From e09f8bce92fcf8a84ab8a8b9bcfc95654ea491fe Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Thu, 29 Apr 2021 18:06:37 +1000 Subject: [PATCH] fix methods of lint and warning see https://github.com/codehaus-plexus/plexus-compiler/pull/131#discussion_r622796309 Signed-off-by: olivier lamy --- .../compiler/CompilerConfiguration.java | 22 +++++++++++++++---- .../src/main/it/simple-javac/pom.xml | 1 + .../plexus/compiler/javac/JavacCompiler.java | 14 +++++++++--- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerConfiguration.java b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerConfiguration.java index 41dff0f0..781bf545 100644 --- a/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerConfiguration.java +++ b/plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerConfiguration.java @@ -70,6 +70,8 @@ public class CompilerConfiguration private boolean showWarnings = true; private String warnings; + + private boolean showLint; /** * -Werror argument as supported since Java 1.7 @@ -341,9 +343,9 @@ public String getDebugLevel() return debugLevel; } - public void setShowWarnings( boolean showWarnings ) + public void setWarnings( String warnings ) { - this.showWarnings = showWarnings; + this.warnings = warnings; } public boolean isShowWarnings() @@ -351,6 +353,11 @@ public boolean isShowWarnings() return showWarnings; } + public void setShowWarnings( boolean showWarnings ) + { + this.showWarnings = showWarnings; + } + public boolean isShowDeprecation() { return showDeprecation; @@ -361,9 +368,16 @@ public String getWarnings() return warnings; } - public void setShowLint( String warnings ) + + + public void setShowLint( boolean showLint ) { - this.warnings = warnings; + this.showLint = showLint; + } + + public boolean isShowLint() + { + return this.showLint; } public void setShowDeprecation( boolean showDeprecation ) diff --git a/plexus-compiler-its/src/main/it/simple-javac/pom.xml b/plexus-compiler-its/src/main/it/simple-javac/pom.xml index 08b00e9e..6bb02053 100644 --- a/plexus-compiler-its/src/main/it/simple-javac/pom.xml +++ b/plexus-compiler-its/src/main/it/simple-javac/pom.xml @@ -50,6 +50,7 @@ 8 8 + -Xlint:-path diff --git a/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/JavacCompiler.java b/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/JavacCompiler.java index b843a2b8..63bc5722 100644 --- a/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/JavacCompiler.java +++ b/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/JavacCompiler.java @@ -343,12 +343,20 @@ public static String[] buildCompilerArguments( CompilerConfiguration config, Str if ( !config.isShowWarnings() ) { args.add( "-nowarn" ); - } else + } + else { String warnings = config.getWarnings(); - if (StringUtils.isNotEmpty(warnings)) + if (config.isShowLint()) { - args.add("-Xlint:" + warnings); + if(config.isShowWarnings() && StringUtils.isNotEmpty(warnings)) + { + args.add( "-Xlint:" + warnings ); + } + else + { + args.add( "-Xlint" ); + } } }