Search in sources :

Example 1 with DefaultServiceLocator

use of org.eclipse.aether.impl.DefaultServiceLocator in project spring-boot by spring-projects.

the class AetherGrapeEngineFactory method createServiceLocator.

private static ServiceLocator createServiceLocator() {
    DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
    locator.addService(RepositorySystem.class, DefaultRepositorySystem.class);
    locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
    locator.addService(TransporterFactory.class, HttpTransporterFactory.class);
    locator.addService(TransporterFactory.class, FileTransporterFactory.class);
    return locator;
}
Also used : DefaultServiceLocator(org.eclipse.aether.impl.DefaultServiceLocator)

Example 2 with DefaultServiceLocator

use of org.eclipse.aether.impl.DefaultServiceLocator in project spring-boot by spring-projects.

the class ModifiedClassPathRunner method resolveCoordinates.

private List<URL> resolveCoordinates(String[] coordinates) throws Exception {
    DefaultServiceLocator serviceLocator = MavenRepositorySystemUtils.newServiceLocator();
    serviceLocator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
    serviceLocator.addService(TransporterFactory.class, HttpTransporterFactory.class);
    RepositorySystem repositorySystem = serviceLocator.getService(RepositorySystem.class);
    DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
    LocalRepository localRepository = new LocalRepository(System.getProperty("user.home") + "/.m2/repository");
    session.setLocalRepositoryManager(repositorySystem.newLocalRepositoryManager(session, localRepository));
    CollectRequest collectRequest = new CollectRequest(null, Arrays.asList(new RemoteRepository.Builder("central", "default", "http://central.maven.org/maven2").build()));
    collectRequest.setDependencies(createDependencies(coordinates));
    DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, null);
    DependencyResult result = repositorySystem.resolveDependencies(session, dependencyRequest);
    List<URL> resolvedArtifacts = new ArrayList<URL>();
    for (ArtifactResult artifact : result.getArtifactResults()) {
        resolvedArtifacts.add(artifact.getArtifact().getFile().toURI().toURL());
    }
    return resolvedArtifacts;
}
Also used : DependencyResult(org.eclipse.aether.resolution.DependencyResult) LocalRepository(org.eclipse.aether.repository.LocalRepository) ArrayList(java.util.ArrayList) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) DefaultServiceLocator(org.eclipse.aether.impl.DefaultServiceLocator) CollectRequest(org.eclipse.aether.collection.CollectRequest) URL(java.net.URL) ArtifactResult(org.eclipse.aether.resolution.ArtifactResult) RepositorySystem(org.eclipse.aether.RepositorySystem) DefaultRepositorySystemSession(org.eclipse.aether.DefaultRepositorySystemSession) DependencyRequest(org.eclipse.aether.resolution.DependencyRequest)

Example 3 with DefaultServiceLocator

use of org.eclipse.aether.impl.DefaultServiceLocator in project camel by apache.

the class BOMResolver method newRepositorySystem.

private RepositorySystem newRepositorySystem() {
    DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
    locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
    locator.addService(TransporterFactory.class, FileTransporterFactory.class);
    locator.addService(TransporterFactory.class, HttpTransporterFactory.class);
    RepositorySystem system = locator.getService(RepositorySystem.class);
    return system;
}
Also used : RepositorySystem(org.eclipse.aether.RepositorySystem) DefaultServiceLocator(org.eclipse.aether.impl.DefaultServiceLocator)

Example 4 with DefaultServiceLocator

use of org.eclipse.aether.impl.DefaultServiceLocator in project bazel by bazelbuild.

the class MavenConnector method newRepositorySystem.

public RepositorySystem newRepositorySystem() {
    DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
    locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
    locator.addService(TransporterFactory.class, FileTransporterFactory.class);
    locator.addService(TransporterFactory.class, HttpTransporterFactory.class);
    return locator.getService(RepositorySystem.class);
}
Also used : DefaultServiceLocator(org.eclipse.aether.impl.DefaultServiceLocator)

Example 5 with DefaultServiceLocator

use of org.eclipse.aether.impl.DefaultServiceLocator in project buck by facebook.

the class AetherUtil method initServiceLocator.

public static ServiceLocator initServiceLocator() {
    DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
    locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() {

        @Override
        public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception) {
            throw new RuntimeException(String.format("Failed to initialize service %s, implemented by %s: %s", type.getName(), impl.getName(), exception.getMessage()), exception);
        }
    });
    locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
    locator.addService(TransporterFactory.class, HttpTransporterFactory.class);
    locator.addService(TransporterFactory.class, FileTransporterFactory.class);
    // Use a no-op logger. Leaving this out would introduce a runtime dependency on log4j
    locator.addService(ILoggerFactory.class, NOPLoggerFactory.class);
    //    locator.addService(ILoggerFactory.class, Log4jLoggerFactory.class);
    return locator;
}
Also used : DefaultServiceLocator(org.eclipse.aether.impl.DefaultServiceLocator)

Aggregations

DefaultServiceLocator (org.eclipse.aether.impl.DefaultServiceLocator)7 RepositorySystem (org.eclipse.aether.RepositorySystem)3 LocalRepository (org.eclipse.aether.repository.LocalRepository)2 FixedIndexedRepo (aQute.bnd.deployer.repository.FixedIndexedRepo)1 File (java.io.File)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 DefaultRepositorySystemSession (org.eclipse.aether.DefaultRepositorySystemSession)1 CollectRequest (org.eclipse.aether.collection.CollectRequest)1 ErrorHandler (org.eclipse.aether.impl.DefaultServiceLocator.ErrorHandler)1 RemoteRepository (org.eclipse.aether.repository.RemoteRepository)1 Builder (org.eclipse.aether.repository.RemoteRepository.Builder)1 ArtifactResult (org.eclipse.aether.resolution.ArtifactResult)1 DependencyRequest (org.eclipse.aether.resolution.DependencyRequest)1 DependencyResult (org.eclipse.aether.resolution.DependencyResult)1 AuthenticationBuilder (org.eclipse.aether.util.repository.AuthenticationBuilder)1