From 340f63c996110e56b76b125b2e691bc1fccfb6b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= Date: Mon, 14 Aug 2023 18:57:55 +0100 Subject: [PATCH] [MCOMPILER-542] add IT --- src/it/MCOMPILER-542/invoker.properties | 18 +++++++ src/it/MCOMPILER-542/pom.xml | 50 +++++++++++++++++++ .../src/main/java/module-info.java | 19 +++++++ .../src/main/java/org/maven/test/Main.java | 29 +++++++++++ src/it/MCOMPILER-542/verify.groovy | 30 +++++++++++ 5 files changed, 146 insertions(+) create mode 100644 src/it/MCOMPILER-542/invoker.properties create mode 100644 src/it/MCOMPILER-542/pom.xml create mode 100644 src/it/MCOMPILER-542/src/main/java/module-info.java create mode 100644 src/it/MCOMPILER-542/src/main/java/org/maven/test/Main.java create mode 100644 src/it/MCOMPILER-542/verify.groovy diff --git a/src/it/MCOMPILER-542/invoker.properties b/src/it/MCOMPILER-542/invoker.properties new file mode 100644 index 00000000..95117185 --- /dev/null +++ b/src/it/MCOMPILER-542/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.java.version = 9+ diff --git a/src/it/MCOMPILER-542/pom.xml b/src/it/MCOMPILER-542/pom.xml new file mode 100644 index 00000000..d8cbe3ef --- /dev/null +++ b/src/it/MCOMPILER-542/pom.xml @@ -0,0 +1,50 @@ + + + + + 4.0.0 + + org.apache.maven.plugins.compiler.it + MCOMPILER-542 + 1.0-SNAPSHOT + ${java.specification.version} + + + UTF-8 + 2023-08-14T15:12:12Z + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + @project.version@ + + ${java.specification.version} + + + + + + diff --git a/src/it/MCOMPILER-542/src/main/java/module-info.java b/src/it/MCOMPILER-542/src/main/java/module-info.java new file mode 100644 index 00000000..cfa968a8 --- /dev/null +++ b/src/it/MCOMPILER-542/src/main/java/module-info.java @@ -0,0 +1,19 @@ +/* + * 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. + */ +module app {} diff --git a/src/it/MCOMPILER-542/src/main/java/org/maven/test/Main.java b/src/it/MCOMPILER-542/src/main/java/org/maven/test/Main.java new file mode 100644 index 00000000..8d175576 --- /dev/null +++ b/src/it/MCOMPILER-542/src/main/java/org/maven/test/Main.java @@ -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. + */ +package org.maven.test; + +public class Main { + + /** + * @param args + */ + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/src/it/MCOMPILER-542/verify.groovy b/src/it/MCOMPILER-542/verify.groovy new file mode 100644 index 00000000..0ac0a7d2 --- /dev/null +++ b/src/it/MCOMPILER-542/verify.groovy @@ -0,0 +1,30 @@ +/* + * 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 proc = 'javap -v target/classes/module-info.class'.execute(null,basedir) +def sout = new StringBuilder(), serr = new StringBuilder() +proc.consumeProcessOutput(sout, serr) +proc.waitForOrKill(1000) +def out = sout.toString() +println "javap -v target/classes/module-info.class>\n$out\nerr> $serr" + +def module = out.substring(out.indexOf('Module:')) +def javaVersion = System.getProperty('java.version') +assert module.contains('// "java.base" ACC_MANDATED') +assert !module.contains(javaVersion)