public void addAttachedArtifact( Artifact artifact ) { getAttachedArtifacts().add( artifact ); }
/** * Add or replace an artifact. This method is now deprecated. Use the @{MavenProjectHelper} to attach artifacts to a * project. In spite of the 'throws' declaration on this API, this method has never thrown an exception since Maven * 3.0.x. Historically, it logged and ignored a second addition of the same g/a/v/c/t. Now it replaces the file for * the artifact, so that plugins (e.g. shade) can change the pathname of the file for a particular set of * coordinates. * * @param artifact the artifact to add or replace. * @throws DuplicateArtifactAttachmentException */ public void addAttachedArtifact( Artifact artifact ) throws DuplicateArtifactAttachmentException { getAttachedArtifacts().add( artifact ); }
Artifact attached = findMatchingArtifact( ref.getAttachedArtifacts(), pluginArtifact ); if ( attached != null )
/** * Tries to resolve the specified artifact from the artifacts of the given project. * * @param project The project to try to resolve the artifact from, must not be <code>null</code>. * @param requestedArtifact The artifact to resolve, must not be <code>null</code>. * @return The matching artifact from the project or <code>null</code> if not found. Note that this */ private Artifact findMatchingArtifact( MavenProject project, Artifact requestedArtifact ) { String requestedRepositoryConflictId = ArtifactIdUtils.toVersionlessId( requestedArtifact ); Artifact mainArtifact = RepositoryUtils.toArtifact( project.getArtifact() ); if ( requestedRepositoryConflictId.equals( ArtifactIdUtils.toVersionlessId( mainArtifact ) ) ) { return mainArtifact; } for ( Artifact attachedArtifact : RepositoryUtils.toArtifacts( project.getAttachedArtifacts() ) ) { if ( attachedArtifactComparison( requestedArtifact, attachedArtifact ) ) { return attachedArtifact; } } return null; }
if ( project.getAttachedArtifacts() != null ) setAttachedArtifacts( new ArrayList<>( project.getAttachedArtifacts() ) );
if ( project.getAttachedArtifacts() != null ) setAttachedArtifacts( new ArrayList( project.getAttachedArtifacts() ) );
private void extractModuleAttachedArtifacts(MavenProject project, Set<Artifact> artifacts) { List<Artifact> attachedArtifacts = project.getAttachedArtifacts(); if (attachedArtifacts != null) { for (Artifact attachedArtifact : attachedArtifacts) { artifacts.add(attachedArtifact); } } }
private File getAttachedFeatureFile(MavenProject project) { List<Artifact> attachedArtifacts = project.getAttachedArtifacts(); for (Artifact artifact : attachedArtifacts) { if ("features".equals(artifact.getClassifier()) && "xml".equals(artifact.getType())) { return artifact.getFile(); } } return null; }
private Artifact getArtifact(String classifier) { if (classifier != null) { for (Artifact attachedArtifact : this.project.getAttachedArtifacts()) { if (classifier.equals(attachedArtifact.getClassifier()) && attachedArtifact.getFile() != null && attachedArtifact.getFile().isFile()) { return attachedArtifact; } } } return null; }
private Map<String,String> configureTranslatedUrls() { Map<String, String> urls = new HashMap<>(); List<Artifact> artifacts = new ArrayList<>(project.getAttachedArtifacts()); artifacts.add(project.getArtifact()); for (Artifact artifact : artifacts) { if (artifact.getFile() != null && artifact.getFile().exists()) { String mvnUrl = artifactToMvn(artifact); urls.put(mvnUrl, artifact.getFile().toURI().toString()); } } urls.putAll(translatedUrls); return urls; }
/** * Returns true if the project has any artifacts to be catalogued. * * @return true if the primary artifact has a real file part as defined by {@link #hasFile(Artifact)}, or if any * attached artifacts are present. */ private boolean hasCataloguableArtifacts() { return hasFile(project.getArtifact()) || !project.getAttachedArtifacts().isEmpty(); }
private File getAttachedFeatureFile(MavenProject project) { List<Artifact> attachedArtifacts = project.getAttachedArtifacts(); for (Artifact artifact : attachedArtifacts) { if ("features".equals(artifact.getClassifier()) && "xml".equals(artifact.getType())) { return artifact.getFile(); } } return null; }
private Map<String,String> configureTranslatedUrls() { Map<String, String> urls = new HashMap<>(); List<Artifact> artifacts = new ArrayList<>(project.getAttachedArtifacts()); artifacts.add(project.getArtifact()); for (Artifact artifact : artifacts) { if (artifact.getFile() != null && artifact.getFile().exists()) { String mvnUrl = artifactToMvn(artifact); urls.put(mvnUrl, artifact.getFile().toURI().toString()); } } urls.putAll(translatedUrls); return urls; }
private void addAttachedArtifacts(Properties props) { for (Artifact a : this.project.getAttachedArtifacts()) { props.setProperty(RepositoryUtils.toArtifact(a).toString(), getProjectRelativePath(a.getFile())); } }
private static void putProject(MutableWorkspaceState state, MavenProject other) { state.putPom(other.getFile(), other.getGroupId(), other.getArtifactId(), other.getVersion()); if (other.getArtifact().getFile() != null) { putArtifact(state, other.getArtifact()); } for (Artifact artifact : other.getAttachedArtifacts()) { putArtifact(state, artifact); } }
private static void putProject(MutableWorkspaceState state, MavenProject other) { state.putPom(other.getFile(), other.getGroupId(), other.getArtifactId(), other.getVersion()); if (other.getArtifact().getFile() != null) { putArtifact(state, other.getArtifact()); } for (Artifact artifact : other.getAttachedArtifacts()) { putArtifact(state, artifact); } }
private Artifact resolveAttachedWsdl(Artifact artifact) { List<MavenProject> rProjects = mavenSession.getProjects(); List<Artifact> artifactList = new ArrayList<>(); for (MavenProject rProject : rProjects) { List<Artifact> list = CastUtils.cast(rProject.getAttachedArtifacts()); if (list != null) { artifactList.addAll(list); } } return findWsdlArtifact(artifact, artifactList); }
private Artifact resolveAttachedWsdl(Artifact artifact) { List<MavenProject> rProjects = mavenSession.getProjects(); List<Artifact> artifactList = new ArrayList<>(); for (MavenProject rProject : rProjects) { List<Artifact> list = CastUtils.cast(rProject.getAttachedArtifacts()); if (list != null) { artifactList.addAll(list); } } return findWsdlArtifact(artifact, artifactList); }
/** * Mojos perform different dependency resolution, so we need to check this for each mojo. */ public boolean postExecute(MavenBuildProxy build, MavenProject pom, MojoInfo mojo, BuildListener listener, Throwable error) throws InterruptedException, IOException { // TODO (kutzi, 2011/09/06): it should be perfectly safe to move all these records to the // postBuild method as artifacts should only be added by mojos, but never removed/modified. record(pom.getArtifacts(),used); record(pom.getArtifact(),produced); record(pom.getAttachedArtifacts(),produced); record(pom.getGroupId() + ":" + pom.getArtifactId(),pom.getFile(),produced); return true; }
/** * Mojos perform different dependency resolution, so we need to check this for each mojo. */ public boolean postExecute(MavenBuildProxy build, MavenProject pom, MojoInfo mojo, BuildListener listener, Throwable error) throws InterruptedException, IOException { record(pom.getArtifacts(),used); record(pom.getArtifact(),produced); record(pom.getAttachedArtifacts(),produced); record(pom.getGroupId(),pom.getFile(),produced); return true; }