Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix handling Windows reference paths in workspace mechanice files
  • Loading branch information
funfried committed Aug 15, 2023
1 parent 9a25976 commit ac83651
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ public static Map<String, String> readPropertiesFromConfiguration(String path, S

@NonNull
private static List<Properties> parseAdditionalFiles(String pathStruct) throws IOException {
System.out.println("PATH STRUCT: " + pathStruct);

// the pathStruct looks as follows:
// ["/path/to/additional/mechanic/files","/path/to/origin/mechanic/file"]
pathStruct = StringUtils.trimToEmpty(pathStruct);
Expand All @@ -62,8 +60,6 @@ private static List<Properties> parseAdditionalFiles(String pathStruct) throws I
List<Properties> result = new ArrayList<>();
String[] additionalFilesPaths = StringUtils.split(pathStruct, ",");
for (String additionalFilesPath : additionalFilesPaths) {
System.out.println("ADDITIONAL FILES PATH: " + additionalFilesPath);

additionalFilesPath = StringUtils.removeStart(additionalFilesPath, "\"");
additionalFilesPath = StringUtils.removeEnd(additionalFilesPath, "\"");

Expand All @@ -76,6 +72,17 @@ private static List<Properties> parseAdditionalFiles(String pathStruct) throws I

@NonNull
private static Properties createPropertiesFromPath(String path) throws IOException {
if (StringUtils.isBlank(path)) {
return new Properties();
}

if (StringUtils.contains(path, "\\")) {
// normalize path if it already has double backslashes
StringUtils.replace(path, "\\\\", "\\");
// ensure double backslashes
StringUtils.replace(path, "\\", "\\\\");
}

if (UrlValidator.getInstance().isValid(path)) {
try {
URL url = new URL(path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@ public void testProxyEpfFile() throws Exception {
/instance/org.eclipse.jdt.core/sp_cleanup.on_save_use_additional_actions=true""");
}

System.out.println("EPF FILE: " + epfFile.getAbsolutePath());
System.out.println("EPF PROXY FOLDER: " + EPF_PROXY_FOLDER.getRoot().getAbsolutePath());
System.out.println("EPF IMPORT FILE: " + epfImportFile.getAbsolutePath());
System.out.println("EPF SAVE ACTIONS FILE: " + epfSaveActionsFile.getAbsolutePath());

Map<String, String> props = WorkspaceMechanicConfigParser.readPropertiesFromConfiguration(epfFile.getAbsolutePath(), PREFIX);

Assert.assertEquals(5, props.size());
Expand Down

0 comments on commit ac83651

Please sign in to comment.