I have a Java project which is built using Maven. I would like to add options to the "javac" command line - particularly, I want to pass a few "-J" options.
So normally I would do something like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgument>-J-Xdebug</compilerArgument>
<compilerArgument>-J-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005</compilerArgument>
</configuration>
</plugin>
However when I try this I get errors of the form:
[ERROR] Failure executing javac, but could not parse the error:
javac: invalid flag: -J-Xdebug
Usage: javac <options> <source files>
use -help for a list of possible options
On closer investigation, it seems that maven-compiler-plugin writes all the compiler arguments out to an options file, and invokes javac like 'javac @optionfile'. According to the official documentation for javac at http://docs.oracle.com/javase/6/docs/technotes/tools/solaris/javac.html:
@argfiles One or more files that lists options and source files. The -J options are not allowed in these files.
So it looks like the option in maven-compiler-plugin is not going to work - it wants to use arg files, arg files cannot contain the options I want.
I've also seen some suggestions to use the map instead - however this had similar results when I tried it.
Are there any other options?