Skip to content

Commit

Permalink
Merge pull request quarkusio#23972 from aloubyansky/non-static-user-home
Browse files Browse the repository at this point in the history
Fix user Maven config dir resolution in native mode
  • Loading branch information
aloubyansky authored Feb 25, 2022
2 parents 89b8b84 + 4cf44ca commit d14c12e
Showing 1 changed file with 6 additions and 5 deletions.
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

0 comments on commit d14c12e

Please sign in to comment.