diff --git a/cli/src/main/java/com/devonfw/tools/ide/commandlet/UpdateSettingsCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/commandlet/UpdateSettingsCommandlet.java index 12bc81ec0..c7840ec12 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/commandlet/UpdateSettingsCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/commandlet/UpdateSettingsCommandlet.java @@ -179,8 +179,13 @@ public void replaceIdeVariables() { Files.walk(workspaceDir) .filter(Files::isRegularFile) // Filter for regular files .forEach(file -> { - // Process each found file - processFileForVariableReplacement(file, legacyToNewMapping); + if (file.getFileName().toString().equals("replacement-patterns.properties")) { + handleReplacementPatternsFile(file); // This deletes the file if not empty + } + if (Files.exists(file)) { + // Process each found file + processFileForVariableReplacement(file, legacyToNewMapping); + } }); } catch (IOException e) { this.context.error("Error while processing files in workspace: " + workspaceDir, e); @@ -222,4 +227,26 @@ private void processFileForVariableReplacement(Path file, Map le this.context.error("Error processing file: {}, exception: {}", file, e); } } + + private void handleReplacementPatternsFile(Path file) { + // If the file matches 'replacement-patterns.properties' + if (Files.exists(file) && Files.isRegularFile(file)) { + try { + // Read the file content + String content = Files.readString(file); + + if (!content.trim().isEmpty()) { + // Log a warning if the file is not empty + this.context.warning("The file 'replacement-patterns.properties' is not empty: " + file); + } + + // Delete the file after processing + Files.delete(file); + this.context.success("Deleted 'replacement-patterns.properties' from: " + file); + } catch (IOException e) { + // Handle any exceptions during reading or deleting the file + this.context.error("Error processing 'replacement-patterns.properties' file: " + file, e); + } + } + } }