Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always parse Maven wrapper files #677

Merged
merged 3 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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