setArtifact( ArtifactUtils.copyArtifact( project.getArtifact() ) );
repositorySystem.createArtifact( project.getGroupId(), project.getArtifactId(), project.getVersion(), null, project.getPackaging() ); project.setArtifact( projectArtifact );
project.setArtifact( projectArtifact ); project.setProjectBuilderConfiguration( config );
setArtifact( ArtifactUtils.copyArtifact( project.getArtifact() ) );
public void setArtifact(Artifact artifact) { wrapped.setArtifact(artifact); }
public void setArtifact(final Artifact artifact) { getDelegate().setArtifact(artifact); }
public GemArtifact(final MavenProject project) { this.artifact = project.getArtifact(); this.jarFile = this.artifact.getFile(); if (isGem()) { if ( project.getBuild().getFinalName() == null || !project.getGroupId().equals("rubygems")) { this.artifact.setFile(new File(new File(project.getBuild() .getDirectory()), getGemFile())); } else { this.artifact.setFile(new File(new File(project.getBuild() .getDirectory()), project.getBuild().getFinalName() + ".gem" ) ); } } // allow maven2 to do the right thing with the classifier project.setArtifact(this); this.artifact.setArtifactHandler(new GemArtifactHandler(this.artifact.getArtifactHandler())); }
public GemArtifact(final MavenProject project) { this.artifact = project.getArtifact(); this.jarFile = this.artifact.getFile(); if (isGem()) { if ( project.getBuild().getFinalName() == null || !project.getGroupId().equals("rubygems")) { this.artifact.setFile(new File(new File(project.getBuild() .getDirectory()), getGemFile())); } else { this.artifact.setFile(new File(new File(project.getBuild() .getDirectory()), project.getBuild().getFinalName() + ".gem" ) ); } } // allow maven2 to do the right thing with the classifier project.setArtifact(this); this.artifact.setArtifactHandler(new GemArtifactHandler(this.artifact.getArtifactHandler())); }
project.setArtifact( bundle );
/** * Modify main artifact to add a "clover" classifier to it so that it's not mixed with the main artifact of * a normal build. */ private void redirectArtifact() { // Only redirect main artifact for non-pom projects if ( !getProject().getPackaging().equals( "pom" ) ) { Artifact oldArtifact = getProject().getArtifact(); Artifact newArtifact = this.artifactFactory.createArtifactWithClassifier( oldArtifact.getGroupId(), oldArtifact.getArtifactId(), oldArtifact.getVersion(), oldArtifact.getType(), "clover" ); getProject().setArtifact( newArtifact ); getProject().getBuild().setFinalName( getProject().getArtifactId() + "-" + getProject().getVersion() + "-clover" ); } }
@SuppressWarnings("deprecation") private void archive(String type) throws IOException { Artifact artifact1 = factory.createArtifactWithClassifier(project.getArtifact().getGroupId(), project.getArtifact().getArtifactId(), project.getArtifact().getVersion(), type, "bin"); File target1 = archive(targetServerDirectory, destDir, artifact1); // artifact1 is created with explicit classifier "bin", which is dropped below when attachArtifact is called // which means we can't use artifact1.equals(artifact) directly with artifact1 Artifact artifact2 = factory.createArtifact(artifact1.getGroupId(), artifact1.getArtifactId(), artifact1.getVersion(), artifact1.getScope(), artifact1.getType()); for (Artifact artifact : project.getAttachedArtifacts()) { if (artifact2.equals(artifact)) { getLog().debug("Artifact " + artifact2 + " already attached"); return; } } if (attach) { projectHelper.attachArtifact(project, artifact1.getType(), classifier, target1); } if (!project.getPackaging().equals("pom")) { artifact2.setFile(target1); project.setArtifact(artifact2); } }
@SuppressWarnings("deprecation") private void archive(String type) throws IOException { Artifact artifact1 = factory.createArtifactWithClassifier(project.getArtifact().getGroupId(), project.getArtifact().getArtifactId(), project.getArtifact().getVersion(), type, "bin"); File target1 = archive(targetServerDirectory, destDir, artifact1); // artifact1 is created with explicit classifier "bin", which is dropped below when attachArtifact is called // which means we can't use artifact1.equals(artifact) directly with artifact1 Artifact artifact2 = factory.createArtifact(artifact1.getGroupId(), artifact1.getArtifactId(), artifact1.getVersion(), artifact1.getScope(), artifact1.getType()); for (Artifact artifact : project.getAttachedArtifacts()) { if (artifact2.equals(artifact)) { getLog().debug("Artifact " + artifact2 + " already attached"); return; } } if (attach) { projectHelper.attachArtifact(project, artifact1.getType(), classifier, target1); } artifact2.setFile(target1); project.setArtifact(artifact2); }
private void gatherProjectDependencies(MavenProject project, Map<MavenProject, List<Pair<String, String>>> dependencyLicenseMap, Map<String, MavenProject> dependencyGavMap) throws ProjectBuildingException { final Set dependencyArtifacts = project.getArtifacts(); if (dependencyArtifacts != null) { for (Object depArtifactObj : dependencyArtifacts) { final Artifact depArtifact = (Artifact) depArtifactObj; if (!excludedScopes.contains(depArtifact.getScope())) { MavenProject dep = resolveDependency(depArtifact); dep.setArtifact(depArtifact); dependencyGavMap.put(toGav(dep), dep); List<Pair<String, String>> licenseUrls = new ArrayList<>(); for (Object license : dep.getLicenses()) { final License license1 = (License) license; String url = license1.getUrl() != null ? license1.getUrl() : (license1.getName() != null ? license1.getName() : "LICENSE_EMPTY_NAME_URL"); licenseUrls.add(new ImmutablePair<>(url, license1.getName())); } dependencyLicenseMap.put(dep, licenseUrls); } } } }
private MavenProject buildProjectStub( final Artifact depArtifact ) { final Model model = new Model(); model.setGroupId( depArtifact.getGroupId() ); model.setArtifactId( depArtifact.getArtifactId() ); model.setVersion( depArtifact.getBaseVersion() ); model.setPackaging( depArtifact.getType() ); model.setDescription( "Stub for " + depArtifact.getId() ); final MavenProject project = new MavenProject( model ); project.setArtifact( depArtifact ); return project; }
/** * Generates the JAR. */ public void execute() throws MojoExecutionException { File jarFile = createArchive(); String classifier = getClassifier(); if (classifier != null) { projectHelper .attachArtifact(getProject(), getType(), classifier, jarFile); } else { // create a new artifact for the project with the appropriate type. // since by default the type is mapped to the "packaging" Artifact artifact = getProject().getArtifact(); Artifact newArtifact = artifactFactory.createArtifact(artifact .getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getClassifier(), getType()); newArtifact.setFile(jarFile); getProject().setArtifact(newArtifact); // projectHelper.attachArtifact( getProject(), getType(), jarFile ); } } }
@Test public void testRequireSnapshot() throws IOException { project.setArtifact( factory.getReleaseArtifact() ); EnforcerRuleUtilsHelper.execute( rule, helper, true ); project.setArtifact( factory.getSnapshotArtifact() ); EnforcerRuleUtilsHelper.execute( rule, helper, false ); }
MavenProject readProject(File pomFile) throws IOException { MavenXpp3Reader mavenReader = new MavenXpp3Reader(); FileReader fileReader = null; try { fileReader = new FileReader(pomFile); Model model = mavenReader.read(fileReader); model.setPomFile(pomFile); MavenProject project = new MavenProject(model); project.setFile(pomFile); project.setArtifact(createArtifact(pomFile, model.getGroupId(), model.getArtifactId(), model.getVersion(), "compile", model.getPackaging(), "")); return project; } catch (Exception e) { throw new RuntimeException(e); } finally { if (fileReader != null) { fileReader.close(); } } }
private void restoreProjectState(ExecutionEvent event) { if (event.getMojoExecution().getExecutionId() != null && event.getMojoExecution().getExecutionId().endsWith("-snapshot")) { if (!event.getProject().getFile().equals(frozenPomFile)) { event.getProject().setFile(frozenPomFile); event.getProject().setArtifact(frozenArtifact); event.getProject().getAttachedArtifacts().clear(); for (Artifact frozenAttachedArtifact : frozenAttachedArtifacts) { event.getProject().addAttachedArtifact(frozenAttachedArtifact); } if (!isPomArtifact(event.getProject())) { event.getProject().getBuild().setFinalName(frozenFinalName); } } } } }
@Test public void testWithParentShouldFail() throws IOException { project.setArtifact( factory.getSnapshotArtifact() ); rule.setFailWhenParentIsRelease( true ); MockProject parent = new MockProject(); parent.setArtifact( factory.getReleaseArtifact() ); project.setParent( parent ); EnforcerRuleUtilsHelper.execute( rule, helper, true ); parent = new MockProject(); parent.setArtifact( factory.getSnapshotArtifact() ); project.setParent( parent ); EnforcerRuleUtilsHelper.execute( rule, helper, false ); }
@Test public void testWithParentShouldPass() throws IOException { project.setArtifact( factory.getSnapshotArtifact() ); rule.setFailWhenParentIsRelease( false ); MockProject parent = new MockProject(); parent.setArtifact( factory.getReleaseArtifact() ); project.setParent( parent ); EnforcerRuleUtilsHelper.execute( rule, helper, false ); parent = new MockProject(); parent.setArtifact( factory.getSnapshotArtifact() ); project.setParent( parent ); EnforcerRuleUtilsHelper.execute( rule, helper, false ); }