diff --git a/src/main/java/net/fabricmc/loom/util/SourceRemapper.java b/src/main/java/net/fabricmc/loom/util/SourceRemapper.java index 5a9e486..67d05c8 100644 --- a/src/main/java/net/fabricmc/loom/util/SourceRemapper.java +++ b/src/main/java/net/fabricmc/loom/util/SourceRemapper.java @@ -135,6 +135,8 @@ public class SourceRemapper { project.getLogger().warn("Could not remap " + source.getName() + " fully!", e); } + copyNonJavaFiles(srcPath, dstPath, project, source); + if (dstFs != null) { dstFs.close(); } @@ -142,8 +144,28 @@ public class SourceRemapper { if (isSrcTmp) { Files.walkFileTree(srcPath, new DeletingFileVisitor()); } + } + private static void copyNonJavaFiles(Path from, Path to, Project project, File source) throws IOException { + Files.walk(from).forEach(path -> { + Path targetPath = to.resolve(from.relativize(path).toString()); + if (!isJavaFile(path) && !Files.exists(targetPath)) { + try { + Files.copy(path, targetPath); + } catch (IOException e) { + project.getLogger().warn("Could not copy non-java sources '" + source.getName() + "' fully!", e); + } + } + }); + } + + private static boolean isJavaFile(Path path) { + String name = path.getFileName().toString(); + // ".java" is not a valid java file + return name.endsWith(".java") && name.length() != 5; + } + public static class TinyReader extends MappingsReader { private final Mappings m; private final String from, to;