Java Code Examples for org.apache.maven.model.Model#getLicenses()
The following examples show how to use
org.apache.maven.model.Model#getLicenses() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArtifactServerUtil.java From LicenseScout with Apache License 2.0 | 6 votes |
private boolean evaluatePomLicenses(final Archive archive, final String filePath, final LicenseStoreData licenseStoreData, final Model model) { boolean licenseFound = false; final List<org.apache.maven.model.License> licenses = model.getLicenses(); for (final org.apache.maven.model.License license : licenses) { final String licenseUrl = license.getUrl(); final String licenseName = license.getName(); log.debug("License name: " + licenseName); log.debug("License URL: " + licenseUrl); final boolean licenseFoundForUrl = LicenseUtil.handleLicenseUrl(licenseUrl, archive, filePath, licenseStoreData, log); licenseFound |= licenseFoundForUrl; boolean licenseFoundForName = false; if (!licenseFoundForUrl) { licenseFoundForName = LicenseUtil.handleLicenseName(licenseName, archive, filePath, licenseStoreData, log); licenseFound |= licenseFoundForName; } if (!licenseFoundForUrl && !licenseFoundForName) { log.warn("Neither license name nor license URL mapping found for name/URL: " + licenseName + " / " + licenseUrl); } } return licenseFound; }
Example 2
Source File: LicenseFinder.java From sonarqube-licensecheck with Apache License 2.0 | 5 votes |
public static List<License> getLicenses(File filePath, String userSettings, String globalSettings) { try { Model model = new MavenXpp3Reader().read(new FileInputStream(filePath)); if (!model.getLicenses().isEmpty()) { return model.getLicenses(); } else { if (model.getParent() != null) { Parent parent = model.getParent(); Dependency dependency = new Dependency(parent.getGroupId() + ":" + parent.getArtifactId(), parent.getVersion(), null); return getLicenses(DirectoryFinder.getPomPath(dependency, DirectoryFinder.getMavenRepsitoryDir(userSettings, globalSettings)), userSettings, globalSettings); } else { return Collections.emptyList(); } } } catch (Exception e) { LOGGER.warn("Could not parse Maven POM " + filePath, e); return Collections.emptyList(); } }
Example 3
Source File: PomProperty.java From flatten-maven-plugin with Apache License 2.0 | 4 votes |
@Override public List<License> get( Model model ) { return model.getLicenses(); }