diff --git a/src/it/release-without-profile-fork/invoker.properties b/src/it/release-without-profile-fork/invoker.properties new file mode 100644 index 00000000..0659ac55 --- /dev/null +++ b/src/it/release-without-profile-fork/invoker.properties @@ -0,0 +1,18 @@ +# 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. + +invoker.goals = compile diff --git a/src/it/release-without-profile-fork/pom.xml b/src/it/release-without-profile-fork/pom.xml new file mode 100644 index 00000000..529ceedb --- /dev/null +++ b/src/it/release-without-profile-fork/pom.xml @@ -0,0 +1,45 @@ + + + + + 4.0.0 + org.apache.maven.plugins.compiler.it + release-without-profile-fork + 1.0-SNAPSHOT + + + + + org.apache.maven.plugins + maven-compiler-plugin + @project.version@ + + + 8 + 8 + 8 + true + + + + + + diff --git a/src/it/release-without-profile-fork/src/main/java/MyClass.java b/src/it/release-without-profile-fork/src/main/java/MyClass.java new file mode 100644 index 00000000..d4132bb2 --- /dev/null +++ b/src/it/release-without-profile-fork/src/main/java/MyClass.java @@ -0,0 +1,21 @@ +/* + * 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. + */ +package foo; + +public class MyClass {} diff --git a/src/it/release-without-profile-fork/verify.groovy b/src/it/release-without-profile-fork/verify.groovy new file mode 100644 index 00000000..e563b3d7 --- /dev/null +++ b/src/it/release-without-profile-fork/verify.groovy @@ -0,0 +1,29 @@ +/* + * 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. + */ +def logFile = new File(basedir, 'build.log') +assert logFile.exists() +content = logFile.text + +// for jdk 8 we will have target and source +def jdkTarget = content.contains(' -source 8') && content.contains(' -target 8') && !content.contains(' --release 8') + +// for jdk9+ we will have release only +def jdkRelease = !content.contains(' -source 8') && !content.contains(' -target 8') && content.contains(' --release 8') + +assert (jdkTarget && !jdkRelease) || (!jdkTarget && jdkRelease) diff --git a/src/it/release-without-profile/invoker.properties b/src/it/release-without-profile/invoker.properties new file mode 100644 index 00000000..0659ac55 --- /dev/null +++ b/src/it/release-without-profile/invoker.properties @@ -0,0 +1,18 @@ +# 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. + +invoker.goals = compile diff --git a/src/it/release-without-profile/pom.xml b/src/it/release-without-profile/pom.xml new file mode 100644 index 00000000..ce58cab9 --- /dev/null +++ b/src/it/release-without-profile/pom.xml @@ -0,0 +1,44 @@ + + + + + 4.0.0 + org.apache.maven.plugins.compiler.it + release-without-profile + 1.0-SNAPSHOT + + + + + org.apache.maven.plugins + maven-compiler-plugin + @project.version@ + + + 8 + 8 + 8 + + + + + + diff --git a/src/it/release-without-profile/src/main/java/MyClass.java b/src/it/release-without-profile/src/main/java/MyClass.java new file mode 100644 index 00000000..d4132bb2 --- /dev/null +++ b/src/it/release-without-profile/src/main/java/MyClass.java @@ -0,0 +1,21 @@ +/* + * 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. + */ +package foo; + +public class MyClass {} diff --git a/src/it/release-without-profile/verify.groovy b/src/it/release-without-profile/verify.groovy new file mode 100644 index 00000000..e563b3d7 --- /dev/null +++ b/src/it/release-without-profile/verify.groovy @@ -0,0 +1,29 @@ +/* + * 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. + */ +def logFile = new File(basedir, 'build.log') +assert logFile.exists() +content = logFile.text + +// for jdk 8 we will have target and source +def jdkTarget = content.contains(' -source 8') && content.contains(' -target 8') && !content.contains(' --release 8') + +// for jdk9+ we will have release only +def jdkRelease = !content.contains(' -source 8') && !content.contains(' -target 8') && content.contains(' --release 8') + +assert (jdkTarget && !jdkRelease) || (!jdkTarget && jdkRelease) diff --git a/src/site/apt/examples/set-compiler-release.apt.vm b/src/site/apt/examples/set-compiler-release.apt.vm index 51219e09..3befe702 100644 --- a/src/site/apt/examples/set-compiler-release.apt.vm +++ b/src/site/apt/examples/set-compiler-release.apt.vm @@ -85,7 +85,12 @@ Setting the <<<--release>>> of the Java Compiler The <<<--release>>> option is not supported using JDK 8. To enable a project that targets Java 8 to be built using JDK 8 and also JDK 9 or later requires the conditional usage of the - <<<--release>>> option. This may be done through the use of a profile: + <<<--release>>> option. + + Conditional parametrization is required for the Compiler Plugin version below <<<3.13.0>>> + or compilerId different that <<>>. + + This may be done through the use of a profile: +----- @@ -106,3 +111,32 @@ Setting the <<<--release>>> of the Java Compiler [...] +----- + + Since version <<<3.13.0>>> of the Compiler Plugin together with the default <<>> compilerId you don't need conditional parametrisation of <<>>. + The <<>> parameter will only be effective for Java 9 or above, otherwise the <<>> and <<>> will be passed to the compiler. + + So you can simply configure as: + ++----- + + [...] + + [...] + + + org.apache.maven.plugins + maven-compiler-plugin + ${project.version} + + 8 + 8 + 8 + + + + [...] + + [...] + ++----- +