public Set translate()

in src/main/java/org/apache/maven/plugins/dependency/utils/translators/ClassifierTypeTranslator.java [59:118]


    public Set<ArtifactCoordinate> translate(Set<Artifact> artifacts, Log log) {
        Set<ArtifactCoordinate> results;

        log.debug("Translating Artifacts using Classifier: " + this.classifier + " and Type: " + this.type);
        results = new LinkedHashSet<>();
        for (Artifact artifact : artifacts) {
            // this translator must pass both type and classifier here so we
            // will use the
            // base artifact value if null comes in
            final String useType;
            if (this.type != null && !this.type.isEmpty()) {
                useType = this.type;
            } else {
                useType = artifact.getType();
            }

            ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler(useType);

            final String extension;
            if (artifactHandler != null) {
                extension = artifactHandler.getExtension();
            } else {
                extension = this.type;
            }

            String useClassifier;
            if (this.classifier != null && !this.classifier.isEmpty()) {
                useClassifier = this.classifier;
            } else {
                useClassifier = artifact.getClassifier();
            }

            DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate();
            coordinate.setGroupId(artifact.getGroupId());
            coordinate.setArtifactId(artifact.getArtifactId());
            coordinate.setVersion(artifact.getVersion());
            coordinate.setClassifier(useClassifier);
            coordinate.setExtension(extension);

            // // Create a new artifact
            // Artifact newArtifact = factory.createArtifactWithClassifier( artifact.getGroupId(), artifact
            // .getArtifactId(), artifact.getVersion(), useType, useClassifier );
            //
            // // note the new artifacts will always have the scope set to null. We
            // // should
            // // reset it here so that it will pass other filters if needed
            // newArtifact.setScope( artifact.getScope() );
            //
            // if ( Artifact.SCOPE_SYSTEM.equals( newArtifact.getScope() ) )
            // {
            // File baseDir = repositoryManager.getLocalRepositoryBasedir( buildingRequest );
            // String path = repositoryManager.getPathForLocalArtifact( buildingRequest, newArtifact );
            // newArtifact.setFile( new File( baseDir, path ) );
            // }

            results.add(coordinate);
        }

        return results;
    }