use of org.eclipse.aether.repository.LocalArtifactRequest 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;
}
use of org.eclipse.aether.repository.LocalArtifactRequest in project revapi by revapi.
the class ArtifactResolver method makeRemoteOnly.
private RepositorySystemSession makeRemoteOnly(RepositorySystemSession session) {
return new AbstractForwardingRepositorySystemSession() {
@Override
protected RepositorySystemSession getSession() {
return session;
}
@Override
public WorkspaceReader getWorkspaceReader() {
return null;
}
@Override
public LocalRepositoryManager getLocalRepositoryManager() {
LocalRepositoryManager wrapped = session.getLocalRepositoryManager();
return new LocalRepositoryManager() {
@Override
public LocalRepository getRepository() {
return wrapped.getRepository();
}
@Override
public String getPathForLocalArtifact(Artifact artifact) {
return wrapped.getPathForLocalArtifact(artifact);
}
@Override
public String getPathForRemoteArtifact(Artifact artifact, RemoteRepository repository, String context) {
return wrapped.getPathForRemoteArtifact(artifact, repository, context);
}
@Override
public String getPathForLocalMetadata(Metadata metadata) {
return wrapped.getPathForLocalMetadata(metadata);
}
@Override
public String getPathForRemoteMetadata(Metadata metadata, RemoteRepository repository, String context) {
return wrapped.getPathForRemoteMetadata(metadata, repository, context);
}
@Override
public LocalArtifactResult find(RepositorySystemSession session, LocalArtifactRequest request) {
return wrapped.find(session, request);
}
@Override
public void add(RepositorySystemSession session, LocalArtifactRegistration request) {
wrapped.add(session, request);
}
@Override
public LocalMetadataResult find(RepositorySystemSession session, LocalMetadataRequest request) {
if (request.getRepository() == null) {
// local metadata request... the returned file must not be null but may not exist
// we exploit that to not include the locally built results
LocalMetadataResult ret = new LocalMetadataResult(request);
ret.setFile(new File("<faked-to-force-remote-only-resolution-of-artifacts>"));
return ret;
} else {
return wrapped.find(session, request);
}
}
@Override
public void add(RepositorySystemSession session, LocalMetadataRegistration request) {
wrapped.add(session, request);
}
};
}
};
}
Aggregations