Skip to content

Commit

Permalink
#704: fix settings-security.xml not found (#705)
Browse files Browse the repository at this point in the history
  • Loading branch information
KianRolf authored Oct 28, 2024
1 parent 9d54ecc commit 1505bbf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down
15 changes: 15 additions & 0 deletions cli/src/main/java/com/devonfw/tools/ide/tool/mvn/Mvn.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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("\\", "\\\\");
}
}

0 comments on commit 1505bbf

Please sign in to comment.