------ 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 <<>> for Java 9 projects must be aware that they need to call <<>> twice: the <<>> must be compiled with <<>>, while the rest of the sources must be compiled with a lower version of <<>>/<<>>. The preferred way to do this is by having 2 execution blocks are described below. JDK 9 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. You could add a jdkToolchain to do base-compile execution-block as well referring to JDK 5. +------- [...] [...] org.apache.maven.plugins maven-compiler-plugin ${project.version} default-compile 9 9 base-compile compile module-info.java 1.5 1.5 [1.5,9) 9 [...] [...] +------- 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 JDK 9 installation on your system. Or simply use Java 9 as the runtime for Maven by setting <<>>. +------- [...] [...] org.apache.maven.plugins maven-compiler-plugin ${project.version} default-compile 9 base-compile compile module-info.java 6 9 [...] [...] +-------