diff --git a/src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java b/src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java index c0ba74af..bbfb5355 100644 --- a/src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java +++ b/src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java @@ -323,13 +323,13 @@ private Stream processMainSources( javaParserBuilder.classpath(dependencies).typeCache(typeCache); kotlinParserBuilder.classpath(dependencies).typeCache(new JavaTypeCache()); - Stream cus = Stream.of(javaParserBuilder) - .map(JavaParser.Builder::build) - .flatMap(parser -> parser.parse(mainJavaSources, baseDir, ctx)); + Stream cus = mainJavaSources.isEmpty() ? Stream.empty() + : Stream.of(javaParserBuilder).map(JavaParser.Builder::build) + .flatMap(parser -> parser.parse(mainJavaSources, baseDir, ctx)); - Stream kcus = Stream.of(kotlinParserBuilder) - .map(KotlinParser.Builder::build) - .flatMap(parser -> parser.parse(mainKotlinSources, baseDir, ctx)); + Stream kcus = mainKotlinSources.isEmpty() ? Stream.empty() + : Stream.of(kotlinParserBuilder).map(KotlinParser.Builder::build) + .flatMap(parser -> parser.parse(mainKotlinSources, baseDir, ctx)); List mainProjectProvenance = new ArrayList<>(projectProvenance); mainProjectProvenance.add(sourceSet("main", dependencies, typeCache)); @@ -382,13 +382,13 @@ private Stream processTestSources( alreadyParsed.addAll(testKotlinSources); - Stream cus = Stream.of(javaParserBuilder) - .map(JavaParser.Builder::build) - .flatMap(parser -> parser.parse(testJavaSources, baseDir, ctx)); + Stream cus = testJavaSources.isEmpty() ? Stream.empty() + : Stream.of(javaParserBuilder).map(JavaParser.Builder::build) + .flatMap(parser -> parser.parse(testJavaSources, baseDir, ctx)); - Stream kcus = Stream.of(kotlinParserBuilder) - .map(KotlinParser.Builder::build) - .flatMap(parser -> parser.parse(testKotlinSources, baseDir, ctx)); + Stream kcus = testKotlinSources.isEmpty() ? Stream.empty() + : Stream.of(kotlinParserBuilder).map(KotlinParser.Builder::build) + .flatMap(parser -> parser.parse(testKotlinSources, baseDir, ctx)); List markers = new ArrayList<>(projectProvenance); markers.add(sourceSet("test", testDependencies, typeCache));