You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2016/09/27 21:44:10 UTC

svn commit: r1762573 - in /maven/plugins/trunk/maven-compiler-plugin: pom.xml src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java src/site/apt/examples/module-info.apt.vm src/site/site.xml

Author: rfscholte
Date: Tue Sep 27 21:44:10 2016
New Revision: 1762573

URL: http://svn.apache.org/viewvc?rev=1762573&view=rev
Log:
[MCOMPILER-269] Support modulepath (Java9/Jigsaw)
add documentation

Added:
    maven/plugins/trunk/maven-compiler-plugin/src/site/apt/examples/module-info.apt.vm
Modified:
    maven/plugins/trunk/maven-compiler-plugin/pom.xml
    maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
    maven/plugins/trunk/maven-compiler-plugin/src/site/site.xml

Modified: maven/plugins/trunk/maven-compiler-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/pom.xml?rev=1762573&r1=1762572&r2=1762573&view=diff
==============================================================================
--- maven/plugins/trunk/maven-compiler-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-compiler-plugin/pom.xml Tue Sep 27 21:44:10 2016
@@ -25,7 +25,7 @@ under the License.
   <parent>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-plugins</artifactId>
-    <version>28</version>
+    <version>30</version>
     <relativePath>../../pom/maven/maven-plugins/pom.xml</relativePath>
   </parent>
 
@@ -209,17 +209,24 @@ under the License.
             </execution>
           </executions>
         </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-plugin-plugin</artifactId>
+          <version>3.5</version>
+        </plugin>
       </plugins>
     </pluginManagement>
+  </build>
+
+  <reporting>
     <plugins>
       <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-plugin-plugin</artifactId>
         <version>3.5</version>
       </plugin>
     </plugins>
-  </build>
-
+  </reporting>
+  
   <profiles>
     <profile>
       <id>run-its</id>

Modified: maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java?rev=1762573&r1=1762572&r2=1762573&view=diff
==============================================================================
--- maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java (original)
+++ maven/plugins/trunk/maven-compiler-plugin/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java Tue Sep 27 21:44:10 2016
@@ -1217,7 +1217,7 @@ public abstract class AbstractCompilerMo
         
         if ( jdkToolchain != null )
         {
-            // Maven 3.2.6 has plugin execution scoped Toolchain Support
+            // Maven 3.3.1 has plugin execution scoped Toolchain Support
             try
             {
                 Method getToolchainsMethod =

Added: maven/plugins/trunk/maven-compiler-plugin/src/site/apt/examples/module-info.apt.vm
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/src/site/apt/examples/module-info.apt.vm?rev=1762573&view=auto
==============================================================================
--- maven/plugins/trunk/maven-compiler-plugin/src/site/apt/examples/module-info.apt.vm (added)
+++ maven/plugins/trunk/maven-compiler-plugin/src/site/apt/examples/module-info.apt.vm Tue Sep 27 21:44:10 2016
@@ -0,0 +1,136 @@
+ ------
+ Older projects with module-info
+ ------
+ Robert Scholte
+ ------
+ 2016-09-27
+ ------
+
+~~ Licensed to the Apache Software Foundation (ASF) under one
+~~ or more contributor license agreements.  See the NOTICE file
+~~ distributed with this work for additional information
+~~ regarding copyright ownership.  The ASF licenses this file
+~~ to you under the Apache License, Version 2.0 (the
+~~ "License"); you may not use this file except in compliance
+~~ with the License.  You may obtain a copy of the License at
+~~
+~~   http://www.apache.org/licenses/LICENSE-2.0
+~~
+~~ Unless required by applicable law or agreed to in writing,
+~~ software distributed under the License is distributed on an
+~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+~~ KIND, either express or implied.  See the License for the
+~~ specific language governing permissions and limitations
+~~ under the License.
+
+~~ NOTE: For help with the syntax of this file, see:
+~~ http://maven.apache.org/doxia/references/apt-format.html
+
+Older projects with module-info
+
+  For projects that want to be compatible with older versions of Java (i.e 1.8 or below), but also want to provide a
+  <<<module-info.java>>> for Java 9 projects must be aware that they need to call <<<javac>>> twice: the 
+  <<<module-info.java>>> must be compiled with <<<release=9>>>, while the rest of the sources must be compiled with a
+  lower version of <<<source>>>/<<<target>>>.
+
+  The preferred way to do this is by having 2 execution blocks are described below. JDK9 only supports compilations for 
+  Java 6 and above, so projects wanting to be compatible with Java 5 or below need to use two different JDKs. With 
+  {{{/guides/mini/guide-using-toolchains.html}toolchains}} it is quite easy to achieve this. Be aware that you will
+  need at least Maven 3.3.1 to specify a custom jdkToolchain in your plugin configuration.
+
++-------
+<project>
+  [...]
+  <build>
+    [...]
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>${project.version}</version>
+        <executions>
+          <execution>
+            <id>default-compile</id>
+            <configuration>
+              <excludes>
+                <exclude>module-info.java</exclude>
+              </excludes>
+              <source>1.5</source>
+              <target>1.5</target>
+            </configuration>
+          </execution>
+          <execution>
+            <id>moduleinfo-compile</id>
+            <goals>
+              <goal>compile</goal>
+            </goals>
+            <configuration>
+              <includes>
+                <include>module-info.java</include>
+              </includes>
+              <jdkToolchain>
+                <version>9</version>
+              </jdkToolchain>
+              <release>9</release>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+    [...]
+  </build>
+  [...]
+</project>
++-------
+
+  In case you want the project to be Java 6 compatible, the easiest to do this is to use Java 9 for both execution
+  blocks. You can use the maven-toolchain-plugin to specify the shared JDK (supported since Maven 2.0.9) or a custom 
+  jdkToolchain (supported since Maven 3.3.1) and refer to the JDK9 installation on your system. Or simply use Java 9
+  as the runtime for Maven by setting <<<JAVA_HOME=/path/to/jdk-9>>>. 
+
++-------
+<project>
+  [...]
+  <build>
+    [...]
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>${project.version}</version>
+        <executions>
+          <execution>
+            <id>default-compile</id>
+            <configuration>
+              <excludes>
+                <exclude>module-info.java</exclude>
+              </excludes>
+              <release>6</release>
+            </configuration>
+          </execution>
+          <execution>
+            <id>moduleinfo-compile</id>
+            <goals>
+              <goal>compile</goal>
+            </goals>
+            <configuration>
+              <includes>
+                <include>module-info.java</include>
+              </includes>
+              <release>9</release>
+            </configuration>
+          </execution>
+        </executions>
+        <configuration>
+          <!-- Only required when JAVA_HOME isn't at least Java9 and when haven't configured the maven-toolchains-plugin -->
+          <jdkToolchain>
+            <version>9</version>
+          </jdkToolchain>
+        </configuration>
+      </plugin>
+    </plugins>
+    [...]
+  </build>
+  [...]
+</project>
++-------

Modified: maven/plugins/trunk/maven-compiler-plugin/src/site/site.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-compiler-plugin/src/site/site.xml?rev=1762573&r1=1762572&r2=1762573&view=diff
==============================================================================
--- maven/plugins/trunk/maven-compiler-plugin/src/site/site.xml (original)
+++ maven/plugins/trunk/maven-compiler-plugin/src/site/site.xml Tue Sep 27 21:44:10 2016
@@ -38,6 +38,7 @@ under the License.
       <item name="Compile Using Memory Allocation Enhancements" href="examples/compile-with-memory-enhancements.html"/>
       <item name="Pass Compiler Arguments" href="examples/pass-compiler-arguments.html"/>
       <item name="Non-javac compilerIds" href="non-javac-compilers.html"/>
+      <item name="Older projects with module-info" href="examples/module-info.html"/>
     </menu>
   </body>
 </project>