Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,12 @@ protected void settings(C context) throws Exception {
* If there are Maven3 passwords presents in settings, this results in doubled warnings emitted. So Plexus DI
* creation call keeps "emitSettingsWarnings" false. If there are fatal issues, it will anyway "die" at that
* spot before warnings would be emitted.
* <p>
* The method returns a "cleaner" runnable, as during extension loading the context needs to be "cleaned", restored
* to previous state (as it was before extension loading).
*/
protected void settings(C context, boolean emitSettingsWarnings, SettingsBuilder settingsBuilder) throws Exception {
protected Runnable settings(C context, boolean emitSettingsWarnings, SettingsBuilder settingsBuilder)
throws Exception {
Options mavenOptions = context.invokerRequest.options();

Path userSettingsFile = null;
Expand Down Expand Up @@ -612,6 +616,14 @@ protected void settings(C context, boolean emitSettingsWarnings, SettingsBuilder
}
context.logger.info("");
}
return () -> {
context.installationSettingsPath = null;
context.projectSettingsPath = null;
context.userSettingsPath = null;
context.effectiveSettings = null;
context.interactive = true;
context.localRepositoryPath = null;
};
}

protected void customizeSettingsRequest(C context, SettingsBuilderRequest settingsBuilderRequest)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,14 @@ protected void configure() {
});

ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
Runnable settingsCleaner = null;
try {
container.setLookupRealm(null);
container.setLoggerManager(createLoggerManager());
container.getLoggerManager().setThresholds(toPlexusLoggingLevel(context.loggerLevel));
Thread.currentThread().setContextClassLoader(container.getContainerRealm());

invoker.settings(context, false, container.lookup(SettingsBuilder.class));
settingsCleaner = invoker.settings(context, false, container.lookup(SettingsBuilder.class));

MavenExecutionRequest mer = new DefaultMavenExecutionRequest();
invoker.populateRequest(context, new DefaultLookup(container), mer);
Expand All @@ -288,6 +289,9 @@ protected void configure() {
.lookup(BootstrapCoreExtensionManager.class)
.loadCoreExtensions(mer, providedArtifacts, extensions));
} finally {
if (settingsCleaner != null) {
settingsCleaner.run();
}
try {
container.dispose();
} finally {
Expand Down
Loading