use of org.eclipse.aether.internal.impl.DefaultLocalRepositoryProvider 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;
}
Aggregations