[MCOMPILER-481] compiler plugin should include static module for compilation (#82)
* [MCOMPILER-481] compiler plugin should include static module for compilation
* use plexus java 1.1.1
Signed-off-by: Olivier Lamy <olamy@apache.org>
diff --git a/pom.xml b/pom.xml
index 5e36508..a2dde74 100644
--- a/pom.xml
+++ b/pom.xml
@@ -72,7 +72,7 @@
<groovyVersion>2.4.21</groovyVersion>
<groovyEclipseCompilerVersion>3.7.0</groovyEclipseCompilerVersion>
<groovy-eclipse-batch>2.5.14-02</groovy-eclipse-batch>
- <plexus-java.version>1.1.0</plexus-java.version>
+ <plexus-java.version>1.1.1</plexus-java.version>
<javaVersion>8</javaVersion>
<maven.it.failure.ignore>false</maven.it.failure.ignore>
<surefire.version>2.22.2</surefire.version>
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 @@
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 @@
{
ResolvePathsRequest<String> request =
ResolvePathsRequest.ofStrings( testPath )
+ .setIncludeStatic( true )
.setMainModuleDescriptor( mainModuleDescriptorClassFile.getAbsolutePath() );
Toolchain toolchain = getToolchain();