Search in sources :

Example 6 with LocalRepository

use of org.eclipse.aether.repository.LocalRepository in project pinpoint by naver.

the class DependencyResolver method newRepositorySystemSession.

private static DefaultRepositorySystemSession newRepositorySystemSession(RepositorySystem system) {
    DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
    String localRepositoryPath = resolveLocalRepository();
    logger.info("Local repository: " + localRepositoryPath);
    LocalRepository localRepository = new LocalRepository(localRepositoryPath);
    session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepository));
    return session;
}
Also used : DefaultRepositorySystemSession(org.eclipse.aether.DefaultRepositorySystemSession) LocalRepository(org.eclipse.aether.repository.LocalRepository)

Example 7 with LocalRepository

use of org.eclipse.aether.repository.LocalRepository in project spring-boot by spring-projects.

the class DefaultRepositorySystemSessionAutoConfiguration method apply.

@Override
public void apply(DefaultRepositorySystemSession session, RepositorySystem repositorySystem) {
    if (session.getLocalRepositoryManager() == null) {
        LocalRepository localRepository = new LocalRepository(getM2RepoDirectory());
        LocalRepositoryManager localRepositoryManager = repositorySystem.newLocalRepositoryManager(session, localRepository);
        session.setLocalRepositoryManager(localRepositoryManager);
    }
    ProxySelector existing = session.getProxySelector();
    if (existing == null || !(existing instanceof CompositeProxySelector)) {
        JreProxySelector fallback = new JreProxySelector();
        ProxySelector selector = existing == null ? fallback : new CompositeProxySelector(Arrays.asList(existing, fallback));
        session.setProxySelector(selector);
    }
}
Also used : ProxySelector(org.eclipse.aether.repository.ProxySelector) JreProxySelector(org.eclipse.aether.util.repository.JreProxySelector) LocalRepositoryManager(org.eclipse.aether.repository.LocalRepositoryManager) LocalRepository(org.eclipse.aether.repository.LocalRepository) JreProxySelector(org.eclipse.aether.util.repository.JreProxySelector)

Example 8 with LocalRepository

use of org.eclipse.aether.repository.LocalRepository in project spring-boot by spring-projects.

the class GrapeRootRepositorySystemSessionAutoConfiguration method configureLocalRepository.

private void configureLocalRepository(DefaultRepositorySystemSession session, RepositorySystem repositorySystem, String grapeRoot) {
    File repositoryDir = new File(grapeRoot, "repository");
    LocalRepository localRepository = new LocalRepository(repositoryDir);
    LocalRepositoryManager localRepositoryManager = repositorySystem.newLocalRepositoryManager(session, localRepository);
    session.setLocalRepositoryManager(localRepositoryManager);
}
Also used : LocalRepositoryManager(org.eclipse.aether.repository.LocalRepositoryManager) LocalRepository(org.eclipse.aether.repository.LocalRepository) File(java.io.File)

Example 9 with LocalRepository

use of org.eclipse.aether.repository.LocalRepository in project bnd by bndtools.

the class AetherRepository method init.

protected final synchronized void init() throws Exception {
    if (initialised)
        return;
    // Initialise Aether
    DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
    locator.addService(ArtifactDescriptorReader.class, DefaultArtifactDescriptorReader.class);
    locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
    locator.addService(TransporterFactory.class, FileTransporterFactory.class);
    locator.addService(TransporterFactory.class, HttpTransporterFactory.class);
    locator.setErrorHandler(new ErrorHandler() {

        @Override
        public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception) {
            if (reporter != null)
                reporter.error("Service creation failed for type %s using impl %s: %s", type, impl, exception.getLocalizedMessage());
            exception.printStackTrace();
        }
    });
    repoSystem = locator.getService(RepositorySystem.class);
    if (repoSystem == null)
        throw new IllegalArgumentException("Failed to initialise Aether repository system");
    Builder builder = new RemoteRepository.Builder("remote", "default", mainUri.toString());
    if (username != null) {
        AuthenticationBuilder authBuilder = new AuthenticationBuilder().addUsername(username);
        if (password != null)
            authBuilder.addPassword(password);
        builder.setAuthentication(authBuilder.build());
    }
    remoteRepo = builder.build();
    localRepo = new LocalRepository(new File(cacheDir, "aether-local"));
    // Initialise Index
    if (indexUri == null) {
        indexedRepo = null;
    } else {
        // Test whether the index URI exists and is available.
        HttpURLConnection connection = (HttpURLConnection) indexUri.toURL().openConnection();
        try {
            connection.setRequestMethod("HEAD");
            int responseCode = connection.getResponseCode();
            if (responseCode >= 400) {
                indexedRepo = null;
            } else {
                indexedRepo = new FixedIndexedRepo();
                Map<String, String> config = new HashMap<String, String>();
                indexedRepo.setReporter(this.reporter);
                indexedRepo.setRegistry(registry);
                config.put(FixedIndexedRepo.PROP_CACHE, cacheDir.getAbsolutePath());
                config.put(FixedIndexedRepo.PROP_LOCATIONS, indexUri.toString());
                indexedRepo.setProperties(config);
            }
        } catch (UnknownHostException e) {
            return;
        } finally {
            connection.disconnect();
        }
    }
    initialised = true;
}
Also used : ErrorHandler(org.eclipse.aether.impl.DefaultServiceLocator.ErrorHandler) AuthenticationBuilder(org.eclipse.aether.util.repository.AuthenticationBuilder) UnknownHostException(java.net.UnknownHostException) HashMap(java.util.HashMap) AuthenticationBuilder(org.eclipse.aether.util.repository.AuthenticationBuilder) Builder(org.eclipse.aether.repository.RemoteRepository.Builder) LocalRepository(org.eclipse.aether.repository.LocalRepository) DefaultServiceLocator(org.eclipse.aether.impl.DefaultServiceLocator) RepositorySystem(org.eclipse.aether.RepositorySystem) HttpURLConnection(java.net.HttpURLConnection) File(java.io.File) FixedIndexedRepo(aQute.bnd.deployer.repository.FixedIndexedRepo)

Aggregations

LocalRepository (org.eclipse.aether.repository.LocalRepository)9 DefaultRepositorySystemSession (org.eclipse.aether.DefaultRepositorySystemSession)5 File (java.io.File)3 RepositorySystem (org.eclipse.aether.RepositorySystem)3 LocalRepositoryManager (org.eclipse.aether.repository.LocalRepositoryManager)3 DefaultServiceLocator (org.eclipse.aether.impl.DefaultServiceLocator)2 RemoteRepository (org.eclipse.aether.repository.RemoteRepository)2 FixedIndexedRepo (aQute.bnd.deployer.repository.FixedIndexedRepo)1 HttpURLConnection (java.net.HttpURLConnection)1 URL (java.net.URL)1 UnknownHostException (java.net.UnknownHostException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 AbstractRepositoryListener (org.eclipse.aether.AbstractRepositoryListener)1 Artifact (org.eclipse.aether.artifact.Artifact)1 DefaultArtifact (org.eclipse.aether.artifact.DefaultArtifact)1 CollectRequest (org.eclipse.aether.collection.CollectRequest)1 DeployRequest (org.eclipse.aether.deployment.DeployRequest)1 Dependency (org.eclipse.aether.graph.Dependency)1