Skip to content

Commit

Permalink
Always parse Maven wrapper files (#677)
Browse files Browse the repository at this point in the history
* Always parse Maven wrapper files

Fixes #1005

* Update src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java
  • Loading branch information
timtebeek authored Dec 4, 2023
1 parent d931bae commit 9285e03
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .sdkmanrc
Original file line number Diff line number Diff line change
@@ -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
13 changes: 12 additions & 1 deletion src/main/java/org/openrewrite/maven/MavenMojoProjectParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,17 @@ public Stream<SourceFile> 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<SourceFile> 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
Expand All @@ -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());
}
Expand Down

0 comments on commit 9285e03

Please sign in to comment.