use of org.eclipse.aether.AbstractForwardingRepositorySystemSession 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