List of usage examples for org.apache.maven.project MavenProject getGroupId
public String getGroupId()
From source file:com.redhat.rcm.version.mgr.session.ManagedInfo.java
License:Open Source License
void addBOM(final File bom, final MavenProject project) throws VManException { final FullProjectKey key = new FullProjectKey(project.getGroupId(), project.getArtifactId(), project.getVersion());//from ww w . ja va 2 s. c om if (bomProjects.containsKey(key)) { return; } bomProjects.put(key, project); startBomMap(bom, project.getGroupId(), project.getArtifactId(), project.getVersion()); if (project.getDependencyManagement() != null && project.getDependencyManagement().getDependencies() != null) { for (final Dependency dep : project.getDependencyManagement().getDependencies()) { mapDependency(bom, dep); } } final Properties properties = project.getProperties(); if (properties != null) { final String relocations = properties.getProperty(RELOCATIONS_KEY); logger.info("Got relocations:\n\n" + relocations); if (relocations != null) { logger.warn("[DEPRECATED] BOM-based coordinate relocations have been replaced by the " + Cli.RELOCATIONS_PROPERTY + " configuration, which specifies a URL to a properties file. Please use this instead."); relocatedCoords.addBomRelocations(bom, parseProperties(relocations)); } final String mappings = properties.getProperty(MAPPINGS_KEY); logger.info("Got mappings:\n\n" + mappings); if (mappings != null) { logger.warn("[DEPRECATED] BOM-based property mappings have been replaced by the " + Cli.PROPERTY_MAPPINGS_PROPERTY + " configuration, which specifies a URL to a properties file. Please use this instead."); propertyMappings.addBomPropertyMappings(bom, project.getProperties(), parseProperties(mappings)); } } logger.info("Updating property mappings from " + project.getId()); // NOTE: parent properties are inherited into the BOM by the time the MavenProject instance // is created, so we don't need to traverse up to the parent; we should have everything here. propertyMappings.updateProjectMap(project.getProperties()); }
From source file:com.rodiontsev.maven.plugins.buildinfo.providers.ProjectInfoProvider.java
License:Apache License
public Map<String, String> getInfo(MavenProject project, BuildInfoMojo mojo) { // finite set of project properties we expose final Map<String, String> props = new LinkedHashMap<String, String>(65); props.put("project.id", project.getId()); props.put("project.groupId", project.getGroupId()); props.put("project.artifactId", project.getArtifactId()); props.put("project.version", project.getVersion()); props.put("project.name", project.getName()); props.put("project.description", project.getDescription()); props.put("project.modelVersion", project.getModelVersion()); props.put("project.inceptionYear", project.getInceptionYear()); props.put("project.packaging", project.getPackaging()); props.put("project.url", project.getUrl()); final MavenProject parent = project.getParent(); if (parent != null) { props.put("project.parent.id", parent.getId()); props.put("project.parent.groupId", parent.getGroupId()); props.put("project.parent.artifactId", parent.getArtifactId()); props.put("project.parent.version", parent.getVersion()); props.put("project.parent.name", parent.getName()); props.put("project.parent.description", parent.getDescription()); props.put("project.parent.modelVersion", parent.getModelVersion()); props.put("project.parent.inceptionYear", parent.getInceptionYear()); props.put("project.parent.packaging", parent.getPackaging()); props.put("project.parent.url", parent.getUrl()); }//from ww w. j a va 2s. co m // properties the user wants Map<String, String> info = new LinkedHashMap<String, String>(); for (String propertyName : mojo.getProjectProperties()) { String prop = props.get(propertyName); if (prop != null) { info.put(propertyName, prop); } } info.put("build.time", DateFormatUtils.format(new Date(), "d MMMM yyyy, HH:mm:ss ZZ", Locale.ENGLISH)); return info; }
From source file:com.rodiontsev.maven.plugins.buildinfo.providers.ProjectPropertiesProvider.java
License:Apache License
public Map<String, String> getInfo(MavenProject project, BuildInfoMojo mojo) { // finite set of project properties we expose final Map<String, String> projectProperties = new LinkedHashMap<String, String>(65); projectProperties.put("project.id", project.getId()); projectProperties.put("project.groupId", project.getGroupId()); projectProperties.put("project.artifactId", project.getArtifactId()); projectProperties.put("project.version", project.getVersion()); projectProperties.put("project.name", project.getName()); projectProperties.put("project.description", project.getDescription()); projectProperties.put("project.modelVersion", project.getModelVersion()); projectProperties.put("project.inceptionYear", project.getInceptionYear()); projectProperties.put("project.packaging", project.getPackaging()); projectProperties.put("project.url", project.getUrl()); MavenProject parent = project.getParent(); if (parent != null) { projectProperties.put("project.parent.id", parent.getId()); projectProperties.put("project.parent.groupId", parent.getGroupId()); projectProperties.put("project.parent.artifactId", parent.getArtifactId()); projectProperties.put("project.parent.version", parent.getVersion()); projectProperties.put("project.parent.name", parent.getName()); projectProperties.put("project.parent.description", parent.getDescription()); projectProperties.put("project.parent.modelVersion", parent.getModelVersion()); projectProperties.put("project.parent.inceptionYear", parent.getInceptionYear()); projectProperties.put("project.parent.packaging", parent.getPackaging()); projectProperties.put("project.parent.url", parent.getUrl()); }//from ww w.j av a 2 s . c om Map<String, String> info = new LinkedHashMap<String, String>(); new InfoWriter().write(info, mojo.getProjectProperties(), new PropertyMapper() { @Override public String mapProperty(String propertyName) { return projectProperties.get(propertyName); } }); return info; }
From source file:com.sap.prd.mobile.ios.mios.PreDeployMojo.java
License:Apache License
/** * Returns the unique archive folder for this specific project (containing folders with groupId * and artifactId)//from w w w . j ava 2 s . co m * * @param rootArchiveFolder * @param project * @return */ static File getProjectArchiveFolder(File rootArchiveFolder, MavenProject project) { return new File(new File(new File(rootArchiveFolder, "artifacts"), project.getGroupId()), project.getArtifactId()); }
From source file:com.sap.prd.mobile.ios.mios.XCodePackageManager.java
License:Apache License
private String getBundleReference(MavenProject project, String escapedBundleName) { return GAVUtil.toColonNotation(project.getGroupId(), project.getArtifactId(), project.getVersion(), ZIPPED_BUNDLE_SUFFIX, escapedBundleName); }
From source file:com.soebes.maven.extensions.BuildTimeProfiler.java
License:Apache License
private ProjectKey mavenProjectToProjectKey(MavenProject project) { return new ProjectKey(project.getGroupId(), project.getArtifactId(), project.getVersion()); }
From source file:com.soebes.maven.extensions.MojoTimer.java
License:Apache License
private ProjectKey createProjectKey(MavenProject project) { return new ProjectKey(project.getGroupId(), project.getArtifactId(), project.getVersion()); }
From source file:com.sun.enterprise.module.maven.OSGiPackager.java
License:Open Source License
/** * Reads information from the POM and the artifact archive to configure * the OSGi manifest entries. Returns a new set of entries if the archive * does not already have manifest entries, else it uses the existing entries * map. If any of the attribute already exists, then * it skips its processing honoring user's request. It uses the following * rules://from w w w . j a va2s .c o m * * Bundle-SymbolicName is assumed to be "${groupId}.${artifactId}" * Bundle-Version is derived from "${pom.version}" * using {@link VersionTranslator#MavenToOSGi(String)} * Bundle-Description is assumed to be "${pom.description}". * Bundle-Vendor is assumed to be "${pom.organization.name}". * Require-Bundle is populated by values read from pom dependencies * Note: * There is no support for Export-Package yet. * It sets Bundle-ManifestVersion as 2 which indicates OSGi r4 bundle. * * @param pom The Maven project object * @param archive The archive that is being built * @param classesDirectory output for javac * @return Manifest entries * @throws java.io.IOException */ public Map<String, String> configureOSGiManifest(MavenProject pom, MavenArchiveConfiguration archive, File classesDirectory) throws IOException { Map<String, String> entries; if (archive != null) entries = archive.getManifestEntries(); else entries = new HashMap<String, String>(); if (entries.get(BUNDLE_MANIFESTVERSION) == null) { // 2 indicates compliance with r4, note: there is no value called 1 entries.put(BUNDLE_MANIFESTVERSION, "2"); } if (entries.get(BUNDLE_NAME) == null) { // Bundle-Name is a human readable localizable name that can contain spaces entries.put(BUNDLE_NAME, pom.getName()); } if (entries.get(BUNDLE_SYMBOLICNAME) == null) { // OSGi convention is to use reverse domain name for SymbolicName, hence use . entries.put(BUNDLE_SYMBOLICNAME, pom.getGroupId() + '.' + pom.getArtifactId()); } if (entries.get(BUNDLE_VERSION) == null) { entries.put(BUNDLE_VERSION, VersionTranslator.MavenToOSGi(pom.getVersion())); } if (entries.get(BUNDLE_DESCRIPTION) == null) { if (pom.getDescription() != null) entries.put(BUNDLE_DESCRIPTION, pom.getDescription()); } if (entries.get(BUNDLE_VENDOR) == null) { if (pom.getOrganization() != null && pom.getOrganization().getName() != null) entries.put(BUNDLE_VENDOR, pom.getOrganization().getName()); } // Handle Require-Bundle. if (entries.get(REQUIRE_BUNDLE) == null) { String requiredBundles = generateRequireBundleHeader(discoverRequiredBundles(pom)); if (requiredBundles.length() > 0) { entries.put(REQUIRE_BUNDLE, requiredBundles); } } // Handle Export-Package if (entries.get(EXPORT_PACKAGE) == null) { List<ExportedPackage> packages = discoverPackages(classesDirectory); // don't use version until we resolve split package issues in GF String exportPackages = generateExportPackageHeader(packages, null); if (exportPackages.length() > 0) { entries.put(EXPORT_PACKAGE, exportPackages); } } return entries; }
From source file:com.sun.enterprise.module.maven.Packager.java
License:Open Source License
public Map<String, String> configureManifest(MavenProject pom, MavenArchiveConfiguration archive, File classesDirectory) throws IOException { Map<String, String> entries; if (archive != null) entries = archive.getManifestEntries(); else//from w w w . j a va2 s . co m entries = new HashMap<String, String>(); entries.put(ManifestConstants.BUNDLE_NAME, pom.getGroupId() + '.' + pom.getArtifactId()); // check META-INF/services/xxx.ImportPolicy to fill in Import-Policy configureImportPolicy(classesDirectory, entries, ImportPolicy.class, ManifestConstants.IMPORT_POLICY); configureImportPolicy(classesDirectory, entries, LifecyclePolicy.class, ManifestConstants.LIFECYLE_POLICY); // check direct dependencies to find out dependency modules. // we don't need to list transitive dependencies here, so use getDependencyArtifacts(). TokenListBuilder dependencyModuleNames = new TokenListBuilder(); Set<String> dependencyModules = new HashSet<String>(); // used to find transitive dependencies through other modules. for (Artifact a : (Set<Artifact>) pom.getDependencyArtifacts()) { if (a.getScope() != null && a.getScope().equals("test")) continue; // http://www.nabble.com/V3-gf%3Arun-throws-NPE-tf4816802.html indicates // that some artifacts are not resolved at this point. Not sure when that could happen // so aborting with diagnostics if we find it. We need to better understand what this // means and work accordingly. - KK if (a.getFile() == null) { throw new AssertionError(a.getId() + " is not resolved. a=" + a); } Jar jar; try { jar = Jar.create(a.getFile()); } catch (IOException ioe) { // not a jar file, so continue. continue; } Manifest manifest = jar.getManifest(); String name = null; if (manifest != null) { Attributes attributes = manifest.getMainAttributes(); name = attributes.getValue(ManifestConstants.BUNDLE_NAME); } if (name != null) { // this is a hk2 module if (!a.isOptional()) dependencyModuleNames.add(name); // even optional modules need to be listed here dependencyModules.add(a.getGroupId() + '.' + a.getArtifactId() + ':' + a.getVersion()); } } // find jar files to be listed in Class-Path. This needs to include transitive // dependencies, except when the path involves a hk2 module. TokenListBuilder classPathNames = new TokenListBuilder(" "); TokenListBuilder classPathIds = new TokenListBuilder(" "); for (Artifact a : (Set<Artifact>) pom.getArtifacts()) { // check the trail. does that include hk2 module in the path? boolean throughModule = false; for (String module : dependencyModules) throughModule |= a.getDependencyTrail().get(1).toString().startsWith(module); if (throughModule) continue; // yep if (a.getScope().equals("system") || a.getScope().equals("provided") || a.getScope().equals("test")) continue; // ignore tools.jar and such dependencies. if (a.isOptional()) continue; // optional dependency classPathNames.add(stripVersion(a)); classPathIds.add(a.getId()); } if (!classPathNames.isEmpty()) { String existingClassPath = entries.get(ManifestConstants.CLASS_PATH); if (existingClassPath != null) entries.put(ManifestConstants.CLASS_PATH, existingClassPath + " " + classPathNames); else entries.put(ManifestConstants.CLASS_PATH, classPathNames.toString()); entries.put(ManifestConstants.CLASS_PATH_ID, classPathIds.toString()); } return entries; }
From source file:com.torchmind.maven.plugins.attribution.AttributionMojo.java
License:Apache License
/** * Creates an attribution object using a root artifact and its listed dependencies. * @param artifact the maven project.//from w w w. j a v a2 s . com * @param dependencies the dependencies. * @return the attribution. */ @Nonnull public static AttributionDocument createAttribution(@Nonnull MavenProject artifact, @Nonnull List<Artifact> dependencies, @Nonnull List<Artifact> plugins) { return new AttributionDocument(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getName(), artifact.getDescription(), artifact.getUrl(), artifact.getLicenses().stream().map(AttributionMojo::createLicense).collect(Collectors.toList()), artifact.getDevelopers().stream().map(AttributionMojo::createDeveloper) .collect(Collectors.toList()), artifact.getContributors().stream().map(AttributionMojo::createDeveloper) .collect(Collectors.toList()), dependencies, plugins); }