Skip to content

Commit 0882bb6

Browse files
authored
[1.20.4] [All] Exception when removing duplicates modules on windows (#25)
* handle windows filepaths correctly * sanitize the file separators on the BaseFileAccess * fix: paths converted to system path * removed changes on unused files * removed intellij indentation
1 parent b79d342 commit 0882bb6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/runtime/java/dev/architectury/transformer/TransformerRuntime.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,10 @@ private static void removeDuplicates(List<String> cpList, List<Map.Entry<Path, P
227227
Set<String> modules = new HashSet<>();
228228
og.handle(path -> {
229229
if (path.endsWith(".class")) {
230+
String sanitized = path.replace(File.separatorChar, '/');
231+
230232
// Get package name, i.e. "dev/architectury/transformer/TransformerRuntime.class" -> "dev.architectury.transformer"
231-
String packageName = Transform.trimLeadingSlash(path).substring(0, Transform.trimLeadingSlash(path).lastIndexOf('/')).replace('/', '.');
233+
String packageName = Transform.trimLeadingSlash(sanitized).substring(0, Transform.trimLeadingSlash(sanitized).lastIndexOf('/')).replace('/', '.');
232234
modules.add(packageName);
233235
}
234236
});
@@ -244,7 +246,7 @@ private static void removeDuplicates(List<String> cpList, List<Map.Entry<Path, P
244246
try (OpenedFileAccess ac = OpenedFileAccess.ofDirectory(cpPath)) {
245247
Set<String> modules = new HashSet<>();
246248
ac.handle(path -> {
247-
String relative = Transform.trimLeadingSlash(cpPath.relativize(Paths.get(path)).toString());
249+
String relative = Transform.trimLeadingSlash(cpPath.relativize(Paths.get(path)).toString().replace(File.separatorChar, '/'));
248250
if (relative.endsWith(".class")) {
249251
// Get package name, i.e. "dev/architectury/transformer/TransformerRuntime.class" -> "dev.architectury.transformer"
250252
String packageName = relative.substring(0, relative.lastIndexOf('/')).replace('/', '.');

0 commit comments

Comments
 (0)