Maven compiler Plugin: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "=External= * http://maven.apache.org/plugins/maven-compiler-plugin =Internal= * Maven#Plugin =Adding <tt>rt.jar</tt> to the compilation classpath= <pre> <plugin>...")
 
Line 19: Line 19:
     </configuration>
     </configuration>
</plugin>
</plugin>
}}}
</pre>


=Source File Encoding=
=Source File Encoding=

Revision as of 19:37, 26 October 2016

External

Internal

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>
     <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.