Search in sources :

Example 6 with ArtifactDescriptorResult

use of org.sonatype.aether.resolution.ArtifactDescriptorResult in project sonatype-aether by sonatype.

the class IniArtifactDescriptorReader method readArtifactDescriptor.

/**
 * Parses the resource <code>$prefix/gid_aid_ext_ver.ini</code> from the request artifact as an artifact description
 * and wraps it into an ArtifactDescriptorResult.
 */
public ArtifactDescriptorResult readArtifactDescriptor(RepositorySystemSession session, ArtifactDescriptorRequest request) throws ArtifactDescriptorException {
    Artifact artifact = request.getArtifact();
    String resourceName = String.format("%s_%s_%s_%s.ini", artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getExtension());
    ArtifactDescriptorResult result = new ArtifactDescriptorResult(request);
    result.setArtifact(artifact);
    try {
        ArtifactDescription data = reader.parse(resourceName);
        result.setDependencies(data.getDependencies());
        result.setManagedDependencies(data.getManagedDependencies());
        result.setRepositories(data.getRepositories());
        result.setRelocations(data.getRelocations());
        return result;
    } catch (Exception e) {
        throw new ArtifactDescriptorException(result, e.getMessage());
    }
}
Also used : ArtifactDescriptorResult(org.sonatype.aether.resolution.ArtifactDescriptorResult) ArtifactDescriptorException(org.sonatype.aether.resolution.ArtifactDescriptorException) Artifact(org.sonatype.aether.artifact.Artifact) ArtifactDescriptorException(org.sonatype.aether.resolution.ArtifactDescriptorException)

Aggregations

ArtifactDescriptorResult (org.sonatype.aether.resolution.ArtifactDescriptorResult)6 RemoteRepository (org.sonatype.aether.repository.RemoteRepository)5 ArtifactDescriptorRequest (org.sonatype.aether.resolution.ArtifactDescriptorRequest)5 Artifact (org.sonatype.aether.artifact.Artifact)4 Dependency (org.sonatype.aether.graph.Dependency)4 ArtifactDescriptorException (org.sonatype.aether.resolution.ArtifactDescriptorException)4 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 RepositorySystemSession (org.sonatype.aether.RepositorySystemSession)2 CollectResult (org.sonatype.aether.collection.CollectResult)2 DependencyManager (org.sonatype.aether.collection.DependencyManager)2 DependencySelector (org.sonatype.aether.collection.DependencySelector)2 DependencyTraverser (org.sonatype.aether.collection.DependencyTraverser)2 VersionRangeRequest (org.sonatype.aether.resolution.VersionRangeRequest)2 VersionRangeResolutionException (org.sonatype.aether.resolution.VersionRangeResolutionException)2 VersionRangeResult (org.sonatype.aether.resolution.VersionRangeResult)2 Version (org.sonatype.aether.version.Version)2 List (java.util.List)1 RepositoryException (org.sonatype.aether.RepositoryException)1 RepositorySystem (org.sonatype.aether.RepositorySystem)1