use of org.apache.maven.cli.internal.BootstrapCoreExtensionManager in project kie-wb-common by kiegroup.
the class AFMavenCli method loadCoreExtensions.
protected List<CoreExtensionEntry> loadCoreExtensions(AFCliRequest cliRequest, ClassRealm containerRealm, Set<String> providedArtifacts) {
if (cliRequest.getMultiModuleProjectDirectory() == null) {
return Collections.emptyList();
}
Path extensionsFile = Paths.get(cliRequest.getMultiModuleProjectDirectory().toString(), EXTENSIONS_FILENAME);
if (!java.nio.file.Files.isRegularFile(extensionsFile)) {
return Collections.emptyList();
}
try {
List<CoreExtension> extensions = readCoreExtensionsDescriptor(extensionsFile);
if (extensions.isEmpty()) {
return Collections.emptyList();
}
ContainerConfiguration cc = //
new DefaultContainerConfiguration().setClassWorld(//
cliRequest.getClassWorld()).setRealm(//
containerRealm).setClassPathScanning(//
PlexusConstants.SCANNING_INDEX).setAutoWiring(//
true).setName("maven");
DefaultPlexusContainer container = new DefaultPlexusContainer(cc, new AbstractModule() {
@Override
protected void configure() {
bind(ILoggerFactory.class).toInstance(slf4jLoggerFactory);
}
});
try {
container.setLookupRealm(null);
container.setLoggerManager(plexusLoggerManager);
container.getLoggerManager().setThresholds(cliRequest.getRequest().getLoggingLevel());
Thread.currentThread().setContextClassLoader(container.getContainerRealm());
executionRequestPopulator = container.lookup(MavenExecutionRequestPopulator.class);
configurationProcessors = container.lookupMap(AFConfigurationProcessor.class);
configure(cliRequest);
MavenExecutionRequest request = DefaultMavenExecutionRequest.copy(cliRequest.getRequest());
request = populateRequest(cliRequest, request);
request = executionRequestPopulator.populateDefaults(request);
BootstrapCoreExtensionManager resolver = container.lookup(BootstrapCoreExtensionManager.class);
return resolver.loadCoreExtensions(request, providedArtifacts, extensions);
} finally {
executionRequestPopulator = null;
container.dispose();
}
} catch (RuntimeException e) {
// runtime exceptions are most likely bugs in maven, let them bubble up to the user
throw e;
} catch (Exception e) {
slf4jLogger.warn("Failed to read extensions descriptor " + extensionsFile + ": " + e.getMessage());
}
return Collections.emptyList();
}
use of org.apache.maven.cli.internal.BootstrapCoreExtensionManager in project kie-wb-common by kiegroup.
the class AFMavenCli method loadCoreExtensions.
protected List<CoreExtensionEntry> loadCoreExtensions(AFCliRequest cliRequest, ClassRealm containerRealm, Set<String> providedArtifacts) {
if (cliRequest.getMultiModuleProjectDirectory() == null) {
return Collections.emptyList();
}
Path extensionsFile = Paths.get(cliRequest.getMultiModuleProjectDirectory().toString(), EXTENSIONS_FILENAME);
if (!java.nio.file.Files.isRegularFile(extensionsFile)) {
return Collections.emptyList();
}
try {
List<CoreExtension> extensions = readCoreExtensionsDescriptor(extensionsFile);
if (extensions.isEmpty()) {
return Collections.emptyList();
}
ContainerConfiguration cc = //
new DefaultContainerConfiguration().setClassWorld(//
cliRequest.getClassWorld()).setRealm(//
containerRealm).setClassPathScanning(//
PlexusConstants.SCANNING_INDEX).setAutoWiring(//
true).setName("maven");
DefaultPlexusContainer container = new DefaultPlexusContainer(cc, new AbstractModule() {
@Override
protected void configure() {
bind(ILoggerFactory.class).toInstance(slf4jLoggerFactory);
}
});
try {
container.setLookupRealm(null);
container.setLoggerManager(plexusLoggerManager);
container.getLoggerManager().setThresholds(cliRequest.getRequest().getLoggingLevel());
Thread.currentThread().setContextClassLoader(container.getContainerRealm());
executionRequestPopulator = container.lookup(MavenExecutionRequestPopulator.class);
configurationProcessors = container.lookupMap(AFConfigurationProcessor.class);
configure(cliRequest);
MavenExecutionRequest request = DefaultMavenExecutionRequest.copy(cliRequest.getRequest());
request = populateRequest(cliRequest, request);
request = executionRequestPopulator.populateDefaults(request);
BootstrapCoreExtensionManager resolver = container.lookup(BootstrapCoreExtensionManager.class);
return resolver.loadCoreExtensions(request, providedArtifacts, extensions);
} finally {
executionRequestPopulator = null;
container.dispose();
}
} catch (RuntimeException e) {
// runtime exceptions are most likely bugs in maven, let them bubble up to the user
throw e;
} catch (Exception e) {
slf4jLogger.warn("Failed to read extensions descriptor " + extensionsFile + ": " + e.getMessage());
}
return Collections.emptyList();
}
use of org.apache.maven.cli.internal.BootstrapCoreExtensionManager in project kie-wb-common by kiegroup.
the class ReusableAFMavenCli method loadCoreExtensions.
protected List<CoreExtensionEntry> loadCoreExtensions(AFCliRequest cliRequest, ClassRealm containerRealm, Set<String> providedArtifacts) {
if (cliRequest.getMultiModuleProjectDirectory() == null) {
return Collections.emptyList();
}
Path extensionsFile = Paths.get(cliRequest.getMultiModuleProjectDirectory().toString(), EXTENSIONS_FILENAME);
if (!java.nio.file.Files.isRegularFile(extensionsFile)) {
return Collections.emptyList();
}
try {
List<CoreExtension> extensions = readCoreExtensionsDescriptor(extensionsFile);
if (extensions.isEmpty()) {
return Collections.emptyList();
}
ContainerConfiguration cc = //
new DefaultContainerConfiguration().setClassWorld(//
cliRequest.getClassWorld()).setRealm(//
containerRealm).setClassPathScanning(//
PlexusConstants.SCANNING_INDEX).setAutoWiring(//
true).setName("maven");
if (reusableContainerCoreExtensions == null) {
reusableContainerCoreExtensions = new DefaultPlexusContainer(cc, new AbstractModule() {
@Override
protected void configure() {
bind(ILoggerFactory.class).toInstance(slf4jLoggerFactory);
}
});
}
try {
reusableContainerCoreExtensions.setLookupRealm(null);
((DefaultPlexusContainer) reusableContainerCoreExtensions).setLoggerManager(plexusLoggerManager);
((DefaultPlexusContainer) reusableContainerCoreExtensions).getLoggerManager().setThresholds(cliRequest.getRequest().getLoggingLevel());
Thread.currentThread().setContextClassLoader(reusableContainerCoreExtensions.getContainerRealm());
reusableExecutionRequestPopulator = reusableContainerCoreExtensions.lookup(MavenExecutionRequestPopulator.class);
reusableConfigurationProcessors = reusableContainerCoreExtensions.lookupMap(AFConfigurationProcessor.class);
configure(cliRequest);
MavenExecutionRequest request = DefaultMavenExecutionRequest.copy(cliRequest.getRequest());
request = populateRequest(cliRequest, request);
request = reusableExecutionRequestPopulator.populateDefaults(request);
BootstrapCoreExtensionManager resolver = reusableContainerCoreExtensions.lookup(BootstrapCoreExtensionManager.class);
reusableExtensions = resolver.loadCoreExtensions(request, providedArtifacts, extensions);
return reusableExtensions;
} finally {
reusableExecutionRequestPopulator = null;
}
} catch (RuntimeException e) {
// runtime exceptions are most likely bugs in maven, let them bubble up to the user
throw e;
} catch (Exception e) {
reusableSlf4jLogger.warn("Failed to read extensions descriptor " + extensionsFile + ": " + e.getMessage());
}
return Collections.emptyList();
}
Aggregations