This is an automated email from the ASF dual-hosted git repository. sjaranowski pushed a commit to branch MCOMPILER-582 in repository https://gitbox.apache.org/repos/asf/maven-compiler-plugin.git
commit e78e58303d0af49f17534a31577510cc64fba547 Author: Slawomir Jaranowski <s.jaranow...@gmail.com> AuthorDate: Mon Mar 11 18:44:21 2024 +0100 [MCOMPILER-582] Release option without profile for JDK 8 --- .../invoker.properties | 18 +++++++++ src/it/release-without-profile-fork/pom.xml | 45 ++++++++++++++++++++++ .../src/main/java/MyClass.java | 21 ++++++++++ src/it/release-without-profile-fork/verify.groovy | 29 ++++++++++++++ src/it/release-without-profile/invoker.properties | 18 +++++++++ src/it/release-without-profile/pom.xml | 44 +++++++++++++++++++++ .../src/main/java/MyClass.java | 21 ++++++++++ src/it/release-without-profile/verify.groovy | 29 ++++++++++++++ src/site/apt/examples/set-compiler-release.apt.vm | 26 +++++++++++++ 9 files changed, 251 insertions(+) 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 0000000..0659ac5 --- /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 0000000..529ceed --- /dev/null +++ b/src/it/release-without-profile-fork/pom.xml @@ -0,0 +1,45 @@ +<?xml version='1.0'?> +<!-- +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. +--> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.maven.plugins.compiler.it</groupId> + <artifactId>release-without-profile-fork</artifactId> + <version>1.0-SNAPSHOT</version> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>@project.version@</version> + <configuration> + <!-- compiler arguments will by automatically selected against to used JDK --> + <release>8</release> + <target>8</target> + <source>8</source> + <fork>true</fork> + </configuration> + </plugin> + </plugins> + + </build> +</project> 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 0000000..d4132bb --- /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 0000000..e563b3d --- /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 0000000..0659ac5 --- /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 0000000..ce58cab --- /dev/null +++ b/src/it/release-without-profile/pom.xml @@ -0,0 +1,44 @@ +<?xml version='1.0'?> +<!-- +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. +--> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.maven.plugins.compiler.it</groupId> + <artifactId>release-without-profile</artifactId> + <version>1.0-SNAPSHOT</version> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>@project.version@</version> + <configuration> + <!-- compiler arguments will by automatically selected against to used JDK --> + <release>8</release> + <target>8</target> + <source>8</source> + </configuration> + </plugin> + </plugins> + + </build> +</project> 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 0000000..d4132bb --- /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 0000000..e563b3d --- /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 51219e0..75e6902 100644 --- a/src/site/apt/examples/set-compiler-release.apt.vm +++ b/src/site/apt/examples/set-compiler-release.apt.vm @@ -106,3 +106,29 @@ Setting the <<<--release>>> of the Java Compiler [...] </project> +----- + + <<Note:>> since plugin version <<<3.13.0>>> you can skip special profile and simply configure as: + ++----- +<project> + [...] + <build> + [...] + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>${project.version}</version> + <configuration> + <release>8</release> + <source>8</source> + <target>8</target> + </configuration> + </plugin> + </plugins> + [...] + </build> + [...] +</project> ++----- +