You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gb...@apache.org on 2016/10/22 18:11:12 UTC

svn commit: r1766221 - in /maven/plugins/trunk/maven-compiler-plugin/src/site/apt/examples: compile-using-different-jdk.apt.vm set-compiler-source-and-target.apt.vm

Author: gboue
Date: Sat Oct 22 18:11:12 2016
New Revision: 1766221

URL: http://svn.apache.org/viewvc?rev=1766221&view=rev
Log:
- Updating the "Setting the -source and -target of the Java Compiler": fixing broken link to Mojohaus, adding a note about the usage of "source", linking to the page about compiling with a different JDK.
- Updating "Compile using a different JDK" documentation page to reference toolchains.

Modified:
    maven/plugins/trunk/maven-compiler-plugin/src/site/apt/examples/compile-using-different-jdk.apt.vm
    maven/plugins/trunk/maven-compiler-plugin/src/site/apt/examples/set-compiler-source-and-target.apt.vm

Modified: maven/plugins/trunk/maven-compiler-plugin/src/site/apt/examples/compile-using-different-jdk.apt.vm
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/src/site/apt/examples/compile-using-different-jdk.apt.vm?rev=1766221&r1=1766220&r2=1766221&view=diff
==============================================================================
--- maven/plugins/trunk/maven-compiler-plugin/src/site/apt/examples/compile-using-different-jdk.apt.vm (original)
+++ maven/plugins/trunk/maven-compiler-plugin/src/site/apt/examples/compile-using-different-jdk.apt.vm Sat Oct 22 18:11:12 2016
@@ -28,6 +28,22 @@
 
 Compiling Sources Using A Different JDK
 
+* Using Maven Toolchains
+
+  The preferable way to use a different JDK is to use the toolchains mechanism. During the build of a project, Maven, 
+  without toolchains, will use the JDK to perform various steps, like compiling the Java sources, generate the Javadoc,
+  run unit tests or sign JARs. Each of those plugins need a tool of the JDK to operate: <<<javac>>>, <<<javadoc>>>,
+  <<<jarsigner>>>, etc. A toolchains is a way to specify the path to the JDK to use for all of those plugins in a
+  centralized manner, independant from the one running Maven itself.
+  
+  To set this up, refer to the {{{/guides/mini/guide-using-toolchains.html}Guide to Using Toolchains}}, which makes use
+  of the {{{/plugins/maven-toolchains-plugin/}Maven Toolchains Plugin}}.
+
+* Configuring the Compiler Plugin
+
+  Outside of a toolchains, it is still possible to tell the Compiler Plugin the specific JDK to use during compilation.
+  Note that such configuration will be specific to this plugin, and will not affect others.
+  
   The <<<compilerVersion>>> parameter can be used to specify the version of the
   compiler that the plugin will use. However, you also need to set <<<fork>>>
   to <<<true>>> for this to work. For example:

Modified: maven/plugins/trunk/maven-compiler-plugin/src/site/apt/examples/set-compiler-source-and-target.apt.vm
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/src/site/apt/examples/set-compiler-source-and-target.apt.vm?rev=1766221&r1=1766220&r2=1766221&view=diff
==============================================================================
--- maven/plugins/trunk/maven-compiler-plugin/src/site/apt/examples/set-compiler-source-and-target.apt.vm (original)
+++ maven/plugins/trunk/maven-compiler-plugin/src/site/apt/examples/set-compiler-source-and-target.apt.vm Sat Oct 22 18:11:12 2016
@@ -35,7 +35,20 @@ Setting the <<<-source>>> and <<<-target
 
   For example, if you want to use the Java 8 language features (<<<-source 1.8>>>)
   and also want the compiled classes to be compatible with JVM 1.8 (<<<-target 1.8>>>),
-  you can then put:
+  you can either add the two following properties, which are the default property names for the plugin parameters:
+
++-----
+<project>
+  [...]
+  <properties>
+    <maven.compiler.source>1.8</maven.compiler.source>
+    <maven.compiler.target>1.8</maven.compiler.target>
+  </properties>
+  [...]
+</project>
++-----
+
+  or configure the plugin directly:
 
 +-----
 <project>
@@ -63,5 +76,8 @@ Setting the <<<-source>>> and <<<-target
   specified version. The pitfall is unintended usage of APIs that only exist in later JREs which would make your code
   fail at runtime with a linkage error. To avoid this issue, you can either configure the compiler's boot classpath
   to match the target JRE or use the
-  {{{http://mojo.codehaus.org/animal-sniffer-maven-plugin/}Animal Sniffer Maven Plugin}} to verify your code doesn't
-  use unintended APIs.
+  {{{http://www.mojohaus.org/animal-sniffer/animal-sniffer-maven-plugin/}Animal Sniffer Maven Plugin}}
+  to verify your code doesn't use unintended APIs. In the same way, setting the <<<source>>> option does not guarantee 
+  that your code actually compiles on a JDK with the specified version. To compile your code with a specific JDK 
+  version, different than the one used to launch Maven, refer to the
+  {{{../examples/compile-using-different-jdk.html}Compile Using A Different JDK}} example.