Skip to content

Commit

Permalink
devonfw#704: Separation of concerns
Browse files Browse the repository at this point in the history
  • Loading branch information
KianRolf committed Oct 28, 2024
1 parent bfc6cd8 commit 4689838
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 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
16 changes: 15 additions & 1 deletion 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,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);
Expand Down Expand Up @@ -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("\\", "\\\\");
}
}

0 comments on commit 4689838

Please sign in to comment.