List of usage examples for org.apache.maven.project MavenProject getArtifactId
public String getArtifactId()
From source file:org.guvnor.common.services.project.backend.server.RepositoryResolverTestUtils.java
License:Apache License
/** * Deploy a Maven Project to the 'Remote' Maven Repository defined in the Project's {code}<distribtionManagement>{code} section. * @param mavenProject/*from w w w. j a v a 2 s. co m*/ * @param pomXml */ public static void deployArtifact(final MavenProject mavenProject, final String pomXml) { final ReleaseId releaseId = new ReleaseIdImpl(mavenProject.getGroupId(), mavenProject.getArtifactId(), mavenProject.getVersion()); //Create temporary files for the JAR and POM final Aether aether = new Aether(mavenProject); final File jarFile = new File(System.getProperty("java.io.tmpdir"), toFileName(releaseId, null) + ".jar"); try { FileOutputStream fos = new FileOutputStream(jarFile); fos.write("content".getBytes()); fos.flush(); fos.close(); } catch (IOException e) { throw new RuntimeException(e); } final File pomFile = new File(System.getProperty("java.io.tmpdir"), toFileName(releaseId, null) + ".pom"); try { FileOutputStream fos = new FileOutputStream(pomFile); fos.write(pomXml.getBytes()); fos.flush(); fos.close(); } catch (IOException e) { throw new RuntimeException(e); } //Artifact representing the JAR Artifact jarArtifact = new DefaultArtifact(releaseId.getGroupId(), releaseId.getArtifactId(), "jar", releaseId.getVersion()); jarArtifact = jarArtifact.setFile(jarFile); //Artifact representing the POM Artifact pomArtifact = new SubArtifact(jarArtifact, "", "pom"); pomArtifact = pomArtifact.setFile(pomFile); //Read <distributionManagement> section final DistributionManagement distributionManagement = mavenProject.getDistributionManagement(); if (distributionManagement != null) { final DeployRequest deployRequest = new DeployRequest(); deployRequest.addArtifact(jarArtifact).addArtifact(pomArtifact).setRepository( getRemoteRepoFromDeployment(distributionManagement.getRepository(), aether.getSession())); try { aether.getSystem().deploy(aether.getSession(), deployRequest); } catch (DeploymentException e) { throw new RuntimeException(e); } } }
From source file:org.heneveld.maven.license_audit.util.Coords.java
public static Coords of(MavenProject x) { // prefer artifact coords as that will be canonical, but it might not be available, e.g. for root project if (x.getArtifact() != null) return of(x.getArtifact()); return new Coords(x.getGroupId(), x.getArtifactId(), x.getVersion(), x.getVersion(), "", ""); }
From source file:org.hsc.novelSpider.bundleplugin.BundlePlugin.java
License:Apache License
/** * @param jar/* w w w.jav a 2 s.co m*/ * @throws IOException */ private void doMavenMetadata(MavenProject currentProject, Jar jar) throws IOException { String path = "META-INF/maven/" + currentProject.getGroupId() + "/" + currentProject.getArtifactId(); File pomFile = new File(currentProject.getBasedir(), "pom.xml"); jar.putResource(path + "/pom.xml", new FileResource(pomFile)); Properties p = new Properties(); p.put("version", currentProject.getVersion()); p.put("groupId", currentProject.getGroupId()); p.put("artifactId", currentProject.getArtifactId()); ByteArrayOutputStream out = new ByteArrayOutputStream(); p.store(out, "Generated by org.hsc.novelSpider.bundleplugin"); jar.putResource(path + "/pom.properties", new EmbeddedResource(out.toByteArray(), System.currentTimeMillis())); }
From source file:org.hsc.novelSpider.bundleplugin.BundlePlugin.java
License:Apache License
protected Properties getDefaultProperties(MavenProject currentProject) { Properties properties = new Properties(); String bsn;/*from ww w .j a va2 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.hudsonci.maven.eventspy_30.MavenProjectConverter.java
License:Open Source License
public static MavenCoordinatesDTO asCoordinates(final MavenProject mavenProject) { checkNotNull(mavenProject);/*from w ww . java 2 s. c om*/ // Assume groupId, artifactId and version are never null. return new MavenCoordinatesDTO().withGroupId(mavenProject.getGroupId()) .withArtifactId(mavenProject.getArtifactId()).withType(nullSafeString(mavenProject.getPackaging())) .withVersion(mavenProject.getVersion()).normalize(); }
From source file:org.hypoport.milk.maven.plugin.UpdateVersionsMojo.java
License:Apache License
/** * {@inheritDoc}//from w ww.j a va 2 s.c o m */ public void execute() throws MojoExecutionException, MojoFailureException { for (MavenProject project : reactorProjects) { versionChanges.add(new VersionChange(project.getGroupId(), project.getArtifactId(), "", newVersion)); } process(); }
From source file:org.impalaframework.maven.plugin.MojoUtils.java
License:Apache License
public static boolean checkConditionFromPropertyAndPackaging(MavenProject project, String propertyName, String packagingName, Log log) { final Properties properties = project.getProperties(); String moduleJarProperty = properties.getProperty(propertyName); if (moduleJarProperty != null && moduleJarProperty.length() > 0) { final boolean parseBoolean = Boolean.parseBoolean(moduleJarProperty); if (!parseBoolean) { log.debug("Not supporting " + project.getArtifactId() + " as it has set the '" + propertyName + "' property to false"); return false; }/* ww w. ja v a 2s .c o m*/ return parseBoolean; } final boolean isJar = packagingName.equals(project.getPackaging()); if (!isJar) { log.debug("Not supporting " + project.getArtifactId() + " as it does not use '" + packagingName + "' packaging"); return false; } return true; }
From source file:org.itcollege.valge.licenseaudit.model.Project.java
public Project(MavenProject project, List<Scope> scopes) { this.name = project.getName(); this.artifactId = project.getArtifactId(); this.groupId = project.getGroupId(); this.version = project.getVersion(); this.scopes = scopes; }
From source file:org.jacoco.maven.AggregateReportMojo.java
License:Open Source License
private List<MavenProject> getIncludedModules() { List<MavenProject> included = new ArrayList<MavenProject>(); for (MavenProject module : (List<MavenProject>) reactorProjects) { if (!skippedModules.contains(module.getArtifactId())) { included.add(module);/*from w w w . j a v a 2s. c o m*/ } } return included; }
From source file:org.jacoco.maven.ReportAggregateMojo.java
License:Open Source License
@Override void createReport(final IReportGroupVisitor visitor, final ReportSupport support) throws IOException { final IReportGroupVisitor group = visitor.visitGroup(title); for (final MavenProject dependency : findDependencies(Artifact.SCOPE_COMPILE, Artifact.SCOPE_RUNTIME, Artifact.SCOPE_PROVIDED)) {// w w w .j a va2 s. c om support.processProject(group, dependency.getArtifactId(), dependency, getIncludes(), getExcludes(), sourceEncoding); } }