You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2022/01/19 21:46:42 UTC

[maven-compiler-plugin] branch MCOMPILER-481-requires-static-included created (now 3ab981e)

This is an automated email from the ASF dual-hosted git repository.

olamy pushed a change to branch MCOMPILER-481-requires-static-included
in repository https://gitbox.apache.org/repos/asf/maven-compiler-plugin.git.


      at 3ab981e  [MCOMPILER-481] compiler plugin should include static module for compilation

This branch includes the following new commits:

     new 3ab981e  [MCOMPILER-481] compiler plugin should include static module for compilation

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[maven-compiler-plugin] 01/01: [MCOMPILER-481] compiler plugin should include static module for compilation

Posted by ol...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

olamy pushed a commit to branch MCOMPILER-481-requires-static-included
in repository https://gitbox.apache.org/repos/asf/maven-compiler-plugin.git

commit 3ab981ebe9e6d08c2c546cd2d452cbdb1725980d
Author: Olivier Lamy <ol...@apache.org>
AuthorDate: Thu Jan 20 07:46:20 2022 +1000

    [MCOMPILER-481] compiler plugin should include static module for compilation
    
    Signed-off-by: Olivier Lamy <ol...@apache.org>
---
 .../app/pom.xml                                    | 53 +++++++++++++++++++++
 .../app/src/main/java/module-info.java             | 24 ++++++++++
 .../app/src/main/java/org/test/app/Main.java       | 24 ++++++++++
 .../app/src/test/java/org/test/app/MainTest.java   | 34 +++++++++++++
 .../invoker.properties                             | 19 ++++++++
 .../MCOMPILER-481-requires-static-included/pom.xml | 55 ++++++++++++++++++++++
 .../service/pom.xml                                | 40 ++++++++++++++++
 .../service/src/main/java/module-info.java         | 24 ++++++++++
 .../main/java/org/test/service/JSONService.java    | 27 +++++++++++
 .../src/main/java/org/test/service/Service.java    | 24 ++++++++++
 .../apache/maven/plugin/compiler/CompilerMojo.java |  1 +
 .../maven/plugin/compiler/TestCompilerMojo.java    |  1 +
 12 files changed, 326 insertions(+)

diff --git a/src/it/MCOMPILER-481-requires-static-included/app/pom.xml b/src/it/MCOMPILER-481-requires-static-included/app/pom.xml
new file mode 100644
index 0000000..7ff0fc7
--- /dev/null
+++ b/src/it/MCOMPILER-481-requires-static-included/app/pom.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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/xsd/maven-4.0.0.xsd">
+  <parent>
+    <groupId>org.example</groupId>
+    <artifactId>compiler-bug</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>compiler-bug-app</artifactId>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.example</groupId>
+      <artifactId>compiler-bug-service</artifactId>
+      <version>1.0-SNAPSHOT</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-util-ajax</artifactId>
+      <version>10.0.7</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-api</artifactId>
+      <version>5.8.2</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+</project>
diff --git a/src/it/MCOMPILER-481-requires-static-included/app/src/main/java/module-info.java b/src/it/MCOMPILER-481-requires-static-included/app/src/main/java/module-info.java
new file mode 100644
index 0000000..55d66f8
--- /dev/null
+++ b/src/it/MCOMPILER-481-requires-static-included/app/src/main/java/module-info.java
@@ -0,0 +1,24 @@
+/*
+ * 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 compiler.bug.app {
+    exports org.test.app;
+
+    requires compiler.bug.service;
+}
diff --git a/src/it/MCOMPILER-481-requires-static-included/app/src/main/java/org/test/app/Main.java b/src/it/MCOMPILER-481-requires-static-included/app/src/main/java/org/test/app/Main.java
new file mode 100644
index 0000000..6debb0c
--- /dev/null
+++ b/src/it/MCOMPILER-481-requires-static-included/app/src/main/java/org/test/app/Main.java
@@ -0,0 +1,24 @@
+package org.test.app;
+
+/*
+ * 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.
+ */
+
+public class Main
+{
+}
diff --git a/src/it/MCOMPILER-481-requires-static-included/app/src/test/java/org/test/app/MainTest.java b/src/it/MCOMPILER-481-requires-static-included/app/src/test/java/org/test/app/MainTest.java
new file mode 100644
index 0000000..9c220a8
--- /dev/null
+++ b/src/it/MCOMPILER-481-requires-static-included/app/src/test/java/org/test/app/MainTest.java
@@ -0,0 +1,34 @@
+package org.test.app;
+
+/*
+ * 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.
+ */
+
+import org.eclipse.jetty.util.ajax.JSON;
+import org.junit.jupiter.api.Test;
+import org.test.service.JSONService;
+
+public class MainTest
+{
+    @Test
+    public void test()
+    {
+        JSON json = new JSONService().json;
+        System.err.println("json = " + json);
+    }
+}
diff --git a/src/it/MCOMPILER-481-requires-static-included/invoker.properties b/src/it/MCOMPILER-481-requires-static-included/invoker.properties
new file mode 100644
index 0000000..7782ffb
--- /dev/null
+++ b/src/it/MCOMPILER-481-requires-static-included/invoker.properties
@@ -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.
+
+invoker.goals = clean install 
+invoker.java.version = 11+
diff --git a/src/it/MCOMPILER-481-requires-static-included/pom.xml b/src/it/MCOMPILER-481-requires-static-included/pom.xml
new file mode 100644
index 0000000..a395992
--- /dev/null
+++ b/src/it/MCOMPILER-481-requires-static-included/pom.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.example</groupId>
+  <artifactId>compiler-bug</artifactId>
+  <packaging>pom</packaging>
+  <version>1.0-SNAPSHOT</version>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <modules>
+    <module>service</module>
+    <module>app</module>
+  </modules>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <version>@project.version@</version>
+          <configuration>
+            <source>11</source>
+            <target>11</target>
+            <release>11</release>
+          </configuration>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+
+</project>
diff --git a/src/it/MCOMPILER-481-requires-static-included/service/pom.xml b/src/it/MCOMPILER-481-requires-static-included/service/pom.xml
new file mode 100644
index 0000000..0da930e
--- /dev/null
+++ b/src/it/MCOMPILER-481-requires-static-included/service/pom.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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/xsd/maven-4.0.0.xsd">
+  <parent>
+    <groupId>org.example</groupId>
+    <artifactId>compiler-bug</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>compiler-bug-service</artifactId>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.eclipse.jetty</groupId>
+      <artifactId>jetty-util-ajax</artifactId>
+      <version>10.0.7</version>
+      <optional>true</optional>
+    </dependency>
+  </dependencies>
+</project>
diff --git a/src/it/MCOMPILER-481-requires-static-included/service/src/main/java/module-info.java b/src/it/MCOMPILER-481-requires-static-included/service/src/main/java/module-info.java
new file mode 100644
index 0000000..4eb04d9
--- /dev/null
+++ b/src/it/MCOMPILER-481-requires-static-included/service/src/main/java/module-info.java
@@ -0,0 +1,24 @@
+/*
+ * 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 compiler.bug.service {
+    exports org.test.service;
+
+    requires static org.eclipse.jetty.util.ajax;
+}
diff --git a/src/it/MCOMPILER-481-requires-static-included/service/src/main/java/org/test/service/JSONService.java b/src/it/MCOMPILER-481-requires-static-included/service/src/main/java/org/test/service/JSONService.java
new file mode 100644
index 0000000..0bca3de
--- /dev/null
+++ b/src/it/MCOMPILER-481-requires-static-included/service/src/main/java/org/test/service/JSONService.java
@@ -0,0 +1,27 @@
+package org.test.service;
+
+/*
+ * 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.
+ */
+
+import org.eclipse.jetty.util.ajax.JSON;
+
+public class JSONService extends Service
+{
+    public final JSON json = new JSON();
+}
diff --git a/src/it/MCOMPILER-481-requires-static-included/service/src/main/java/org/test/service/Service.java b/src/it/MCOMPILER-481-requires-static-included/service/src/main/java/org/test/service/Service.java
new file mode 100644
index 0000000..69b865f
--- /dev/null
+++ b/src/it/MCOMPILER-481-requires-static-included/service/src/main/java/org/test/service/Service.java
@@ -0,0 +1,24 @@
+package org.test.service;
+
+/*
+ * 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.
+ */
+
+public abstract class Service
+{
+}
diff --git a/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java b/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
index 7cb94f2..182ec43 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
@@ -231,6 +231,7 @@ public class CompilerMojo
                 
                 ResolvePathsRequest<File> request =
                     ResolvePathsRequest.ofFiles( dependencyArtifacts )
+                                       .setIncludeStatic( true )
                                        .setMainModuleDescriptor( moduleDescriptorPath );
                 
                 Toolchain toolchain = getToolchain();
diff --git a/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java b/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java
index 9430ac2..b1c0b7c 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java
@@ -233,6 +233,7 @@ public class TestCompilerMojo
             {
                 ResolvePathsRequest<String> request =
                         ResolvePathsRequest.ofStrings( testPath )
+                                .setIncludeStatic( true )
                                 .setMainModuleDescriptor( mainModuleDescriptorClassFile.getAbsolutePath() );
 
                 Toolchain toolchain = getToolchain();