Search in sources :

Example 1 with LocalArtifactResult

use of org.eclipse.aether.repository.LocalArtifactResult in project wildfly-swarm by wildfly-swarm.

the class MavenArtifactResolvingHelper method resolve.

@Override
public ArtifactSpec resolve(ArtifactSpec spec) {
    if (spec.file == null) {
        final DefaultArtifact artifact = new DefaultArtifact(spec.groupId(), spec.artifactId(), spec.classifier(), spec.type(), spec.version());
        final LocalArtifactResult localResult = this.session.getLocalRepositoryManager().find(this.session, new LocalArtifactRequest(artifact, this.remoteRepositories, null));
        if (localResult.isAvailable()) {
            spec.file = localResult.getFile();
        } else {
            try {
                final ArtifactResult result = resolver.resolveArtifact(this.session, new ArtifactRequest(artifact, this.remoteRepositories, null));
                if (result.isResolved()) {
                    spec.file = result.getArtifact().getFile();
                }
            } catch (ArtifactResolutionException e) {
                e.printStackTrace();
            }
        }
    }
    return spec.file != null ? spec : null;
}
Also used : ArtifactResolutionException(org.eclipse.aether.resolution.ArtifactResolutionException) LocalArtifactRequest(org.eclipse.aether.repository.LocalArtifactRequest) ArtifactRequest(org.eclipse.aether.resolution.ArtifactRequest) LocalArtifactResult(org.eclipse.aether.repository.LocalArtifactResult) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) LocalArtifactRequest(org.eclipse.aether.repository.LocalArtifactRequest) LocalArtifactResult(org.eclipse.aether.repository.LocalArtifactResult) ArtifactResult(org.eclipse.aether.resolution.ArtifactResult)

Aggregations

DefaultArtifact (org.eclipse.aether.artifact.DefaultArtifact)1 LocalArtifactRequest (org.eclipse.aether.repository.LocalArtifactRequest)1 LocalArtifactResult (org.eclipse.aether.repository.LocalArtifactResult)1 ArtifactRequest (org.eclipse.aether.resolution.ArtifactRequest)1 ArtifactResolutionException (org.eclipse.aether.resolution.ArtifactResolutionException)1 ArtifactResult (org.eclipse.aether.resolution.ArtifactResult)1