Add property to configure JavaParser logging

This commit is contained in:
Fabian Krüger
2024-01-09 16:58:14 +00:00
committed by GitHub
parent e23bad299e
commit d466412b06
2 changed files with 15 additions and 1 deletions

View File

@@ -15,6 +15,7 @@
*/
package org.springframework.rewrite.parsers;
import org.openrewrite.java.JavaParser;
import org.springframework.boot.context.properties.ConfigurationProperties;
import java.nio.file.Path;
@@ -92,6 +93,11 @@ public class SpringRewriteProperties {
*/
private boolean parseAdditionalResources = true;
/**
* Whether {@link JavaParser} should log compilation warnings and errors.
*/
private boolean logCompilationWarningsAndErrors = false;
public boolean isSkipMavenParsing() {
return skipMavenParsing;
}
@@ -172,4 +178,12 @@ public class SpringRewriteProperties {
this.parseAdditionalResources = parseAdditionalResources;
}
public boolean isLogCompilationWarningsAndErrors() {
return logCompilationWarningsAndErrors;
}
public void setLogCompilationWarningsAndErrors(boolean logCompilationWarningsAndErrors) {
this.logCompilationWarningsAndErrors = logCompilationWarningsAndErrors;
}
}

View File

@@ -87,7 +87,7 @@ public class MavenModuleParser {
JavaParser.Builder<? extends JavaParser, ?> javaParserBuilder = JavaParser.fromJavaVersion()
.styles(styles)
.logCompilationWarningsAndErrors(false);
.logCompilationWarningsAndErrors(springRewriteProperties.isLogCompilationWarningsAndErrors());
Path buildFilePath = currentProject.getBasedir().resolve(moduleBuildFile.getSourcePath());
LOGGER.info("Parsing module " + buildFilePath);