Search in sources :

Example 1 with LocalMetadataResult

use of org.eclipse.aether.repository.LocalMetadataResult 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);
                }
            };
        }
    };
}
Also used : AbstractForwardingRepositorySystemSession(org.eclipse.aether.AbstractForwardingRepositorySystemSession) RepositorySystemSession(org.eclipse.aether.RepositorySystemSession) LocalArtifactRegistration(org.eclipse.aether.repository.LocalArtifactRegistration) LocalMetadataRequest(org.eclipse.aether.repository.LocalMetadataRequest) LocalMetadataRegistration(org.eclipse.aether.repository.LocalMetadataRegistration) Metadata(org.eclipse.aether.metadata.Metadata) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) Artifact(org.eclipse.aether.artifact.Artifact) LocalRepositoryManager(org.eclipse.aether.repository.LocalRepositoryManager) LocalMetadataResult(org.eclipse.aether.repository.LocalMetadataResult) AbstractForwardingRepositorySystemSession(org.eclipse.aether.AbstractForwardingRepositorySystemSession) File(java.io.File) LocalArtifactRequest(org.eclipse.aether.repository.LocalArtifactRequest)

Aggregations

File (java.io.File)1 AbstractForwardingRepositorySystemSession (org.eclipse.aether.AbstractForwardingRepositorySystemSession)1 RepositorySystemSession (org.eclipse.aether.RepositorySystemSession)1 Artifact (org.eclipse.aether.artifact.Artifact)1 DefaultArtifact (org.eclipse.aether.artifact.DefaultArtifact)1 Metadata (org.eclipse.aether.metadata.Metadata)1 LocalArtifactRegistration (org.eclipse.aether.repository.LocalArtifactRegistration)1 LocalArtifactRequest (org.eclipse.aether.repository.LocalArtifactRequest)1 LocalMetadataRegistration (org.eclipse.aether.repository.LocalMetadataRegistration)1 LocalMetadataRequest (org.eclipse.aether.repository.LocalMetadataRequest)1 LocalMetadataResult (org.eclipse.aether.repository.LocalMetadataResult)1 LocalRepositoryManager (org.eclipse.aether.repository.LocalRepositoryManager)1 RemoteRepository (org.eclipse.aether.repository.RemoteRepository)1