Maven compiler Plugin: Difference between revisions
Jump to navigation
Jump to search
Line 6: | Line 6: | ||
* [[Maven#Plugin|Maven]] | * [[Maven#Plugin|Maven]] | ||
=Configuration Example= | |||
<pre> | |||
</pre> | |||
=Adding <tt>rt.jar</tt> to the compilation classpath= | =Adding <tt>rt.jar</tt> to the compilation classpath= |
Revision as of 16:36, 11 January 2017
External
Internal
Configuration Example
Adding rt.jar to the compilation classpath
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <compilerArguments> <bootclasspath>${java.home}\lib\rt.jar</bootclasspath> </compilerArguments> </configuration> </plugin>
Source File Encoding
If nothing is explicitly configured, the plugin does not configure the java compiler -encoding flag:
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ northstar --- [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! [INFO] Compiling 291 source files to /Users/ovidiu/c063-Apple/src/mobileappsfoundation/northstar/target/test-classes
To configure a specific encoding to be passed to the compiler, you can configure the "encoding" parameter on the plugin, which specifies the the -encoding argument for the Java compiler:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.6.0</version> <configuration> <source>1.7</source> <target>1.7</target> <debug>true</debug> <encoding>UTF-8</encoding> </configuration> </plugin>
If not explicitly specified in the plugin configuration, the default value passed to the compiler is ${project.build.sourceEncoding}, if defined, or otherwise the platform default value.