From 1108fc99ecdf478acbb52476bbbb9af4fde49212 Mon Sep 17 00:00:00 2001 From: Bruno Salmon Date: Wed, 10 Apr 2024 16:40:57 +0100 Subject: [PATCH] Added module-info.java filter prior to Java 8 compilation (#258) --- .../com/vertispan/j2cl/build/provided/BytecodeTask.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/j2cl-tasks/src/main/java/com/vertispan/j2cl/build/provided/BytecodeTask.java b/j2cl-tasks/src/main/java/com/vertispan/j2cl/build/provided/BytecodeTask.java index c67df298..c5a95fc9 100644 --- a/j2cl-tasks/src/main/java/com/vertispan/j2cl/build/provided/BytecodeTask.java +++ b/j2cl-tasks/src/main/java/com/vertispan/j2cl/build/provided/BytecodeTask.java @@ -52,6 +52,8 @@ public class BytecodeTask extends TaskFactory { public static final PathMatcher JAVA_SOURCES = withSuffix(".java"); public static final PathMatcher JAVA_BYTECODE = withSuffix(".class"); public static final PathMatcher NOT_BYTECODE = p -> !JAVA_BYTECODE.matches(p); + public static final PathMatcher JAVA_MODULE_INFO = withSuffix("module-info.java"); + public static final PathMatcher JAVA_SOURCES_EXCEPT_MODULE_INFO = p -> JAVA_SOURCES.matches(p) && !JAVA_MODULE_INFO.matches(p); public static final PathMatcher APT_PROCESSOR = p -> p.equals(Paths.get("META-INF", "services", "javax.annotation.processing.Processor")); @@ -88,8 +90,8 @@ public Task resolve(Project project, Config config) { // TODO just use one input for both of these // track the dirs (with all file changes) so that APT can see things it wants Input inputDirs = input(project, OutputTypes.INPUT_SOURCES); - // track just java files (so we can just compile them) - Input inputSources = input(project, OutputTypes.INPUT_SOURCES).filter(JAVA_SOURCES); + // track just java files (so we can just compile them), ignoring module-info.java files (as they make javac 8 fail) + Input inputSources = input(project, OutputTypes.INPUT_SOURCES).filter(JAVA_SOURCES_EXCEPT_MODULE_INFO); // track resources so they are available to downstream processors on the classpath, as they would // be if we had built a jar Input resources = input(project, OutputTypes.INPUT_SOURCES).filter(NOT_BYTECODE);