diff --git a/rewrite-java-test/src/test/java/org/openrewrite/java/JavaParserTest.java b/rewrite-java-test/src/test/java/org/openrewrite/java/JavaParserTest.java index b74cd479f67..c5b6fda983a 100644 --- a/rewrite-java-test/src/test/java/org/openrewrite/java/JavaParserTest.java +++ b/rewrite-java-test/src/test/java/org/openrewrite/java/JavaParserTest.java @@ -35,6 +35,7 @@ import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.openrewrite.java.Assertions.java; /** @@ -157,4 +158,11 @@ void shouldResolvePathUsingPublicClasses(@Language("java") String source) { ) ); } + + @Test + @Issue("https://github.com/openrewrite/rewrite/issues/1895") + void moduleInfo(){ + // Ignored until properly handled: https://github.com/openrewrite/rewrite/issues/4054#issuecomment-2267605739 + assertFalse(JavaParser.fromJavaVersion().build().accept(Path.of("src/main/java/foo/module-info.java"))); + } } diff --git a/rewrite-java/src/main/java/org/openrewrite/java/JavaParser.java b/rewrite-java/src/main/java/org/openrewrite/java/JavaParser.java index e912c6b12b6..b3df6b61cd7 100644 --- a/rewrite-java/src/main/java/org/openrewrite/java/JavaParser.java +++ b/rewrite-java/src/main/java/org/openrewrite/java/JavaParser.java @@ -273,7 +273,7 @@ default Stream parse(@Language("java") String... sources) { @Override default boolean accept(Path path) { - return path.toString().endsWith(".java"); + return path.toString().endsWith(".java") && !path.endsWith("module-info.java"); } /**