List of usage examples for org.apache.maven.project MavenProject getVersion
public String getVersion()
From source file:com.puppetlabs.geppetto.forge.maven.plugin.Package.java
License:Open Source License
@Override protected void invoke(Diagnostic result) throws Exception { Collection<File> moduleRoots = findModuleRoots(); if (moduleRoots.isEmpty()) { result.addChild(new Diagnostic(ERROR, PACKAGE, "No modules found in repository")); return;//from w ww .j a v a2 s . co m } File buildDir = getBuildDir(); buildDir.mkdirs(); if (moduleRoots.size() == 1) { MavenProject project = getProject(); File moduleRoot = moduleRoots.iterator().next(); Metadata[] resultingMetadata = new Metadata[1]; byte[][] resultingMD5 = new byte[1][]; project.getArtifact() .setFile(buildForge(moduleRoot, buildDir, resultingMetadata, resultingMD5, result)); Artifact pmriArtifact = repositorySystem.createArtifact(project.getGroupId(), project.getArtifactId(), project.getVersion(), "compile", "pmri"); PuppetModuleReleaseInfo pmri = new PuppetModuleReleaseInfo(); pmri.setMetadata(resultingMetadata[0]); pmri.populate(moduleRoot); File pmriFile = new File(buildDir, "release.pmri"); OutputStream out = new FileOutputStream(pmriFile); try { Writer writer = new BufferedWriter(new OutputStreamWriter(out, Charsets.UTF_8)); getGson().toJson(pmri, writer); writer.flush(); } finally { out.close(); } pmriArtifact.setFile(pmriFile); pmriArtifact.setResolved(true); project.addAttachedArtifact(pmriArtifact); } else { File builtModules = new File(buildDir, "builtModules"); if (!(builtModules.mkdir() || builtModules.isDirectory())) { result.addChild( new Diagnostic(ERROR, PACKAGE, "Unable to create directory" + builtModules.getPath())); return; } for (File moduleRoot : moduleRoots) buildForge(moduleRoot, builtModules, null, null, result); } }
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()); if (bomProjects.containsKey(key)) { return;/*from w w w. j a v a 2s. c om*/ } 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()); }// w w w .j a va2s . c om // 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 .ja va 2 s .com*/ 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.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.sixdimensions.wcm.cq.pack.PackageMojo.java
License:Open Source License
public void execute() throws MojoExecutionException { this.getLog().info("execute"); final PackageManagerConfig config = new PackageManagerConfig(); this.initConfig(config); this.getLog().info("Connecting to server: " + config.getHost() + ":" + config.getPort()); this.getLog().info("Connecting with user: " + config.getUser()); this.getLog().debug("Retrieving service"); final PackageManagerService packageMgrSvc = PackageManagerService.Factory.getPackageMgr(config); String packagePath = this.path; if (config.isUseLegacy()) { this.getLog().debug("Checking path: " + packagePath + " for compatibility with legacy API"); final MavenProject project = (MavenProject) this.getPluginContext().get("project"); if (this.path .equals(project.getArtifactId() + "-" + project.getVersion() + "." + project.getPackaging())) { this.getLog().debug("Updating path for legacy API"); packagePath = project.getArtifactId(); } else {/*from w w w . j ava 2 s. c o m*/ this.getLog().debug("Custom path specified, not modifying"); } } try { if (this.deleteFirst) { try { packageMgrSvc.delete(packagePath); } catch (final Exception e) { this.getLog().warn("Exception deleting existing package, continuing with installation.", e); } } packageMgrSvc.upload(packagePath, this.packageFile); this.getLog().info("Package upload successful"); if (!this.uploadOnly) { packageMgrSvc.install(packagePath); this.getLog().info("Package installation successful"); } } catch (final Exception e) { this.getLog().error("Exception uploading/installing package.", e); throw new MojoExecutionException("Exception uploading/installing package.", e); } this.getLog().info("Package Upload/Installation Completed Successfully"); }
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:// ww w . j av a 2s . co 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.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 ww .j a v a2 s .c om * @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); }