I'm using maven to build a new project. There are some warnings in my codes which are underlined by yellow line. I wish maven could report these warnings in console. How can I accomplish that? Can I just add some parameters in the command such as mvn -XXX clean compile?
<annotationProcessorPaths>The detection itself depends on the configuration of annotationProcessors. Each classpath element is specified using their Maven coordinates (groupId, artifactId, version, classifier, type). Transitive dependencies are added automatically.
mvn clean This command cleans the maven project by deleting the target directory.
<showDeprecation>
Sets whether to show source locations where deprecated APIs are used.
- Default value is:
false
- User property is:
maven.compiler.showDeprecation
<showWarnings>
Set totrue
to show compilation warnings.
- Default value is:
false
- User property is:
maven.compiler.showWarnings
-- Maven Doku
As simple as mvn clean install -Dmaven.compiler.showDeprecation=true -Dmaven.compiler.showWarnings=true
all in one line.
You could even remove the =true
part because, when you add a maven parameter with -D
it automatically sets its value to true
, if not set to something else.
With maven 3.3.9, using the maven-compiler-plugin and Java 1.8, you need a <configuration>
section like the following:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<compilerArgument>-Xlint:all</compilerArgument>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
I got this answer from here when none of the above worked for me: http://frequal.com/java/EnableWarningsInMaven.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With