Java Code Examples for org.eclipse.aether.artifact.Artifact#getClassifier()

The following examples show how to use org.eclipse.aether.artifact.Artifact#getClassifier() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArtifactIdUtils.java    From pinpoint with Apache License 2.0 6 votes vote down vote up
public static String artifactToString(Artifact artifact) {
    StringBuilder result = new StringBuilder();

    String groupId = artifact.getGroupId();
    result.append(groupId).append(ARTIFACT_DELIMITER);

    String artifactId = artifact.getArtifactId();
    result.append(artifactId).append(ARTIFACT_DELIMITER);

    String version = artifact.getVersion();
    result.append(version);

    if (StringUtils.hasText(artifact.getClassifier())) {
        String classifier = artifact.getClassifier();
        result.append(ARTIFACT_DELIMITER).append(classifier);
    }


    return result.toString();
}
 
Example 2
Source File: BootstrapAppModelResolver.java    From quarkus with Apache License 2.0 5 votes vote down vote up
private static AppArtifact toAppArtifact(Artifact artifact) {
    final AppArtifact appArtifact = new AppArtifact(artifact.getGroupId(), artifact.getArtifactId(),
            artifact.getClassifier(), artifact.getExtension(), artifact.getVersion());
    final File file = artifact.getFile();
    if (file != null) {
        appArtifact.setPaths(PathsCollection.of(file.toPath()));
    }
    return appArtifact;
}
 
Example 3
Source File: MavenUtils.java    From syndesis with Apache License 2.0 5 votes vote down vote up
static String toGav(final Artifact artifact) {
    // <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>
    return artifact.getGroupId()
        + ":" + artifact.getArtifactId()
        + (artifact.getExtension() == null ? "" : ":" + artifact.getExtension())
        + (artifact.getClassifier() == null ? "" : ":" + artifact.getClassifier())
        + ":" + artifact.getVersion();
}
 
Example 4
Source File: AetherImporter.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
private static Map<MetaKey, String> makeMetaData ( final Artifact artifact )
{
    final Map<MetaKey, String> md = new HashMap<> ();

    md.put ( new MetaKey ( "mvn", "groupId" ), artifact.getGroupId () );
    md.put ( new MetaKey ( "mvn", "artifactId" ), artifact.getArtifactId () );
    md.put ( new MetaKey ( "mvn", "version" ), artifact.getVersion () );
    md.put ( new MetaKey ( "mvn", "extension" ), artifact.getExtension () );
    if ( artifact.getClassifier () != null )
    {
        md.put ( new MetaKey ( "mvn", "classifier" ), artifact.getClassifier () );
    }

    return md;
}
 
Example 5
Source File: AetherImporter.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
private static DefaultArtifact makeOtherClassifier ( final Artifact main, final String classifier )
{
    if ( main.getClassifier () != null && !main.getClassifier ().isEmpty () )
    {
        // we only change main artifacts
        return null;
    }

    return new DefaultArtifact ( main.getGroupId (), main.getArtifactId (), classifier, main.getExtension (), main.getVersion () );
}
 
Example 6
Source File: AetherImporter.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
private static DefaultArtifact makeOtherExtension ( final Artifact main, final String extension )
{
    if ( main.getClassifier () != null && !main.getClassifier ().isEmpty () )
    {
        // we only change main artifacts
        return null;
    }

    return new DefaultArtifact ( main.getGroupId (), main.getArtifactId (), null, extension, main.getVersion () );
}
 
Example 7
Source File: StackResolution.java    From vertx-stack with Apache License 2.0 5 votes vote down vote up
private String getManagementKey(Artifact artifact) {
  return artifact.getGroupId()
    + ":" + artifact.getArtifactId()
    + ":" + artifact.getExtension()
    + (artifact.getClassifier() != null && artifact.getClassifier().length() > 0
    ? ":" + artifact.getClassifier() : "");
}
 
Example 8
Source File: Resolver.java    From buck with Apache License 2.0 5 votes vote down vote up
/** Construct a key to identify the artifact, less its version */
private String buildKey(Artifact artifact) {
  return artifact.getGroupId()
      + ':'
      + artifact.getArtifactId()
      + ':'
      + artifact.getExtension()
      + ':'
      + artifact.getClassifier();
}
 
Example 9
Source File: MavenArtifactResolver.java    From quarkus with Apache License 2.0 4 votes vote down vote up
private static AppArtifactKey getId(Artifact a) {
    return new AppArtifactKey(a.getGroupId(), a.getArtifactId(), a.getClassifier(), a.getExtension());
}
 
Example 10
Source File: BootstrapAppModelResolver.java    From quarkus with Apache License 2.0 4 votes vote down vote up
private AppArtifactKey getKey(final Artifact artifact) {
    return new AppArtifactKey(artifact.getGroupId(), artifact.getArtifactId(),
            artifact.getClassifier(), artifact.getExtension());
}
 
Example 11
Source File: IDEWorkspaceReader2.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public File findArtifact(Artifact artifact) {
    return super.findArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getBaseVersion(), artifact.getExtension(), artifact.getClassifier());
}
 
Example 12
Source File: NbArtifactFixer.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public @Override File resolve(Artifact artifact) {
    if (!artifact.getExtension().equals(NbMavenProject.TYPE_POM)) {
        return null;
    }
    if (!artifact.getClassifier().isEmpty()) {
        return null;
    }
    ArtifactRepository local = EmbedderFactory.getProjectEmbedder().getLocalRepository();
    if (local.getLayout() != null) { // #189807: for unknown reasons, there is no layout when running inside MavenCommandLineExecutor.run
        
        //the special snapshot handling is important in case of SNAPSHOT or x-SNAPSHOT versions, for some reason aether has slightly different
        //handling of baseversion compared to maven artifact. we need to manually set the baseversion here..
        boolean isSnapshot = artifact.isSnapshot();
        DefaultArtifact art = new DefaultArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), null, artifact.getExtension(), artifact.getClassifier(), new DefaultArtifactHandler(artifact.getExtension()));
        if (isSnapshot) {
            art.setBaseVersion(artifact.getBaseVersion());
        }
        String path = local.pathOf(art);
        if (new File(local.getBasedir(), path).exists()) {
            return null; // for now, we prefer the repository version when available
        }
    }
    //#234586
    Set<String> gavSet = gav.get();
    if (gavSet == null) {
        gavSet = new HashSet<String>();
        gav.set(gavSet);
    }
    String id = artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion();

    if (!gavSet.contains(id)) {
        try {
            gavSet.add(id); //#234586
            File pom = MavenFileOwnerQueryImpl.getInstance().getOwnerPOM(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion());
            if (pom != null) {
                //instead of workarounds down the road, we set the artifact's file here.
                // some stacktraces to maven/aether do set it after querying our code, but some don't for reasons unknown to me.
                artifact.setFile(pom);
                return pom;
            }
        } finally {
            gavSet.remove(id); //#234586
            if (gavSet.isEmpty()) {
                gav.remove();
            }
        }
    } else {
        LOG.log(Level.INFO, "Cycle in NbArtifactFixer resolution (issue #234586): {0}", Arrays.toString(gavSet.toArray()));
    }
    
    try {
        File f = createFallbackPOM(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion());
        //instead of workarounds down the road, we set the artifact's file here.
        // some stacktraces to maven/aether do set it after querying our code, but some don't for reasons unknown to me.
        artifact.setFile(f);
        return f;
    } catch (IOException x) {
        Exceptions.printStackTrace(x);
        return null;
    }
}
 
Example 13
Source File: DependencyResolutionResultHandler.java    From pipeline-maven-plugin with MIT License 4 votes vote down vote up
@Override
protected boolean _handle(DependencyResolutionResult result) {

    Xpp3Dom root = new Xpp3Dom("DependencyResolutionResult");
    root.setAttribute("class", result.getClass().getName());

    Xpp3Dom dependenciesElt = new Xpp3Dom("resolvedDependencies");
    root.addChild(dependenciesElt);

    for (Dependency dependency : result.getResolvedDependencies()) {
        Artifact artifact = dependency.getArtifact();

        if ( !includedScopes.contains(dependency.getScope())) {
            continue;
        }
        if (!includeSnapshots && artifact.isSnapshot()) {
            continue;
        }
        if(!includeReleases && !artifact.isSnapshot()) {
            continue;
        }

        Xpp3Dom dependencyElt = new Xpp3Dom("dependency");

        dependencyElt.addChild(newElement("file", artifact.getFile().getAbsolutePath()));

        dependencyElt.setAttribute("name", artifact.getFile().getName());

        dependencyElt.setAttribute("groupId", artifact.getGroupId());
        dependencyElt.setAttribute("artifactId", artifact.getArtifactId());
        dependencyElt.setAttribute("version", artifact.getVersion());
        dependencyElt.setAttribute("baseVersion", artifact.getBaseVersion());
        if (artifact.getClassifier() != null) {
            dependencyElt.setAttribute("classifier", artifact.getClassifier());
        }
        dependencyElt.setAttribute("type", artifact.getExtension());
        dependencyElt.setAttribute("id", artifact.getArtifactId());
        dependencyElt.setAttribute("extension", artifact.getExtension());
        dependencyElt.setAttribute("scope", dependency.getScope());
        dependencyElt.setAttribute("optional", Boolean.toString(dependency.isOptional()));
        dependencyElt.setAttribute("snapshot", Boolean.toString(artifact.isSnapshot()));

        dependenciesElt.addChild(dependencyElt);
    }

    reporter.print(root);
    return true;
}