Search in sources :

Example 1 with ArtifactTranslator

use of org.apache.maven.plugins.dependency.utils.translators.ArtifactTranslator in project maven-plugins by apache.

the class AbstractDependencyFilterMojo method getClassifierTranslatedDependencies.

/**
     * Transform artifacts
     *
     * @param artifacts
     * @param stopOnFailure
     * @return DependencyStatusSets - Bean of TreeSets that contains information
     *         on the projects dependencies
     * @throws MojoExecutionException
     */
protected DependencyStatusSets getClassifierTranslatedDependencies(Set<Artifact> artifacts, boolean stopOnFailure) throws MojoExecutionException {
    Set<Artifact> unResolvedArtifacts = new LinkedHashSet<Artifact>();
    Set<Artifact> resolvedArtifacts = artifacts;
    DependencyStatusSets status = new DependencyStatusSets();
    // if this did something, we need to resolve the new artifacts
    if (StringUtils.isNotEmpty(classifier)) {
        ArtifactTranslator translator = new ClassifierTypeTranslator(artifactHandlerManager, this.classifier, this.type);
        Collection<ArtifactCoordinate> coordinates = translator.translate(artifacts, getLog());
        status = filterMarkedDependencies(artifacts);
        // the unskipped artifacts are in the resolved set.
        artifacts = status.getResolvedDependencies();
        // resolve the rest of the artifacts
        resolvedArtifacts = resolve(new LinkedHashSet<ArtifactCoordinate>(coordinates), stopOnFailure);
        // calculate the artifacts not resolved.
        unResolvedArtifacts.addAll(artifacts);
        unResolvedArtifacts.removeAll(resolvedArtifacts);
    }
    // return a bean of all 3 sets.
    status.setResolvedDependencies(resolvedArtifacts);
    status.setUnResolvedDependencies(unResolvedArtifacts);
    return status;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ArtifactTranslator(org.apache.maven.plugins.dependency.utils.translators.ArtifactTranslator) ArtifactCoordinate(org.apache.maven.shared.artifact.ArtifactCoordinate) ClassifierTypeTranslator(org.apache.maven.plugins.dependency.utils.translators.ClassifierTypeTranslator) DependencyStatusSets(org.apache.maven.plugins.dependency.utils.DependencyStatusSets) Artifact(org.apache.maven.artifact.Artifact)

Aggregations

LinkedHashSet (java.util.LinkedHashSet)1 Artifact (org.apache.maven.artifact.Artifact)1 DependencyStatusSets (org.apache.maven.plugins.dependency.utils.DependencyStatusSets)1 ArtifactTranslator (org.apache.maven.plugins.dependency.utils.translators.ArtifactTranslator)1 ClassifierTypeTranslator (org.apache.maven.plugins.dependency.utils.translators.ClassifierTypeTranslator)1 ArtifactCoordinate (org.apache.maven.shared.artifact.ArtifactCoordinate)1