diff --git a/cli/src/main/java/com/devonfw/tools/ide/context/IdeContext.java b/cli/src/main/java/com/devonfw/tools/ide/context/IdeContext.java index b0c527c4e..077398198 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/context/IdeContext.java +++ b/cli/src/main/java/com/devonfw/tools/ide/context/IdeContext.java @@ -432,13 +432,7 @@ default String getMavenArgs() { return null; } Mvn mvn = getCommandletManager().getCommandlet(Mvn.class); - Path mavenConfFolder = mvn.getMavenConfFolder(false); - Path mvnSettingsFile = mavenConfFolder.resolve(Mvn.SETTINGS_FILE); - if (!Files.exists(mvnSettingsFile)) { - return null; - } - String settingsPath = mvnSettingsFile.toString(); - return "-s " + settingsPath; + return mvn.getMavenArgs(); } /** diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/mvn/Mvn.java b/cli/src/main/java/com/devonfw/tools/ide/tool/mvn/Mvn.java index ba0aac130..d700d3978 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/tool/mvn/Mvn.java +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/mvn/Mvn.java @@ -163,7 +163,7 @@ private String getEncryptedPassword(String variable) { ProcessContext pc = this.context.newProcess().executable("mvn"); pc.addArgs("--encrypt-password", input); - pc.addArg("-Dsettings.security=" + this.context.getMavenRepository().getParent().resolve(SETTINGS_SECURITY_FILE).toString().replace("\\", "\\\\")); + pc.addArg(getDsettingsSecurityProperty()); ProcessResult result = pc.run(ProcessMode.DEFAULT_CAPTURE); String encryptedPassword = result.getOut().get(0); @@ -241,4 +241,18 @@ public Path getMavenConfFolder(boolean legacy) { } return mvnConfigFolder; } + + public String getMavenArgs() { + Path mavenConfFolder = getMavenConfFolder(false); + Path mvnSettingsFile = mavenConfFolder.resolve(Mvn.SETTINGS_FILE); + if (!Files.exists(mvnSettingsFile)) { + return null; + } + String settingsPath = mvnSettingsFile.toString(); + return "-s " + settingsPath + getDsettingsSecurityProperty(); + } + + private String getDsettingsSecurityProperty() { + return "-Dsettings.security=" + this.context.getMavenRepository().getParent().resolve(SETTINGS_SECURITY_FILE).toString().replace("\\", "\\\\"); + } }