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 user Maven config dir resolution in native mode #23972

Merged
merged 1 commit into from
Feb 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ public class BootstrapMavenContext {
private static final String MAVEN_TOP_LEVEL_PROJECT_BASEDIR = "maven.top-level-basedir";
private static final String SETTINGS_XML = "settings.xml";

private static final String userHome = PropertyUtils.getUserHome();
private static final File userMavenConfigurationHome = new File(userHome, ".m2");

private static final String EFFECTIVE_MODEL_BUILDER_PROP = "quarkus.bootstrap.effective-model-builder";

private boolean artifactTransferLogging;
Expand Down Expand Up @@ -211,12 +208,16 @@ public File getUserSettings() {
getCliOptions().getOptionValue(BootstrapMavenOptions.ALTERNATE_USER_SETTINGS),
() -> {
final String quarkusMavenSettings = getProperty(MAVEN_SETTINGS);
return quarkusMavenSettings == null ? new File(userMavenConfigurationHome, SETTINGS_XML)
return quarkusMavenSettings == null ? new File(getUserMavenConfigurationHome(), SETTINGS_XML)
: new File(quarkusMavenSettings);
})
: userSettings;
}

private static File getUserMavenConfigurationHome() {
return new File(PropertyUtils.getUserHome(), ".m2");
}

private String getProperty(String name) {
String value = PropertyUtils.getProperty(name);
if (value != null) {
Expand Down Expand Up @@ -326,7 +327,7 @@ private String resolveLocalRepo(Settings settings) {
return localRepo;
}
localRepo = settings.getLocalRepository();
return localRepo == null ? new File(userMavenConfigurationHome, "repository").getAbsolutePath() : localRepo;
return localRepo == null ? new File(getUserMavenConfigurationHome(), "repository").getAbsolutePath() : localRepo;
}

private File resolveSettingsFile(String settingsArg, Supplier<File> supplier) {
Expand Down