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

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

Introduction

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

Prototype

String getClassifier();

Source Link

Document

Get the classifier associated to the dependency type.

Usage

From source file:com.rebaze.maven.support.AetherUtils.java

License:Open Source License

public static ArtifactType newArtifactType(String id, ArtifactHandler handler) {
    return new DefaultArtifactType(id, handler.getExtension(), handler.getClassifier(), handler.getLanguage(),
            handler.isAddedToClasspath(), handler.isIncludesDependencies());
}

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  av  a 2 s.co  m
 * @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.fluidity.deployment.maven.DependenciesSupportImpl.java

License:Apache License

/**
 * Converts a Aether artifact to a Maven artifact.
 *
 * @param original the Maven artifact.//from w  w w. j  a v  a 2  s  .  co m
 *
 * @return the Aether artifact.
 */
private static org.eclipse.aether.artifact.Artifact aetherArtifact(final Artifact original) {
    final String explicitVersion = original.getVersion();
    final VersionRange versionRange = original.getVersionRange();
    final String version = explicitVersion == null && versionRange != null ? versionRange.toString()
            : explicitVersion;

    final boolean isSystem = Artifact.SCOPE_SYSTEM.equals(original.getScope());
    final String path = (original.getFile() != null) ? original.getFile().getPath() : "";
    final Map<String, String> properties = isSystem
            ? Collections.singletonMap(ArtifactProperties.LOCAL_PATH, path)
            : null;

    final ArtifactHandler handler = original.getArtifactHandler();

    final String extension = handler.getExtension();
    final DefaultArtifactType type = new DefaultArtifactType(original.getType(), extension,
            handler.getClassifier(), handler.getLanguage(), handler.isAddedToClasspath(),
            handler.isIncludesDependencies());

    final org.eclipse.aether.artifact.Artifact artifact = new org.eclipse.aether.artifact.DefaultArtifact(
            original.getGroupId(), original.getArtifactId(), original.getClassifier(), extension, version,
            properties, type);
    return artifact.setFile(original.getFile());
}

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());
    }/*ww w  .j  av  a  2 s  .  co 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;
}

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

License:Apache License

private static ArtifactType newArtifactType(String id, ArtifactHandler handler) {
    return new DefaultArtifactType(id, handler.getExtension(), handler.getClassifier(), handler.getLanguage(),
            handler.isAddedToClasspath(), handler.isIncludesDependencies());
}