List of usage examples for org.apache.maven.project MavenProject getLicenses
public List<License> getLicenses()
From source file:org.codehaus.mojo.unix.maven.plugin.MavenProjectWrapper.java
License:Open Source License
public static MavenProjectWrapper mavenProjectWrapper(final MavenProject project, MavenSession session) { SortedMap<String, String> properties = new TreeMap<String, String>(); // This is perhaps not ideal. Maven uses reflection to dynamically extract properties from the project // when interpolating each file. This uses a static list that doesn't contain the project.* properties, except // the new we hard-code support for. ///*from w w w . j ava 2 s. com*/ // The user can work around this like this: // <properties> // <project.build.directory>${project.build.directory}</project.build.directory> // </properties> // // If this has to change, the properties has to be a F<String, String> and interpolation tokens ("${" and "}") // has to be defined. Doable but too painful for now. properties.putAll(toMap(session.getSystemProperties())); properties.putAll(toMap(session.getUserProperties())); properties.putAll(toMap(project.getProperties())); properties.put("project.groupId", project.getGroupId()); properties.put("project.artifactId", project.getArtifactId()); properties.put("project.version", project.getVersion()); return new MavenProjectWrapper(project.getGroupId(), project.getArtifactId(), project.getVersion(), project.getArtifact(), project.getName(), project.getDescription(), project.getBasedir(), new File(project.getBuild().getDirectory()), new LocalDateTime(), project.getArtifacts(), project.getLicenses(), new ArtifactMap(project.getArtifacts()), unmodifiableSortedMap(properties)); }
From source file:org.heneveld.maven.license_audit.util.ProjectsOverrides.java
public List<License> getLicense(MavenProject p) { if (p == null) return null; List<License> result = null; result = parseAsLicenses(getOverridesForProject(p).get("license")); if (result != null) return result; // anything on project trumps something unversioned result = p.getLicenses(); // semantics of MavenProject is never to return null if (result != null && !result.isEmpty()) return result; // next look up unversioned (as a default if nothing specified) result = getLicense(Coords.of(p).unversioned()); if (result != null) return result; return Collections.emptyList(); }
From source file:org.hsc.novelSpider.bundleplugin.BundlePlugin.java
License:Apache License
protected Properties getDefaultProperties(MavenProject currentProject) { Properties properties = new Properties(); String bsn;/*from w w w.j a v a 2 s . c o m*/ try { bsn = getMaven2OsgiConverter().getBundleSymbolicName(currentProject.getArtifact()); } catch (Exception e) { bsn = currentProject.getGroupId() + "." + currentProject.getArtifactId(); } // Setup defaults properties.put(MAVEN_SYMBOLICNAME, bsn); properties.put(Analyzer.BUNDLE_SYMBOLICNAME, bsn); properties.put(Analyzer.IMPORT_PACKAGE, "*"); properties.put(Analyzer.BUNDLE_VERSION, getMaven2OsgiConverter().getVersion(currentProject.getVersion())); // remove the extraneous Include-Resource and Private-Package entries from generated manifest properties.put(Constants.REMOVEHEADERS, Analyzer.INCLUDE_RESOURCE + ',' + Analyzer.PRIVATE_PACKAGE); header(properties, Analyzer.BUNDLE_DESCRIPTION, currentProject.getDescription()); StringBuffer licenseText = printLicenses(currentProject.getLicenses()); if (licenseText != null) { header(properties, Analyzer.BUNDLE_LICENSE, licenseText); } header(properties, Analyzer.BUNDLE_NAME, currentProject.getName()); if (currentProject.getOrganization() != null) { if (currentProject.getOrganization().getName() != null) { String organizationName = currentProject.getOrganization().getName(); header(properties, Analyzer.BUNDLE_VENDOR, organizationName); properties.put("project.organization.name", organizationName); properties.put("pom.organization.name", organizationName); } if (currentProject.getOrganization().getUrl() != null) { String organizationUrl = currentProject.getOrganization().getUrl(); header(properties, Analyzer.BUNDLE_DOCURL, organizationUrl); properties.put("project.organization.url", organizationUrl); properties.put("pom.organization.url", organizationUrl); } } properties.putAll(currentProject.getProperties()); properties.putAll(currentProject.getModel().getProperties()); if (m_mavenSession != null) { try { // don't pass upper-case session settings to bnd as they end up in the manifest Properties sessionProperties = m_mavenSession.getExecutionProperties(); for (Enumeration e = sessionProperties.propertyNames(); e.hasMoreElements();) { String key = (String) e.nextElement(); if (key.length() > 0 && !Character.isUpperCase(key.charAt(0))) { properties.put(key, sessionProperties.getProperty(key)); } } } catch (Exception e) { getLog().warn("Problem with Maven session properties: " + e.getLocalizedMessage()); } } properties.putAll(getProperties(currentProject.getModel(), "project.build.")); properties.putAll(getProperties(currentProject.getModel(), "pom.")); properties.putAll(getProperties(currentProject.getModel(), "project.")); properties.put("project.baseDir", getBase(currentProject)); properties.put("project.build.directory", getBuildDirectory()); properties.put("project.build.outputdirectory", getOutputDirectory()); properties.put("classifier", classifier == null ? "" : classifier); getLog().info("BlueprintPlugin"); // Add default plugins header(properties, Analyzer.PLUGIN, SpringXMLType.class.getName()); //header( properties, Analyzer.PLUGIN, BlueprintPlugin.class.getName() + "," + SpringXMLType.class.getName() ); return properties; }
From source file:org.kaazing.license.maven.plugin.AbstractLicenseMojo.java
License:Open Source License
List<License> getLicenses(MavenProject project) { @SuppressWarnings("unchecked") List<License> licenses = project.getLicenses(); return licenses; }
From source file:org.linuxstuff.mojo.licensing.AbstractLicensingMojo.java
protected Set<String> collectLicensesForMavenProject(MavenProject mavenProject) { Set<String> licenses = new HashSet<String>(); /**//from ww w. j a va 2 s .c o m * If an artifact declares a license, we will use it <b>instead</b> of * anything defined in licensing requirements. */ if (mavenProject.getLicenses() != null && mavenProject.getLicenses().size() > 0) { getLog().debug("Licensing: " + mavenProject.getId() + " has licensing information in it."); List<License> embeddedLicenses = mavenProject.getLicenses(); for (License license : embeddedLicenses) { if (license.getName() != null) { licenses.add(licensingRequirements.getCorrectLicenseName(license.getName())); } } } else { Set<String> hardcodedLicenses = licensingRequirements.getLicenseNames(mavenProject.getId()); for (String license : hardcodedLicenses) { licenses.add(licensingRequirements.getCorrectLicenseName(license)); } } return licenses; }
From source file:org.sonar.updatecenter.deprecated.UpdateCenter.java
License:Open Source License
private History<Plugin> resolvePluginHistory(String id) throws Exception { String groupId = StringUtils.substringBefore(id, ":"); String artifactId = StringUtils.substringAfter(id, ":"); Artifact artifact = artifactFactory.createArtifact(groupId, artifactId, Artifact.LATEST_VERSION, Artifact.SCOPE_COMPILE, ARTIFACT_JAR_TYPE); List<ArtifactVersion> versions = filterSnapshots( metadataSource.retrieveAvailableVersions(artifact, localRepository, remoteRepositories)); History<Plugin> history = new History<Plugin>(); for (ArtifactVersion version : versions) { Plugin plugin = org.sonar.updatecenter.deprecated.Plugin .extractMetadata(resolve(artifact.getGroupId(), artifact.getArtifactId(), version.toString())); history.addArtifact(version, plugin); MavenProject project = mavenProjectBuilder .buildFromRepository(//from w ww. java2 s. c o m artifactFactory.createArtifact(groupId, artifactId, version.toString(), Artifact.SCOPE_COMPILE, ARTIFACT_POM_TYPE), remoteRepositories, localRepository); if (plugin.getVersion() == null) { // Legacy plugin - set default values plugin.setKey(project.getArtifactId()); plugin.setName(project.getName()); plugin.setVersion(project.getVersion()); String sonarVersion = "1.10"; // TODO Is it minimal version for all extension points ? for (Dependency dependency : project.getDependencies()) { if ("sonar-plugin-api".equals(dependency.getArtifactId())) { // TODO dirty hack sonarVersion = dependency.getVersion(); } } plugin.setRequiredSonarVersion(sonarVersion); plugin.setHomepage(project.getUrl()); } plugin.setDownloadUrl(getPluginDownloadUrl(groupId, artifactId, plugin.getVersion())); // There is no equivalent for following properties in MANIFEST.MF if (project.getIssueManagement() != null) { plugin.setIssueTracker(project.getIssueManagement().getUrl()); } else { System.out.println("Unknown Issue Management for " + plugin.getKey() + ":" + plugin.getVersion()); } if (project.getScm() != null) { String scmUrl = project.getScm().getUrl(); if (StringUtils.startsWith(scmUrl, "scm:")) { scmUrl = StringUtils.substringAfter(StringUtils.substringAfter(scmUrl, ":"), ":"); } plugin.setSources(scmUrl); } else { System.out.println("Unknown SCM for " + plugin.getKey() + ":" + plugin.getVersion()); } if (project.getLicenses() != null && project.getLicenses().size() > 0) { plugin.setLicense(project.getLicenses().get(0).getName()); } else { System.out.println("Unknown License for " + plugin.getKey() + ":" + plugin.getVersion()); } if (project.getDevelopers().size() > 0) { plugin.setDevelopers(project.getDevelopers()); } else { System.out.println("Unknown Developers for " + plugin.getKey() + ":" + plugin.getVersion()); } } return history; }
From source file:org.wisdom.maven.utils.MavenUtils.java
License:Apache License
/** * Gets the default set of properties for the given project. * * @param currentProject the project/* w ww .jav a 2 s . co m*/ * @return the set of properties, containing default bundle packaging instructions. */ public static Properties getDefaultProperties(MavenProject currentProject) { Properties properties = new Properties(); String bsn = DefaultMaven2OsgiConverter.getBundleSymbolicName(currentProject.getArtifact()); // Setup defaults properties.put(MAVEN_SYMBOLICNAME, bsn); properties.put("bundle.file.name", DefaultMaven2OsgiConverter.getBundleFileName(currentProject.getArtifact())); properties.put(Analyzer.BUNDLE_SYMBOLICNAME, bsn); properties.put(Analyzer.IMPORT_PACKAGE, "*"); properties.put(Analyzer.BUNDLE_VERSION, DefaultMaven2OsgiConverter.getVersion(currentProject.getVersion())); header(properties, Analyzer.BUNDLE_DESCRIPTION, currentProject.getDescription()); StringBuilder licenseText = printLicenses(currentProject.getLicenses()); if (licenseText != null) { header(properties, Analyzer.BUNDLE_LICENSE, licenseText); } header(properties, Analyzer.BUNDLE_NAME, currentProject.getName()); if (currentProject.getOrganization() != null) { if (currentProject.getOrganization().getName() != null) { String organizationName = currentProject.getOrganization().getName(); header(properties, Analyzer.BUNDLE_VENDOR, organizationName); properties.put("project.organization.name", organizationName); properties.put("pom.organization.name", organizationName); } if (currentProject.getOrganization().getUrl() != null) { String organizationUrl = currentProject.getOrganization().getUrl(); header(properties, Analyzer.BUNDLE_DOCURL, organizationUrl); properties.put("project.organization.url", organizationUrl); properties.put("pom.organization.url", organizationUrl); } } properties.putAll(currentProject.getModel().getProperties()); for (String s : currentProject.getFilters()) { File filterFile = new File(s); if (filterFile.isFile()) { properties.putAll(PropertyUtils.loadProperties(filterFile)); } } properties.putAll(getProperties(currentProject.getModel(), "project.build.")); properties.putAll(getProperties(currentProject.getModel(), "pom.")); properties.putAll(getProperties(currentProject.getModel(), "project.")); properties.put("project.baseDir", currentProject.getBasedir().getAbsolutePath()); properties.put("project.build.directory", currentProject.getBuild().getDirectory()); properties.put("project.build.outputdirectory", currentProject.getBuild().getOutputDirectory()); properties.put("project.source.roots", getArray(currentProject.getCompileSourceRoots())); properties.put("project.testSource.roots", getArray(currentProject.getTestCompileSourceRoots())); properties.put("project.resources", toString(currentProject.getResources())); properties.put("project.testResources", toString(currentProject.getTestResources())); return properties; }
From source file:se.natusoft.tools.codelicmgr.MojoUtils.java
License:Open Source License
/** * This will take config values that are not specified or specified as blank and * look for that information elsewhere in the maven project and if found, update * the configuration with that information. * <p>// w w w . j a va 2 s . com * The reason for this is to minimize duplication of information in the pom. Some * of the information managed by CodeLicenseManager is also available as standard * information in a pom and is used by site:site to generate documentation. * * @param project The CLM project config. * @param mavenProject Maven project info from pom. */ public static ProjectConfig updateConfigFromMavenProject(ProjectConfig project, MavenProject mavenProject) { // Project if (project == null) { // Will be null if no <project> tag is specified! project = new ProjectConfig(); } if (isEmpty(project.getName())) { project.setName(getFirstNonEmpty(mavenProject.getName(), mavenProject.getArtifactId())); } if (isEmpty(project.getDescription())) { project.setDescription(mavenProject.getDescription()); } // License LicenseConfig licenseConf = project.getLicense(); if (licenseConf == null) { licenseConf = new LicenseConfig(); project.setLicense(licenseConf); } if (licenseConf.getType() == null) { List<org.apache.maven.model.License> lics = mavenProject.getLicenses(); if (lics != null && lics.size() >= 1) { org.apache.maven.model.License lic = lics.get(0); String licName = getLicenseName(lic.getName().replaceAll("-", " ")); if (licName.trim().length() > 0) { licenseConf.setType(licName); } String licVer = getLicenseVersion(lic.getName().replaceAll("-", " ")); if (licVer.trim().length() > 0) { licenseConf.setVersion(licVer); } } } // Copyright if (project.getCopyrights().getCopyrights().size() == 0) { CopyrightConfig copyrightConf = new CopyrightConfig(); copyrightConf.setHolder(mavenProject.getOrganization().getName()); copyrightConf.setYear(mavenProject.getInceptionYear()); project.getCopyrights().addCopyright(copyrightConf); } return project; }