Skip to content

Commit e09f8bc

Browse files
committed
fix methods of lint and warning see #131 (comment)
Signed-off-by: olivier lamy <olamy@apache.org>
1 parent 56c109a commit e09f8bc

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

plexus-compiler-api/src/main/java/org/codehaus/plexus/compiler/CompilerConfiguration.java

+18-4
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ public class CompilerConfiguration
7070
private boolean showWarnings = true;
7171

7272
private String warnings;
73+
74+
private boolean showLint;
7375

7476
/**
7577
* -Werror argument as supported since Java 1.7
@@ -341,16 +343,21 @@ public String getDebugLevel()
341343
return debugLevel;
342344
}
343345

344-
public void setShowWarnings( boolean showWarnings )
346+
public void setWarnings( String warnings )
345347
{
346-
this.showWarnings = showWarnings;
348+
this.warnings = warnings;
347349
}
348350

349351
public boolean isShowWarnings()
350352
{
351353
return showWarnings;
352354
}
353355

356+
public void setShowWarnings( boolean showWarnings )
357+
{
358+
this.showWarnings = showWarnings;
359+
}
360+
354361
public boolean isShowDeprecation()
355362
{
356363
return showDeprecation;
@@ -361,9 +368,16 @@ public String getWarnings()
361368
return warnings;
362369
}
363370

364-
public void setShowLint( String warnings )
371+
372+
373+
public void setShowLint( boolean showLint )
365374
{
366-
this.warnings = warnings;
375+
this.showLint = showLint;
376+
}
377+
378+
public boolean isShowLint()
379+
{
380+
return this.showLint;
367381
}
368382

369383
public void setShowDeprecation( boolean showDeprecation )

plexus-compiler-its/src/main/it/simple-javac/pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
<configuration>
5151
<target>8</target>
5252
<source>8</source>
53+
<!-- <showLint>true</showLint>-->
5354
<compilerArgs>
5455
<compilerArg>-Xlint:-path</compilerArg>
5556
</compilerArgs>

plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/JavacCompiler.java

+11-3
Original file line numberDiff line numberDiff line change
@@ -343,12 +343,20 @@ public static String[] buildCompilerArguments( CompilerConfiguration config, Str
343343
if ( !config.isShowWarnings() )
344344
{
345345
args.add( "-nowarn" );
346-
} else
346+
}
347+
else
347348
{
348349
String warnings = config.getWarnings();
349-
if (StringUtils.isNotEmpty(warnings))
350+
if (config.isShowLint())
350351
{
351-
args.add("-Xlint:" + warnings);
352+
if(config.isShowWarnings() && StringUtils.isNotEmpty(warnings))
353+
{
354+
args.add( "-Xlint:" + warnings );
355+
}
356+
else
357+
{
358+
args.add( "-Xlint" );
359+
}
352360
}
353361
}
354362

0 commit comments

Comments
 (0)