Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli test fails without settings.xml #28090

Closed
AdlerFleurant opened this issue Sep 20, 2022 · 4 comments · Fixed by #28141
Closed

cli test fails without settings.xml #28090

AdlerFleurant opened this issue Sep 20, 2022 · 4 comments · Fixed by #28141
Labels
area/cli Related to quarkus cli (not maven/gradle/etc.) kind/bug Something isn't working
Milestone

Comments

@AdlerFleurant
Copy link
Contributor

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

Full Maven Log

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:

  1. Ensure that no user settings.xml is defined
  2. 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

e19f65e

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)

Additional information

No response

@AdlerFleurant AdlerFleurant added the kind/bug Something isn't working label Sep 20, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Sep 20, 2022

/cc @ebullient, @maxandersen

@quarkus-bot quarkus-bot bot added the area/cli Related to quarkus cli (not maven/gradle/etc.) label Sep 20, 2022
@geoand
Copy link
Contributor

geoand commented Sep 20, 2022

cc @aloubyansky

@ebullient
Copy link
Member

[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).

@AdlerFleurant
Copy link
Contributor Author

Actually, there are multiple issues regarding settings.xml here.

The first one is with this line

final Settings settings = getBaseMavenSettings(mavenContext.getUserSettings().toPath());
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:

<maven.settings>${session.request.userSettingsFile.path}</maven.settings>

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:

protected Map<String, String> collectOverridenProps(List<String> newArgs) {
final Map<String, String> originalProps = new HashMap<>();
for (String s : newArgs) {
if (s.startsWith("-D")) {
int equals = s.indexOf('=', 2);
if (equals > 0) {
final String propName = s.substring(2, equals);
final String origValue = System.getProperty(propName);
if (origValue != null) {
originalProps.put(propName, origValue);
} else if (System.getProperties().contains(propName)) {
originalProps.put(propName, "true");
}
}
}
}
return originalProps;
}
. 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.

AdlerFleurant added a commit to AdlerFleurant/quarkus that referenced this issue Sep 21, 2022
Null check on mavenSettings.
Do not pass non-existent maven settings file to surefire and failsafe plugin.
Fix nearby typos and deprecated API usage.

Fixes quarkusio#28090
AdlerFleurant added a commit to AdlerFleurant/quarkus that referenced this issue Sep 21, 2022
Null check on mavenSettings.
Do not pass non-existent maven settings file to surefire and failsafe plugin.
Fix nearby typos and deprecated API usage.

Fixes quarkusio#28090
AdlerFleurant added a commit to AdlerFleurant/quarkus that referenced this issue Sep 21, 2022
Null check on mavenSettings.
Do not pass non-existent maven settings file to surefire and failsafe plugin.
Fix nearby typos and deprecated API usage.
Use ci settings.xml full path.

Fixes quarkusio#28090
AdlerFleurant added a commit to AdlerFleurant/quarkus that referenced this issue Sep 21, 2022
Null check on mavenSettings.
Do not pass non-existent maven settings file to surefire and failsafe plugin.
Fix nearby typos and deprecated API usage.
Use ci settings.xml full path.

Fixes quarkusio#28090
AdlerFleurant added a commit to AdlerFleurant/quarkus that referenced this issue Sep 22, 2022
Null check on mavenSettings.
Do not pass non-existent maven settings file to surefire and failsafe plugin.
Fix nearby typos and deprecated API usage.
Use ci settings.xml full path.

Fixes quarkusio#28090
AdlerFleurant added a commit to AdlerFleurant/quarkus that referenced this issue Sep 22, 2022
Null check on mavenSettings.
Do not pass non-existent maven settings file to surefire and failsafe plugin.
Fix nearby typos, deprecated API usage and perform code cleanup.
Use ci settings.xml full path.

Fixes quarkusio#28090

Signed-off-by: Adler Fleurant <[email protected]>
AdlerFleurant added a commit to AdlerFleurant/quarkus that referenced this issue Sep 22, 2022
Null check on mavenSettings.
Do not pass non-existent maven settings file to surefire and failsafe plugin.
Fix nearby typos.
Use ci settings.xml full path for test that uses settings parameter.

Fixes quarkusio#28090

Signed-off-by: Adler Fleurant <[email protected]>
AdlerFleurant added a commit to AdlerFleurant/quarkus that referenced this issue Sep 23, 2022
Check if maven settings file exist if coming from system properties.
Null check on mavenSettings.
Fix nearby typos.

Fixes quarkusio#28090

Signed-off-by: Adler Fleurant <[email protected]>
AdlerFleurant added a commit to AdlerFleurant/quarkus that referenced this issue Sep 23, 2022
Check if maven settings file exists when getting from system properties.
Null check on mavenSettings.
Fix nearby typos.

Fixes quarkusio#28090

Signed-off-by: Adler Fleurant <[email protected]>
gsmet pushed a commit to AdlerFleurant/quarkus that referenced this issue Sep 28, 2022
Check if maven settings file exists when getting from system properties.
Null check on mavenSettings.
Fix nearby typos.

Fixes quarkusio#28090

Signed-off-by: Adler Fleurant <[email protected]>
@quarkus-bot quarkus-bot bot added this to the 2.14 - main milestone Sep 30, 2022
@gsmet gsmet modified the milestones: 2.14 - main, 2.13.1.Final Sep 30, 2022
gsmet pushed a commit to gsmet/quarkus that referenced this issue Oct 3, 2022
Check if maven settings file exists when getting from system properties.
Null check on mavenSettings.
Fix nearby typos.

Fixes quarkusio#28090

Signed-off-by: Adler Fleurant <[email protected]>
(cherry picked from commit 2b0923f)
igorregis pushed a commit to igorregis/quarkus that referenced this issue Oct 16, 2022
Check if maven settings file exists when getting from system properties.
Null check on mavenSettings.
Fix nearby typos.

Fixes quarkusio#28090

Signed-off-by: Adler Fleurant <[email protected]>
igorregis pushed a commit to igorregis/quarkus that referenced this issue Oct 16, 2022
Check if maven settings file exists when getting from system properties.
Null check on mavenSettings.
Fix nearby typos.

Fixes quarkusio#28090

Signed-off-by: Adler Fleurant <[email protected]>
igorregis pushed a commit to igorregis/quarkus that referenced this issue Oct 16, 2022
Check if maven settings file exists when getting from system properties.
Null check on mavenSettings.
Fix nearby typos.

Fixes quarkusio#28090

Signed-off-by: Adler Fleurant <[email protected]>
igorregis pushed a commit to igorregis/quarkus that referenced this issue Oct 17, 2022
Check if maven settings file exists when getting from system properties.
Null check on mavenSettings.
Fix nearby typos.

Fixes quarkusio#28090

Signed-off-by: Adler Fleurant <[email protected]>
tmihalac pushed a commit to tmihalac/quarkus that referenced this issue Oct 27, 2022
Check if maven settings file exists when getting from system properties.
Null check on mavenSettings.
Fix nearby typos.

Fixes quarkusio#28090

Signed-off-by: Adler Fleurant <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cli Related to quarkus cli (not maven/gradle/etc.) kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants