diff --git a/.sdkmanrc b/.sdkmanrc new file mode 100644 index 00000000..bc36ae5d --- /dev/null +++ b/.sdkmanrc @@ -0,0 +1,3 @@ +# Enable auto-env through the sdkman_auto_env config +# Add key=value pairs of SDKs to use below +java=21-tem diff --git a/src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java b/src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java index 4c0b9ae9..24888253 100644 --- a/src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java +++ b/src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java @@ -206,6 +206,17 @@ public Stream listSourceFiles(MavenProject mavenProject, @Nullable X .map(addProvenance(baseDir, projectProvenance, null)); logDebug(mavenProject, "Parsed " + (alreadyParsed.size() - sourcesParsedBefore) + " additional files found within the project."); sourceFiles = Stream.concat(sourceFiles, parsedResourceFiles); + } else { + // Only parse Maven wrapper files, such that UpdateMavenWrapper can use the version information. + int sourcesParsedBefore = alreadyParsed.size(); + Stream parsedResourceFiles = Stream.concat( + rp.parse(mavenProject.getBasedir().toPath().resolve(".mvn/wrapper"), alreadyParsed), + Stream.concat( + rp.parse(mavenProject.getBasedir().toPath().resolve("mvnw"), alreadyParsed), + rp.parse(mavenProject.getBasedir().toPath().resolve("mvnw.cmd"), alreadyParsed))) + .map(addProvenance(baseDir, projectProvenance, null)); + logDebug(mavenProject, "Parsed " + (alreadyParsed.size() - sourcesParsedBefore) + " Maven wrapper files found within the project."); + sourceFiles = Stream.concat(sourceFiles, parsedResourceFiles); } // log parse errors here at the end, so that we don't log parse errors for files that were excluded @@ -216,7 +227,7 @@ private SourceFile logParseErrors(SourceFile source) { if (source instanceof ParseError) { if (firstWarningLogged.compareAndSet(false, true)) { logger.warn("There were problems parsing some source files" + - (mavenSession.getRequest().isShowErrors() ? "" : ", run with --errors to see full stack traces")); + (mavenSession.getRequest().isShowErrors() ? "" : ", run with --errors to see full stack traces")); } logger.warn("There were problems parsing " + source.getSourcePath()); }