-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#1008: improve upgrade settings #1146
base: main
Are you sure you want to change the base?
Changes from all commits
68623eb
ee0472a
9dcfdc1
f832220
49ef8ef
0dcb661
e37e0b4
c359522
2c30607
e8a9fc0
be644c6
255542a
9610ea9
2dfc249
6345aa9
ad54840
f890489
e17e2b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
package com.devonfw.tools.ide.commandlet; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.nio.file.StandardCopyOption; | ||
import java.nio.file.StandardOpenOption; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.function.Function; | ||
|
||
import com.devonfw.tools.ide.context.IdeContext; | ||
|
@@ -139,6 +144,7 @@ private void updateProperties(EnvironmentVariablesPropertiesFile environmentVari | |
} | ||
updatePropertiesLegacyEdition(environmentVariables, "INTELLIJ_EDITION_TYPE", "INTELLIJ_EDITION", this::mapLegacyIntellijEdition); | ||
updatePropertiesLegacyEdition(environmentVariables, "ECLIPSE_EDITION_TYPE", "ECLIPSE_EDITION", this::mapLegacyEclipseEdition); | ||
cleanupLegacyProperties(); | ||
environmentVariables.save(); | ||
this.context.getFileAccess().backup(environmentVariables.getLegacyPropertiesFilePath()); | ||
} | ||
|
@@ -181,4 +187,43 @@ private static void updatePropertiesLegacyEdition(EnvironmentVariablesProperties | |
environmentVariables.remove(legacyEditionVariable); | ||
} | ||
} | ||
|
||
private void cleanupLegacyProperties() { | ||
this.context.info("Cleaning up legacy properties..."); | ||
|
||
Path homeDirectory = this.config.getgetUserHome(); | ||
try { | ||
Files.walk(rootDirectory) | ||
.filter(path -> path.getFileName().toString().equals("IDEasy.properties")) | ||
.forEach(filePath -> { | ||
try { | ||
updateProperties(filePath); | ||
} catch (IOException e) { | ||
this.context.warning("Error processing IDEasy.properties at " + filePath); | ||
} | ||
}); | ||
} catch (IOException e) { | ||
this.context.warning("Error walking the file tree to find IDEasy.properties."); | ||
} | ||
} | ||
|
||
private void updateRepositoryPropertiesFile(Path filePath) throws IOException { | ||
List<String> lines = Files.readAllLines(filePath); | ||
List<String> updatedLines = new ArrayList<>(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI: You can do the modifications directly in the original list ( |
||
|
||
for (String line : lines) { | ||
if (line.startsWith("git.url=") || line.startsWith("git-url")) { | ||
String gitUrl = line.substring("git.url=".length()); | ||
updatedLines.add("git_url=" + gitUrl); | ||
continue; | ||
} | ||
if (line.startsWith("eclipse=import")) { | ||
updatedLines.add("import=eclipse"); | ||
hohwille marked this conversation as resolved.
Show resolved
Hide resolved
|
||
continue; | ||
} | ||
updatedLines.add(line); | ||
} | ||
Files.write(filePath, updatedLines, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you should add a boolean flag |
||
this.context.success("Successfully updated repository configuration file {}", filePath); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Obsolete but for the record. This filename
IDEasy.properties
is just an example and cannot be hardcoded.There can be any number of
*.properites
files in therepositories
folder and you cannot make any assumptions about their name.