Search in sources :

Example 6 with ArtifactDescriptorException

use of org.sonatype.aether.resolution.ArtifactDescriptorException 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

ArtifactDescriptorException (org.sonatype.aether.resolution.ArtifactDescriptorException)6 CollectResult (org.sonatype.aether.collection.CollectResult)4 Dependency (org.sonatype.aether.graph.Dependency)4 ArtifactDescriptorResult (org.sonatype.aether.resolution.ArtifactDescriptorResult)4 Test (org.junit.Test)3 CollectRequest (org.sonatype.aether.collection.CollectRequest)3 DependencyCollectionException (org.sonatype.aether.collection.DependencyCollectionException)3 DependencyNode (org.sonatype.aether.graph.DependencyNode)3 RemoteRepository (org.sonatype.aether.repository.RemoteRepository)3 ArtifactDescriptorRequest (org.sonatype.aether.resolution.ArtifactDescriptorRequest)3 ArrayList (java.util.ArrayList)2 Artifact (org.sonatype.aether.artifact.Artifact)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