quarkus
quarkus copied to clipboard
cli test fails without settings.xml
Describe the bug
If no settings.xml is present in the maven user location, cli test will fail with 3 failures and 3 errors.
./mvnw -f devtools/cli test
...
[ERROR] Tests run: 79, Failures: 3, Errors: 3, Skipped: 0
Expected behavior
cli test should be able to run without settings.xml
Actual behavior
Fails without settings.xml
How to Reproduce?
Steps to reproduce the behavior:
- Ensure that no user settings.xml is defined
- Run
./mvnw -f devtools/cli test
Output of uname -a
or ver
Darwin mavenrunner-mac 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:19:52 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T6000 arm64
Output of java -version
openjdk version "17.0.2" 2022-01-18
GraalVM version (if different from Java)
No response
Quarkus version or git rev
e19f65e535
Build tool (ie. output of mvnw --version
or gradlew --version
)
Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Additional information
No response
/cc @ebullient, @maxandersen
cc @aloubyansky
[ERROR] Error executing Maven.
java.io.FileNotFoundException: The specified user settings file does not exist: /Users/mavenrunner/.m2/settings.xml
at org.apache.maven.cli.configuration.SettingsXmlConfigurationProcessor.process (SettingsXmlConfigurationProcessor.java:99)
at org.apache.maven.cli.MavenCli.configure (MavenCli.java:1169)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:568)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:568)
at org.apache.maven.wrapper.BootstrapMainStarter.start (BootstrapMainStarter.java:53)
at org.apache.maven.wrapper.WrapperExecutor.execute (WrapperExecutor.java:152)
at org.apache.maven.wrapper.MavenWrapperMain.main (MavenWrapperMain.java:76)
The relevant bits: Maven wrapper is invoking maven, which complains if it can't find a .m2 settings.xml
Maven does want one somewhere...https://maven.apache.org/settings.html
In this environment, is it unable to create one for that user (no write access to /Users/mavenrunner/)?
This sounds like something maven is trying/failing to do, not something Quarkus is attempting (we are invoking/wrapping maven in this case).
Actually, there are multiple issues regarding settings.xml here.
The first one is with this line https://github.com/quarkusio/quarkus/blob/782c6bae234b614257c9902a40af493778b0a381/devtools/cli/src/test/java/io/quarkus/cli/RegistryClientBuilderTestBase.java#L62 mavenContext.getUserSettings()
will return null and the call to toPath()
will cause a NullPointerException
as referred to line 148 of the attached maven log.
The second problem is with the parent pom.xml which will add maven.settings
property regardless if the file actually exist or not: https://github.com/quarkusio/quarkus/blob/782c6bae234b614257c9902a40af493778b0a381/build-parent/pom.xml#L445
The last problem is with the property cleanup, it ignores properties that were not present before and does not add them to the original properties map as null: https://github.com/quarkusio/quarkus/blob/782c6bae234b614257c9902a40af493778b0a381/devtools/cli/src/test/java/io/quarkus/cli/CliDriver.java#L112-L129 . If they were added as null, they would have been removed from the properties after the running quarkus.
Maven is trying to read the settings file only because it was added to maven properties maven.settings file. And maven rightfully fails because this file is not present. To fix this issue, we should avoid adding maven settings file if it does not exist.