Example usage for org.apache.maven.artifact.handler ArtifactHandler getDirectory

List of usage examples for org.apache.maven.artifact.handler ArtifactHandler getDirectory

Introduction

In this page you can find the example usage for org.apache.maven.artifact.handler ArtifactHandler getDirectory.

Prototype

String getDirectory();

Source Link

Usage

From source file:org.apache.archiva.converter.artifact.LegacyRepositoryLayout.java

License:Apache License

@Override
public String pathOf(Artifact artifact) {
    ArtifactHandler artifactHandler = artifact.getArtifactHandler();

    StringBuilder path = new StringBuilder(128);

    path.append(artifact.getGroupId()).append('/');
    path.append(artifactHandler.getDirectory()).append('/');
    path.append(artifact.getArtifactId()).append('-').append(artifact.getVersion());

    if (artifact.hasClassifier()) {
        path.append('-').append(artifact.getClassifier());
    }/*www  .j a  v  a  2s.  c o  m*/

    if (artifactHandler.getExtension() != null && artifactHandler.getExtension().length() > 0) {
        path.append('.').append(artifactHandler.getExtension());
    }

    return path.toString();
}

From source file:org.apache.nifi.NarProvidedDependenciesMojo.java

License:Apache License

/**
 * Creates a new ArtifactHandler for the specified Artifact that overrides the includeDependencies flag. When set, this flag prevents transitive
 * dependencies from being printed in dependencies plugin.
 *
 * @param artifact  The artifact//from   w  w  w .j  a v  a  2s. c  om
 * @return          The handler for the artifact
 */
private ArtifactHandler excludesDependencies(final Artifact artifact) {
    final ArtifactHandler orig = artifact.getArtifactHandler();

    return new ArtifactHandler() {
        @Override
        public String getExtension() {
            return orig.getExtension();
        }

        @Override
        public String getDirectory() {
            return orig.getDirectory();
        }

        @Override
        public String getClassifier() {
            return orig.getClassifier();
        }

        @Override
        public String getPackaging() {
            return orig.getPackaging();
        }

        // mark dependencies has excluded so they will appear in tree listing
        @Override
        public boolean isIncludesDependencies() {
            return false;
        }

        @Override
        public String getLanguage() {
            return orig.getLanguage();
        }

        @Override
        public boolean isAddedToClasspath() {
            return orig.isAddedToClasspath();
        }
    };
}

From source file:org.sourcepit.common.maven.artifact.MavenArtifactUtils.java

License:Apache License

@NotNull
public static MavenArtifact toMavenArtifact(@NotNull Artifact artifact) {
    final MavenArtifact mavenArtifact = MavenModelFactory.eINSTANCE.createMavenArtifact();
    mavenArtifact.setGroupId(artifact.getGroupId());
    mavenArtifact.setArtifactId(artifact.getArtifactId());
    mavenArtifact.setVersion(artifact.getVersion());
    if (artifact.getClassifier() != null
            && !ObjectUtils.equals(mavenArtifact.getClassifier(), artifact.getClassifier())) {
        mavenArtifact.setClassifier(artifact.getClassifier());
    }/*from w ww .j av a 2  s.c  o m*/
    if (artifact.getType() != null && !ObjectUtils.equals(mavenArtifact.getType(), artifact.getType())) {
        mavenArtifact.setType(artifact.getType());
    }
    mavenArtifact.setFile(artifact.getFile());

    final ArtifactHandler artifactHandler = artifact.getArtifactHandler();

    final Annotation annotation = mavenArtifact.getAnnotation(ArtifactHandler.class.getName(), true);
    annotation.setData("packaging", artifactHandler.getPackaging());
    annotation.setData("directory", artifactHandler.getDirectory());
    annotation.setData("extension", artifactHandler.getExtension());
    annotation.setData("language", artifactHandler.getLanguage());
    annotation.setData("classifier", artifactHandler.getClassifier());
    annotation.setData("includesDependencies", artifactHandler.isIncludesDependencies());
    annotation.setData("addedToClasspath", artifactHandler.isAddedToClasspath());
    return mavenArtifact;
}