Fix core export provider (#764)

* Fix core export provider

Since https://github.com/apache/maven/pull/616, the default
CoreExportProvider no longer uses the provided CoreExports,
but instead tries (and fails) to discover them itself.

This change fixes that by providing our own custom instance
of CoreExportProvider. This allows core extension to contribute
exported artifacts and exported packages again, like it used to
do before the Maven 4.x upgrade.

* Add integration tests for API-providing extensions
This commit is contained in:
Stefan Oehme
2023-01-17 11:18:22 +01:00
committed by GitHub
parent f3c336adb9
commit 74df4b6b53
13 changed files with 385 additions and 0 deletions

View File

@@ -64,6 +64,7 @@ import org.apache.maven.exception.ExceptionSummary;
import org.apache.maven.execution.*;
import org.apache.maven.execution.scope.internal.MojoExecutionScopeModule;
import org.apache.maven.extension.internal.CoreExports;
import org.apache.maven.extension.internal.CoreExportsProvider;
import org.apache.maven.extension.internal.CoreExtensionEntry;
import org.apache.maven.lifecycle.LifecycleExecutionException;
import org.apache.maven.model.building.ModelProcessor;
@@ -518,6 +519,7 @@ public class DaemonMavenCli {
protected void configure() {
bind(ILoggerFactory.class).toInstance(slf4jLoggerFactory);
bind(CoreExports.class).toInstance(exports);
bind(CoreExportsProvider.class).toInstance(new CoreExportsProvider(exports));
bind(ExtensionRealmCache.class).to(InvalidatingExtensionRealmCache.class);
bind(PluginArtifactsCache.class).to(InvalidatingPluginArtifactsCache.class);
bind(PluginRealmCache.class).to(InvalidatingPluginRealmCache.class);