maven-mvnd icon indicating copy to clipboard operation
maven-mvnd copied to clipboard

Maven Daemon doesn't download Core Extensions from pluginRepository defined in settings.xml

Open matteo-gallo-bb opened this issue 1 year ago • 1 comments

On a project that I'm working on, we need to use a patched version of a Maven Extension (specified with .mvn/extensions.xml) that is stored in an internal Maven repository. When using Maven we are able to download the Maven Extension from a pluginRepository specified in the settings.xml (we use --settings option to point to a project specific settings.xml). When using mvnd this doesn't work. From my investigation it seams that Maven Daemon doesn't resolve the settings.xml passed with --settings option when downloading Maven Core Extensions. In fact it tries to download it from central (https://repo.maven.apache.org/maven2). In our settings.xml we use a mirror of Maven central for both dependencies and plugins. This makes me think that mvnd doesn't use the specified settings.xml at early stage when it needs to resolve Maven Core Extensions defined in .mvn/extensions.xml.

We are using mvnd version 1.0.2.

Partial stacktrace:

java.lang.RuntimeException: Could not initialize org.mvndaemon.mvnd.daemon.Server
	at org.mvndaemon.mvnd.daemon.Server.<init>(Server.java:171)
	at org.mvndaemon.mvnd.daemon.Server.main(Server.java:103)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:292)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:208)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:361)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:314)
Caused by: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:74)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
	at org.mvndaemon.mvnd.daemon.Server.<init>(Server.java:136)
	... 7 more
Caused by: org.apache.maven.cli.internal.ExtensionResolutionException: Extension <omitted> or one of its dependencies could not be resolved: Plugin <omitted> or one of its dependencies could not be resolved:
	Could not find artifact <omitted> in central (https://repo.maven.apache.org/maven2)

	at org.apache.maven.cli.internal.BootstrapCoreExtensionManager.resolveExtension(BootstrapCoreExtensionManager.java:182)
	at org.apache.maven.cli.internal.BootstrapCoreExtensionManager.resolveCoreExtensions(BootstrapCoreExtensionManager.java:115)
	at org.apache.maven.cli.internal.BootstrapCoreExtensionManager.loadCoreExtensions(BootstrapCoreExtensionManager.java:99)
	at org.apache.maven.cli.DaemonMavenCli.loadCoreExtensions(DaemonMavenCli.java:765)
	at org.apache.maven.cli.DaemonMavenCli.container(DaemonMavenCli.java:668)
	at org.apache.maven.cli.DaemonMavenCli.<init>(DaemonMavenCli.java:205)
	at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
	... 10 more
Caused by: org.apache.maven.plugin.PluginResolutionException: Plugin <omitted> or one of its dependencies could not be resolved:
	Could not find artifact <omitted> in central (https://repo.maven.apache.org/maven2)

	at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolveInternal(DefaultPluginDependenciesResolver.java:234)
	at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolveCoreExtension(DefaultPluginDependenciesResolver.java:159)
	at org.apache.maven.cli.internal.BootstrapCoreExtensionManager.resolveExtension(BootstrapCoreExtensionManager.java:174)
	... 16 more
----- End of the daemon output -----

	at org.mvndaemon.mvnd.client.DaemonConnector.startDaemon(DaemonConnector.java:330)
	at org.mvndaemon.mvnd.client.DaemonConnector.connect(DaemonConnector.java:123)
	at org.mvndaemon.mvnd.client.DefaultClient.execute(DefaultClient.java:353)
	at org.mvndaemon.mvnd.client.DefaultClient.main(DefaultClient.java:171)
	at [email protected]/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)

matteo-gallo-bb avatar Oct 17 '24 18:10 matteo-gallo-bb

Is there ANY chance to try your build by current master of mvnd (build master of maven then master of mvnd)? I understand it is Maven 4, not Maven 3 as in 1.0.2, but still...

cstamas avatar Oct 17 '24 19:10 cstamas

I am facing the same issue with mvnd 1.0.2 that uses Maven 3.9.9 AFAIK.

Mobe91 avatar Jul 31 '25 10:07 Mobe91

The workaround that I found working is to modify user.home using -Dmvnd.jvmArgs=-Duser.home=/some/dir and then create /some/dir/settings.xml. mvnd will then use this settings.xml to resolve extensions.

Mobe91 avatar Jul 31 '25 11:07 Mobe91

~I can confirm this, mvnd creates container "early", way too early (and as side effects loads configured extesions), but settings are not YET available and hence not applied.~ More precisely: user arguments and options, like -s mysettings.xml are not yet available.

cstamas avatar Sep 09 '25 09:09 cstamas