Close

Pass javac -g option from command line with Maven

[Last Updated: Nov 4, 2018]

Maven 

mvn -Dmaven.compiler.debuglevel=none clean install

Legal values for debuglevel are none or a comma-separated list of the following keywords: lines, vars, and source. If debug level is not specified, by default, nothing will be appended to -g.

We can also set javac -g option using maven-compiler-plugin specific compilerArgs element in pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project>
......
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>

<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<compilerArgs>
<arg>-g:source,lines</arg>
</compilerArgs>

</configuration>
</plugin>
</plugins>
</build>
</project>


See Also