Search in sources :

Example 1 with LocalRepositoryManagerFactory

use of org.eclipse.aether.spi.localrepo.LocalRepositoryManagerFactory in project intellij-plugins by JetBrains.

the class GeneratorServer method createPlexusContainer.

private static DefaultPlexusContainer createPlexusContainer() throws PlexusContainerException, ComponentLookupException {
    ContainerConfiguration containerConfiguration = new DefaultContainerConfiguration().setClassPathScanning(PlexusConstants.SCANNING_INDEX).setAutoWiring(true).setClassWorld(new ClassWorld("plexus.core", Thread.currentThread().getContextClassLoader())).setName("maven");
    final DefaultPlexusContainer container = new DefaultPlexusContainer(containerConfiguration);
    final List<LocalRepositoryManagerFactory> factoryList = Collections.singletonList(container.lookup(LocalRepositoryManagerFactory.class, "simple"));
    final String mavenVersion = container.lookup(RuntimeInformation.class).getMavenVersion();
    // tracked impl is not suitable for us (our list of remote repo may be not equals - we don't want think about it)
    if (mavenVersion.length() >= 5 && mavenVersion.charAt(2) == '0' && mavenVersion.charAt(4) < '4') {
        final DefaultRepositorySystem repositorySystem = (DefaultRepositorySystem) container.lookup(RepositorySystem.class);
        try {
            repositorySystem.getClass().getMethod("setLocalRepositoryManagerFactories", List.class).invoke(repositorySystem, factoryList);
        } catch (Exception e) {
            container.getLoggerManager().getLoggerForComponent(null).warn("", e);
        }
    } else {
        ((DefaultLocalRepositoryProvider) container.lookup(LocalRepositoryProvider.class)).setLocalRepositoryManagerFactories(factoryList);
    }
    return container;
}
Also used : DefaultLocalRepositoryProvider(org.eclipse.aether.internal.impl.DefaultLocalRepositoryProvider) DefaultRepositorySystem(org.eclipse.aether.internal.impl.DefaultRepositorySystem) ClassWorld(org.codehaus.plexus.classworlds.ClassWorld) SettingsBuildingException(org.apache.maven.settings.building.SettingsBuildingException) ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException) InvalidRepositoryException(org.apache.maven.artifact.InvalidRepositoryException) IOException(java.io.IOException) DefaultRepositorySystem(org.eclipse.aether.internal.impl.DefaultRepositorySystem) RepositorySystem(org.apache.maven.repository.RepositorySystem) LocalRepositoryManagerFactory(org.eclipse.aether.spi.localrepo.LocalRepositoryManagerFactory) DefaultLocalRepositoryProvider(org.eclipse.aether.internal.impl.DefaultLocalRepositoryProvider) LocalRepositoryProvider(org.eclipse.aether.impl.LocalRepositoryProvider) RuntimeInformation(org.apache.maven.rtinfo.RuntimeInformation)

Aggregations

IOException (java.io.IOException)1 InvalidRepositoryException (org.apache.maven.artifact.InvalidRepositoryException)1 RepositorySystem (org.apache.maven.repository.RepositorySystem)1 RuntimeInformation (org.apache.maven.rtinfo.RuntimeInformation)1 SettingsBuildingException (org.apache.maven.settings.building.SettingsBuildingException)1 ClassWorld (org.codehaus.plexus.classworlds.ClassWorld)1 ComponentLookupException (org.codehaus.plexus.component.repository.exception.ComponentLookupException)1 LocalRepositoryProvider (org.eclipse.aether.impl.LocalRepositoryProvider)1 DefaultLocalRepositoryProvider (org.eclipse.aether.internal.impl.DefaultLocalRepositoryProvider)1 DefaultRepositorySystem (org.eclipse.aether.internal.impl.DefaultRepositorySystem)1 LocalRepositoryManagerFactory (org.eclipse.aether.spi.localrepo.LocalRepositoryManagerFactory)1