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

Fix bug with mavenSettings in WrapperRunner while running tests locally #21890

Merged
merged 1 commit into from
Dec 3, 2021

Conversation

ia3andy
Copy link
Contributor

@ia3andy ia3andy commented Dec 2, 2021

[ERROR] Error executing Maven.
[ERROR] The specified user settings file does not exist: /Users/ia3andy/.m2/settings.xml

@ia3andy ia3andy requested a review from aloubyansky December 2, 2021 15:06
@quarkus-bot quarkus-bot bot added area/devtools Issues/PR related to maven, gradle, platform and cli tooling/plugins area/platform Issues related to definition and interaction with Quarkus Platform labels Dec 2, 2021
@gastaldi
Copy link
Contributor

gastaldi commented Dec 2, 2021

The current behavior is the same as Maven's, so I'm -1 to this change

@aloubyansky
Copy link
Member

What kind of use-case is this fixing?

@aloubyansky
Copy link
Member

I suppose there could be a relative path evaluation that could go wrong. But just to clarify.

@gastaldi
Copy link
Contributor

gastaldi commented Dec 2, 2021

I suppose there could be a relative path evaluation that could go wrong. But just to clarify.

IMHO if the -s flag was explicitly set to a non-existent file it should fail, so it would give the dev a hint of what's wrong. Silently ignoring it in this case is bad.

@aloubyansky
Copy link
Member

aloubyansky commented Dec 2, 2021

If it's a relative path though, it could be resolved correctly against the current project but not the one it is passed to. So, perhaps, here we should be making sure we are always propagating an absolute path. But again it would be good to clarify what issue Andy ran into.

@ia3andy
Copy link
Contributor Author

ia3andy commented Dec 2, 2021

maven is working fine locally without this file.. this bug was introduced when we started reading maven.settings in WrapperRunner.

@ia3andy
Copy link
Contributor Author

ia3andy commented Dec 2, 2021

@gastaldi I don't think we should propagate the -s with a non existing file.

@ia3andy
Copy link
Contributor Author

ia3andy commented Dec 2, 2021

Here is when it started: #21673

@gastaldi
Copy link
Contributor

gastaldi commented Dec 2, 2021

I think the question is if the -s is explicitly set in the original command.

@ia3andy
Copy link
Contributor Author

ia3andy commented Dec 2, 2021

@gastaldi no it's using the properties, I am not setting it manually.

@gastaldi
Copy link
Contributor

gastaldi commented Dec 2, 2021

@gastaldi I don't think we should propagate the -s with a non existing file.

We should propagate what's been set in the original command. If it's an invalid path, that's the user's fault, the error should not be swallowed

@gastaldi
Copy link
Contributor

gastaldi commented Dec 2, 2021

So I guess the fix is to make sure that getMavenSettingsArg() returns a value ONLY if it's set. Checking if the file exists here is bad because it may lead to unexpected behavior when the command executes succesfully with a non-existent path

@ia3andy
Copy link
Contributor Author

ia3andy commented Dec 2, 2021

So I guess the fix is to make sure that getMavenSettingsArg() returns a value ONLY if it's set. Checking if the file exists here is bad because it may lead to unexpected behavior when the command executes succesfully with a non-existent pathII

I don't think we can can know if -s is set or not.

Maven is failing only when explicitly using -s with a non existent file. Here this is propagation, we shouldn't propagate something which makes the runner fail.

So maybe it's not the best solution, but it's better than the current code..

@ia3andy
Copy link
Contributor Author

ia3andy commented Dec 2, 2021

@gastaldi if you have a better solution to not propagate -s when you should not, let me know

@gastaldi
Copy link
Contributor

gastaldi commented Dec 2, 2021

Maven is failing only when explicitly using -s with a non existent file. Here this is propagation, we shouldn't propagate something which makes the runner fail.

It's okay to fail if the parameters are wrong, I think the bug is that -s is specified here but not in the original command

@aloubyansky
Copy link
Member

We check whether maven.settings is set first. If it is we can check whether it's a valid path. If it's not, we should return null.
If maven.settings isn't set we can check whether -s was provided. If it was we should propagate it as an absolute path.

@aloubyansky
Copy link
Member

We should always propagate it with -s because maven.settings is a Quarkus only property.

@ia3andy ia3andy force-pushed the fix-bug-wrapper-runner branch from 35c030a to 6eb683c Compare December 2, 2021 16:24
@ia3andy ia3andy force-pushed the fix-bug-wrapper-runner branch from 6eb683c to 49dd31b Compare December 2, 2021 16:53
@ia3andy ia3andy requested a review from gastaldi December 2, 2021 16:53
@@ -105,7 +107,7 @@ public static int run(Path projectDir, Wrapper wrapper) {
private static String getMavenSettingsArg() {
final String mavenSettings = System.getProperty("maven.settings");
if (mavenSettings != null) {
return mavenSettings;
return Files.exists(Paths.get(mavenSettings)) ? mavenSettings : null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nitpick: use Path.of instead :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's a shortcut you are right. I think we can live with it :)

@@ -105,7 +107,7 @@ public static int run(Path projectDir, Wrapper wrapper) {
private static String getMavenSettingsArg() {
final String mavenSettings = System.getProperty("maven.settings");
if (mavenSettings != null) {
return mavenSettings;
return Files.exists(Paths.get(mavenSettings)) ? mavenSettings : null;
}
return BootstrapMavenOptions.newInstance().getOptionValue(BootstrapMavenOptions.ALTERNATE_USER_SETTINGS);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW shouldn't we make this result an absolute path?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's worth making sure the ALTERNATE_USER_SETTINGS is an absolute path.

@quarkus-bot
Copy link

quarkus-bot bot commented Dec 2, 2021

Failing Jobs - Building 49dd31b

Status Name Step Failures Logs Raw logs
Gradle Tests - JDK 11 Windows Build Failures Logs Raw logs

Full information is available in the Build summary check run.

Failures

⚙️ Gradle Tests - JDK 11 Windows #

- Failing: integration-tests/gradle 

📦 integration-tests/gradle

io.quarkus.gradle.devmode.QuarkusDevDependencyDevModeTest.main line 14 - More details - Source on GitHub

org.awaitility.core.ConditionTimeoutException: Condition with lambda expression in io.quarkus.test.devmode.util.DevModeTestUtils that uses java.util.function.Supplier, java.util.function.Supplierjava.util.concurrent.atomic.AtomicReference, java.util.concurrent.atomic.AtomicReferencejava.lang.String, java.lang.Stringboolean was not fulfilled within 1 minutes.
	at org.awaitility.core.ConditionAwaiter.await(ConditionAwaiter.java:164)
	at org.awaitility.core.CallableCondition.await(CallableCondition.java:78)

@ia3andy
Copy link
Contributor Author

ia3andy commented Dec 3, 2021

Error seems unrelated. @aloubyansky should we merge?

@aloubyansky aloubyansky merged commit 0c752d9 into quarkusio:main Dec 3, 2021
@quarkus-bot quarkus-bot bot added this to the 2.6 - main milestone Dec 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/devtools Issues/PR related to maven, gradle, platform and cli tooling/plugins area/platform Issues related to definition and interaction with Quarkus Platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants