Search in sources :

Example 26 with RepositorySystem

use of org.eclipse.aether.RepositorySystem in project spring-cloud-function by spring-cloud.

the class DependencyResolutionModule method initialize.

private void initialize() {
    if (this.container == null) {
        synchronized (lock) {
            if (this.container == null) {
                ClassWorld classWorld = new ClassWorld("plexus.core", Thread.currentThread().getContextClassLoader());
                ContainerConfiguration config = new DefaultContainerConfiguration().setClassWorld(classWorld).setRealm(classWorld.getClassRealm("plexus.core")).setClassPathScanning(PlexusConstants.SCANNING_INDEX).setAutoWiring(true).setName("maven");
                PlexusContainer container;
                try {
                    container = new DefaultPlexusContainer(config, new AetherModule(), new DependencyResolutionModule());
                    localRepositoryManagerFactory = container.lookup(LocalRepositoryManagerFactory.class);
                    container.addComponent(new ClassRealmManager((MutablePlexusContainer) container, new DefaultBeanLocator()), ClassRealmManager.class.getName());
                    projectBuilder = container.lookup(ProjectBuilder.class);
                    repositorySystem = container.lookup(RepositorySystem.class);
                } catch (Exception e) {
                    throw new IllegalStateException("Cannot create container", e);
                }
                this.container = container;
                this.settings = new MavenSettingsReader().readSettings();
            }
        }
    }
}
Also used : ClassRealmManager(org.eclipse.sisu.plexus.ClassRealmManager) DefaultPlexusContainer(org.codehaus.plexus.DefaultPlexusContainer) MutablePlexusContainer(org.codehaus.plexus.MutablePlexusContainer) PlexusContainer(org.codehaus.plexus.PlexusContainer) AetherModule(org.eclipse.aether.impl.guice.AetherModule) DefaultBeanLocator(org.eclipse.sisu.inject.DefaultBeanLocator) MutablePlexusContainer(org.codehaus.plexus.MutablePlexusContainer) ClassWorld(org.codehaus.plexus.classworlds.ClassWorld) ContainerConfiguration(org.codehaus.plexus.ContainerConfiguration) DefaultContainerConfiguration(org.codehaus.plexus.DefaultContainerConfiguration) ProjectBuildingException(org.apache.maven.project.ProjectBuildingException) NoLocalRepositoryManagerException(org.eclipse.aether.repository.NoLocalRepositoryManagerException) IOException(java.io.IOException) RepositorySystem(org.eclipse.aether.RepositorySystem) LocalRepositoryManagerFactory(org.eclipse.aether.spi.localrepo.LocalRepositoryManagerFactory) DefaultContainerConfiguration(org.codehaus.plexus.DefaultContainerConfiguration) DefaultPlexusContainer(org.codehaus.plexus.DefaultPlexusContainer) ProjectBuilder(org.apache.maven.project.ProjectBuilder)

Example 27 with RepositorySystem

use of org.eclipse.aether.RepositorySystem in project zeppelin by apache.

the class RepositorySystemFactory method newRepositorySystem.

public static RepositorySystem newRepositorySystem() {
    DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
    locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
    locator.addService(TransporterFactory.class, FileTransporterFactory.class);
    locator.addService(TransporterFactory.class, HttpTransporterFactory.class);
    locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() {

        @Override
        public void serviceCreationFailed(Class<?> type, Class<?> impl, Throwable exception) {
            exception.printStackTrace();
        }
    });
    RepositorySystem system = locator.getService(RepositorySystem.class);
    if (system == null) {
        throw new RuntimeException();
    }
    return system;
}
Also used : RepositorySystem(org.eclipse.aether.RepositorySystem) DefaultServiceLocator(org.eclipse.aether.impl.DefaultServiceLocator)

Aggregations

RepositorySystem (org.eclipse.aether.RepositorySystem)27 DefaultRepositorySystemSession (org.eclipse.aether.DefaultRepositorySystemSession)18 RepositorySystemSession (org.eclipse.aether.RepositorySystemSession)12 RemoteRepository (org.eclipse.aether.repository.RemoteRepository)9 Artifact (org.eclipse.aether.artifact.Artifact)8 DefaultArtifact (org.eclipse.aether.artifact.DefaultArtifact)8 ArtifactResult (org.eclipse.aether.resolution.ArtifactResult)7 DefaultServiceLocator (org.eclipse.aether.impl.DefaultServiceLocator)6 File (java.io.File)5 ArrayList (java.util.ArrayList)5 LocalRepository (org.eclipse.aether.repository.LocalRepository)5 ArtifactRequest (org.eclipse.aether.resolution.ArtifactRequest)4 IOException (java.io.IOException)3 CollectRequest (org.eclipse.aether.collection.CollectRequest)3 Dependency (org.eclipse.aether.graph.Dependency)3 ArtifactResolutionException (org.eclipse.aether.resolution.ArtifactResolutionException)3 DependencyRequest (org.eclipse.aether.resolution.DependencyRequest)3 URL (java.net.URL)2 Path (java.nio.file.Path)2 List (java.util.List)2