From 1505bbf7acf3608ec98b1747506102880a2d2d9a Mon Sep 17 00:00:00 2001 From: KianRolf Date: Mon, 28 Oct 2024 18:07:23 +0100 Subject: [PATCH] #704: fix settings-security.xml not found (#705) --- .../com/devonfw/tools/ide/context/IdeContext.java | 8 +------- .../java/com/devonfw/tools/ide/tool/mvn/Mvn.java | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 7 deletions(-) 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 c86b68818..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,6 +163,7 @@ private String getEncryptedPassword(String variable) { ProcessContext pc = this.context.newProcess().executable("mvn"); pc.addArgs("--encrypt-password", input); + pc.addArg(getDsettingsSecurityProperty()); ProcessResult result = pc.run(ProcessMode.DEFAULT_CAPTURE); String encryptedPassword = result.getOut().get(0); @@ -240,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("\\", "\\\\"); + } }