diff --git a/src/it/MCOMPILER-372_modularized_testjar/invoker.properties b/src/it/MCOMPILER-372_modularized_testjar/invoker.properties
new file mode 100644
index 00000000..668d5c4c
--- /dev/null
+++ b/src/it/MCOMPILER-372_modularized_testjar/invoker.properties
@@ -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.
+
+## For remote debug
+#invoker.mavenOpts = -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+
+invoker.goals = clean test
diff --git a/src/it/MCOMPILER-372_modularized_testjar/pom.xml b/src/it/MCOMPILER-372_modularized_testjar/pom.xml
new file mode 100644
index 00000000..25536df4
--- /dev/null
+++ b/src/it/MCOMPILER-372_modularized_testjar/pom.xml
@@ -0,0 +1,56 @@
+
+
+
+
+ 4.0.0
+
+ org.apache.maven.plugins.compiler.it.372
+ mcompiler-372
+ 1.0-SNAPSHOT
+ pom
+
+
+ UTF-8
+
+
+
+ prj0
+ prj1
+ prj2
+ prj3
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ @project.version@
+
+ 11
+ 11
+
+
+
+
+
diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj0/pom.xml b/src/it/MCOMPILER-372_modularized_testjar/prj0/pom.xml
new file mode 100644
index 00000000..f0eb0dbc
--- /dev/null
+++ b/src/it/MCOMPILER-372_modularized_testjar/prj0/pom.xml
@@ -0,0 +1,132 @@
+
+
+
+
+ 4.0.0
+
+ This project tests a JAXB XSD to java test compilation
+
+
+ org.apache.maven.plugins.compiler.it.372
+ mcompiler-372
+ 1.0-SNAPSHOT
+
+
+ prj0-372
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.2.0
+
+
+
+ test-jar
+
+
+
+
+
+
+
+ org.codehaus.mojo
+ jaxb2-maven-plugin
+ 2.5.0
+
+
+
+
+ config
+
+ xjc
+
+
+
+
+ src/main/resources/prj0/Prj0Conf.xsd
+
+ prj0.conf
+ ${project.build.directory}/generated-sources/xjcConf
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ org.apache.logging.log4j
+ log4j-api
+ 2.12.1
+
+
+
+ org.apache.logging.log4j
+ log4j-core
+ 2.12.1
+
+
+
+
+ javax.xml.bind
+ jaxb-api
+ 2.3.1
+
+
+ com.sun.xml.bind
+ jaxb-core
+ 2.3.0.1
+
+
+ com.sun.xml.bind
+ jaxb-impl
+ 2.3.1
+
+
+
+ javax.activation
+ activation
+ 1.1.1
+
+
+
+ junit
+ junit
+ 3.8.2
+ test
+
+
+
+
+
diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/java/module-info.java b/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/java/module-info.java
new file mode 100644
index 00000000..2c1aba25
--- /dev/null
+++ b/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/java/module-info.java
@@ -0,0 +1,32 @@
+/*
+ * 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 prj0_372 {
+
+ exports prj0;
+
+ // For log4j
+ requires transitive org.apache.logging.log4j;
+
+ // For JAXB compilation
+ requires transitive java.xml;
+ requires transitive java.xml.bind;
+ requires transitive java.activation;
+
+}
\ No newline at end of file
diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/java/prj0/Dummy.java b/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/java/prj0/Dummy.java
new file mode 100644
index 00000000..a1311b39
--- /dev/null
+++ b/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/java/prj0/Dummy.java
@@ -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.
+ */
+
+package prj0;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+public class Dummy
+{
+
+ public static final Logger LOGGER = LogManager.getLogger( Dummy.class );
+
+}
diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/resources/prj0/Prj0Conf.xsd b/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/resources/prj0/Prj0Conf.xsd
new file mode 100644
index 00000000..b46e2eae
--- /dev/null
+++ b/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/resources/prj0/Prj0Conf.xsd
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj0/src/test/java/prj0/Prj0Test.java b/src/it/MCOMPILER-372_modularized_testjar/prj0/src/test/java/prj0/Prj0Test.java
new file mode 100644
index 00000000..84fa4071
--- /dev/null
+++ b/src/it/MCOMPILER-372_modularized_testjar/prj0/src/test/java/prj0/Prj0Test.java
@@ -0,0 +1,35 @@
+/*
+ * 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 prj0;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import junit.framework.TestCase;
+
+public class Prj0Test extends TestCase
+{
+
+ public static final Logger LOGGER = LogManager.getLogger( Prj0Test.class );
+
+ public void test() {
+
+ }
+
+}
diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj1/pom.xml b/src/it/MCOMPILER-372_modularized_testjar/prj1/pom.xml
new file mode 100644
index 00000000..174380ac
--- /dev/null
+++ b/src/it/MCOMPILER-372_modularized_testjar/prj1/pom.xml
@@ -0,0 +1,83 @@
+
+
+
+
+ 4.0.0
+
+
+ org.apache.maven.plugins.compiler.it.372
+ mcompiler-372
+ 1.0-SNAPSHOT
+
+
+ prj1-372
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.2.0
+
+
+
+ test-jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+ org.apache.logging.log4j
+ log4j-api
+ 2.12.1
+
+
+
+ org.apache.logging.log4j
+ log4j-core
+ 2.12.1
+
+
+
+
+ junit
+ junit
+ 3.8.2
+ test
+
+
+
+
+
+
diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj1/src/main/java/module-info.java b/src/it/MCOMPILER-372_modularized_testjar/prj1/src/main/java/module-info.java
new file mode 100644
index 00000000..f44230a6
--- /dev/null
+++ b/src/it/MCOMPILER-372_modularized_testjar/prj1/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 prj1_372 {
+
+ exports prj1;
+
+}
\ No newline at end of file
diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj1/src/main/java/prj1/Dummy.java b/src/it/MCOMPILER-372_modularized_testjar/prj1/src/main/java/prj1/Dummy.java
new file mode 100644
index 00000000..fe753214
--- /dev/null
+++ b/src/it/MCOMPILER-372_modularized_testjar/prj1/src/main/java/prj1/Dummy.java
@@ -0,0 +1,25 @@
+/*
+ * 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 prj1;
+
+public class Dummy
+{
+
+}
diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj1/src/test/java/prj1/Prj1Test.java b/src/it/MCOMPILER-372_modularized_testjar/prj1/src/test/java/prj1/Prj1Test.java
new file mode 100644
index 00000000..47178c96
--- /dev/null
+++ b/src/it/MCOMPILER-372_modularized_testjar/prj1/src/test/java/prj1/Prj1Test.java
@@ -0,0 +1,35 @@
+/*
+ * 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 prj1;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import junit.framework.TestCase;
+
+public class Prj1Test extends TestCase
+{
+
+ public static final Logger LOGGER = LogManager.getLogger( Prj1Test.class );
+
+ public void test() {
+
+ }
+
+}
diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj2/pom.xml b/src/it/MCOMPILER-372_modularized_testjar/prj2/pom.xml
new file mode 100644
index 00000000..121beb38
--- /dev/null
+++ b/src/it/MCOMPILER-372_modularized_testjar/prj2/pom.xml
@@ -0,0 +1,87 @@
+
+
+
+
+ 4.0.0
+
+
+ org.apache.maven.plugins.compiler.it.372
+ mcompiler-372
+ 1.0-SNAPSHOT
+
+
+ prj2-372
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.2.0
+
+
+
+ test-jar
+
+
+
+
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins.compiler.it.372
+ prj1-372
+ 1.0-SNAPSHOT
+
+
+
+
+ org.apache.maven.plugins.compiler.it.372
+ prj1-372
+ 1.0-SNAPSHOT
+ tests
+ test
+
+
+
+ junit
+ junit
+ 3.8.2
+ test
+
+
+
+
+
diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj2/src/main/java/module-info.java b/src/it/MCOMPILER-372_modularized_testjar/prj2/src/main/java/module-info.java
new file mode 100644
index 00000000..f338c8ca
--- /dev/null
+++ b/src/it/MCOMPILER-372_modularized_testjar/prj2/src/main/java/module-info.java
@@ -0,0 +1,26 @@
+/*
+ * 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 prj2_372 {
+
+ requires prj1_372;
+
+ exports prj2;
+
+}
\ No newline at end of file
diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj2/src/main/java/prj2/Dummy.java b/src/it/MCOMPILER-372_modularized_testjar/prj2/src/main/java/prj2/Dummy.java
new file mode 100644
index 00000000..d666a2bf
--- /dev/null
+++ b/src/it/MCOMPILER-372_modularized_testjar/prj2/src/main/java/prj2/Dummy.java
@@ -0,0 +1,25 @@
+/*
+ * 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 prj2;
+
+public class Dummy
+{
+
+}
diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj2/src/test/java/prj2/Prj2Test.java b/src/it/MCOMPILER-372_modularized_testjar/prj2/src/test/java/prj2/Prj2Test.java
new file mode 100644
index 00000000..c0434926
--- /dev/null
+++ b/src/it/MCOMPILER-372_modularized_testjar/prj2/src/test/java/prj2/Prj2Test.java
@@ -0,0 +1,41 @@
+/*
+ * 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 prj2;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import prj1.Prj1Test;
+
+public class Prj2Test extends Prj1Test
+{
+
+ public static final Logger LOGGER = LogManager.getLogger( Prj2Test.class );
+
+ public Prj2Test() {
+ super();
+ }
+
+ @Override
+ public void test() {
+
+ }
+
+}
diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj3/pom.xml b/src/it/MCOMPILER-372_modularized_testjar/prj3/pom.xml
new file mode 100644
index 00000000..52514c2f
--- /dev/null
+++ b/src/it/MCOMPILER-372_modularized_testjar/prj3/pom.xml
@@ -0,0 +1,74 @@
+
+
+
+
+ 4.0.0
+
+
+ org.apache.maven.plugins.compiler.it.372
+ mcompiler-372
+ 1.0-SNAPSHOT
+
+
+ prj3-372
+
+
+
+
+ org.apache.maven.plugins.compiler.it.372
+ prj2-372
+ 1.0-SNAPSHOT
+
+
+
+
+ org.apache.maven.plugins.compiler.it.372
+ prj2-372
+ 1.0-SNAPSHOT
+ tests
+ test
+
+
+
+ org.apache.maven.plugins.compiler.it.372
+ prj1-372
+ 1.0-SNAPSHOT
+ tests
+ test
+
+
+
+ junit
+ junit
+ 3.8.2
+ test
+
+
+
+
+
diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj3/src/main/java/module-info.java b/src/it/MCOMPILER-372_modularized_testjar/prj3/src/main/java/module-info.java
new file mode 100644
index 00000000..0da57e20
--- /dev/null
+++ b/src/it/MCOMPILER-372_modularized_testjar/prj3/src/main/java/module-info.java
@@ -0,0 +1,25 @@
+/*
+ * 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 prj3_372 {
+
+ requires prj1_372;
+ requires prj2_372;
+
+}
\ No newline at end of file
diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj3/src/main/java/prj3/Dummy.java b/src/it/MCOMPILER-372_modularized_testjar/prj3/src/main/java/prj3/Dummy.java
new file mode 100644
index 00000000..bc61e590
--- /dev/null
+++ b/src/it/MCOMPILER-372_modularized_testjar/prj3/src/main/java/prj3/Dummy.java
@@ -0,0 +1,25 @@
+/*
+ * 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 prj3;
+
+public class Dummy
+{
+
+}
diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj3/src/test/java/prj3/Prj3Test.java b/src/it/MCOMPILER-372_modularized_testjar/prj3/src/test/java/prj3/Prj3Test.java
new file mode 100644
index 00000000..0dac72f9
--- /dev/null
+++ b/src/it/MCOMPILER-372_modularized_testjar/prj3/src/test/java/prj3/Prj3Test.java
@@ -0,0 +1,47 @@
+/*
+ * 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 prj3;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import prj1.Prj1Test;
+import prj2.Prj2Test;
+
+/**
+ * We want to test that import of 2 levels of modularized test projects is OK
+ */
+public class Prj3Test extends Prj2Test
+{
+
+ public static final Logger LOGGER = LogManager.getLogger( Prj3Test.class );
+
+ private Prj1Test prj1Test = new Prj1Test();
+
+ public Prj3Test() {
+ super();
+ }
+
+ @Override
+ public void test() {
+
+ }
+
+}
diff --git a/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java b/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
index b199e24d..371385c1 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
@@ -488,6 +488,12 @@ public abstract class AbstractCompilerMojo extends AbstractMojo {
@Parameter(defaultValue = "${project}", readonly = true, required = true)
private MavenProject project;
+ /**
+ * Reactor projects list
+ */
+ @Parameter( defaultValue = "${reactorProjects}", readonly = true, required = true )
+ private List reactorProjects;
+
/**
* Strategy to re use javacc class created:
*
@@ -1696,6 +1702,10 @@ public void setRelease(String release) {
targetOrReleaseSet = true;
}
+ public List getReactorProjects() {
+ return reactorProjects;
+ }
+
final String getImplicit() {
return implicit;
}
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 4bbdc7e0..60f8f826 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java
@@ -32,11 +32,13 @@
import java.util.Map.Entry;
import java.util.Set;
+import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.apache.maven.project.MavenProject;
import org.apache.maven.shared.utils.StringUtils;
import org.apache.maven.toolchain.Toolchain;
import org.apache.maven.toolchain.java.DefaultJavaToolChain;
@@ -45,6 +47,7 @@
import org.codehaus.plexus.compiler.util.scan.StaleSourceScanner;
import org.codehaus.plexus.languages.java.jpms.JavaModuleDescriptor;
import org.codehaus.plexus.languages.java.jpms.LocationManager;
+import org.codehaus.plexus.languages.java.jpms.ModuleNameSource;
import org.codehaus.plexus.languages.java.jpms.ResolvePathsRequest;
import org.codehaus.plexus.languages.java.jpms.ResolvePathsResult;
@@ -350,27 +353,218 @@ protected void preparePaths(Set sourceFiles) {
if (compilerArgs == null) {
compilerArgs = new ArrayList<>();
}
- compilerArgs.add("--patch-module");
-
- StringBuilder patchModuleValue = new StringBuilder(mainModuleDescriptor.name())
- .append('=')
- .append(mainOutputDirectory)
- .append(PS);
- for (String root : compileSourceRoots) {
- patchModuleValue.append(root).append(PS);
- }
-
- compilerArgs.add(patchModuleValue.toString());
+ // Patch module to add
+ LinkedHashMap> patchModules = new LinkedHashMap<>();
+
+ List mainModulePaths = new ArrayList<>();
+ // Add main output dir
+ mainModulePaths.add(mainOutputDirectory.getAbsolutePath());
+ // Add source roots
+ mainModulePaths.addAll(compileSourceRoots);
+ patchModules.put(mainModuleDescriptor.name(), mainModulePaths);
+
+ // Main module detected, modularized test dependencies must augment patch modules
+ patchModulesForTestDependencies(
+ mainModuleDescriptor.name(), mainOutputDirectory.getAbsolutePath(),
+ patchModules
+ );
+
+ for (Entry> patchModuleEntry: patchModules.entrySet()) {
+ compilerArgs.add("--patch-module");
+ StringBuilder patchModuleValue = new StringBuilder(patchModuleEntry.getKey())
+ .append('=');
+
+ for (String path : patchModuleEntry.getValue()) {
+ patchModuleValue.append(path).append(PS);
+ }
+
+ compilerArgs.add(patchModuleValue.toString());
+ }
+
compilerArgs.add("--add-reads");
compilerArgs.add(mainModuleDescriptor.name() + "=ALL-UNNAMED");
} else {
modulepathElements = Collections.emptyList();
classpathElements = testPath;
}
+
+ }
+ }
+
+ /**
+ * Compiling with test classpath is not sufficient because some dependencies
+ * may be modularized and their test class path addition would be ignored.
+ * Example from MCOMPILER-372_modularized_test:
+ * prj2 test classes depend on prj1 classes and test classes
+ * As prj1.jar is added as a module, pjr1-tests.jar classes are ignored if we add jar class path
+ * We have to add pjr1-tests.jar as --patch-module
+ * @param mainModuleName
+ * param mainModuleTarget
+ * @param patchModules map of module names -> list of paths to add to --patch-module option
+ *
+ */
+ protected void patchModulesForTestDependencies(
+ String mainModuleName, String mainModuleTarget,
+ LinkedHashMap> patchModules
+ ) {
+ File mainModuleDescriptorClassFile = new File(mainModuleTarget, "module-info.class");
+
+ ResolvePathsResult result;
+
+ try {
+ // Get compile path information to identify modularized compile path elements
+ Collection dependencyArtifacts = getCompileClasspathElements(getProject());
+
+ ResolvePathsRequest request =
+ ResolvePathsRequest.ofFiles(dependencyArtifacts)
+ .setMainModuleDescriptor(mainModuleDescriptorClassFile);
+
+ Toolchain toolchain = getToolchain();
+ if (toolchain instanceof DefaultJavaToolChain) {
+ request.setJdkHome(new File(((DefaultJavaToolChain) toolchain).getJavaHome()));
+ }
+
+ result = locationManager.resolvePaths(request);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+
+ // Prepare a path list containing test paths for modularized paths
+ // This path list will augment modules to be able to compile
+ List listModuleTestPaths = new ArrayList<>(testPath.size());
+
+ // Browse modules
+ for (Entry pathElt : result.getModulepathElements().entrySet()) {
+
+ File modulePathElt = pathElt.getKey();
+
+ // Get module name
+ JavaModuleDescriptor moduleDesc = result.getPathElements().get( modulePathElt );
+ String moduleName = (moduleDesc != null) ? moduleDesc.name() : null;
+
+ if (
+ // Is it a modularized compile elements?
+ ( modulePathElt != null ) && ( moduleName != null )
+ &&
+ // Is it different from main module name
+ !mainModuleName.equals( moduleName )
+ ) {
+
+ // Get test path element
+ File moduleTestPathElt = getModuleTestPathElt(modulePathElt);
+
+ if (moduleTestPathElt != null) {
+ listModuleTestPaths.add(moduleTestPathElt.getAbsolutePath());
+ }
+ }
+ }
+
+ // Remove main target path
+ listModuleTestPaths.remove(mainModuleTarget);
+ listModuleTestPaths.remove(outputDirectory.getAbsolutePath());
+
+ // Freeze list
+ listModuleTestPaths = Collections.unmodifiableList(listModuleTestPaths);
+
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("patchModule test paths:");
+ for (String moduleTestPath : listModuleTestPaths) {
+ getLog().debug(" " + moduleTestPath);
+ }
+
+ }
+
+ // Get modularized dependencies resolved before
+ for (Entry pathElt : result.getModulepathElements().entrySet()) {
+ File path = pathElt.getKey();
+
+ // Get module name
+ JavaModuleDescriptor moduleDesc = result.getPathElements().get(path);
+ String moduleName = (moduleDesc != null) ? moduleDesc.name() : null;
+
+ if (
+ // Is it a modularized compile elements?
+ ( path != null ) && ( moduleName != null )
+ &&
+ // Not an auto-module
+ !moduleDesc.isAutomatic()
+ &&
+ // Is it different from main module name
+ !mainModuleName.equals( moduleName )
+ ) {
+
+ // Add --add-reads =ALL-UNNAMED
+ compilerArgs.add( "--add-reads" );
+ StringBuilder sbAddReads = new StringBuilder();
+ sbAddReads.append(moduleName).append("=ALL-UNNAMED");
+ compilerArgs.add(sbAddReads.toString());
+
+ // Add compile classpath if needed
+ if (!listModuleTestPaths.isEmpty()) {
+ // Yes, add it as patch module
+ List listPath = patchModules.get(moduleName);
+ // Make sure it is initialized
+ if (listPath == null) {
+ listPath = new ArrayList<>();
+ patchModules.put(moduleName, listPath);
+ }
+
+ // Add test compile path but not main module target
+ listPath.addAll(listModuleTestPaths);
+ }
+ }
+ }
+
+ if (pathElements == null) {
+ pathElements = new LinkedHashMap<>(result.getPathElements().size());
+ for (Entry entry : result.getPathElements().entrySet()) {
+ pathElements.put(entry.getKey().getAbsolutePath(), entry.getValue());
+ }
}
}
+ /**
+ * Get module test path element from module path element
+ * @param modulePathElt
+ * @return
+ */
+ protected File getModuleTestPathElt(File modulePathElt) {
+ // Get test path from reactor projects
+ File result = getModuleTestPathEltFromReactorProjects(modulePathElt);
+ return result;
+
+ }
+
+ protected File getModuleTestPathEltFromReactorProjects(File modulePathElt) {
+ File result = null;
+
+ // Get reactor projects
+ List reactorProjects = getReactorProjects();
+
+ // Find project matching module path
+ for (MavenProject reactorProject : reactorProjects) {
+ // Get build folder
+ File reactorProjectBuildFolder = new File(reactorProject.getBuild().getOutputDirectory());
+
+ // Same as module path element?
+ if (modulePathElt.equals(reactorProjectBuildFolder)) {
+ // Yes, get test build folder
+ result = new File(reactorProject.getBuild().getTestOutputDirectory());
+ // Loop is finished
+ break;
+ }
+
+ }
+
+ // Last check : result (directory or file) exists?
+ if ((result != null) && !result.exists()) {
+ result = null;
+ }
+
+ return result;
+ }
+
protected SourceInclusionScanner getSourceInclusionScanner(int staleMillis) {
SourceInclusionScanner scanner;
@@ -453,4 +647,14 @@ protected Set getIncludes() {
protected Set getExcludes() {
return testExcludes;
}
+
+ private List getCompileClasspathElements(MavenProject project) {
+ // 3 is outputFolder + 2 reserved for multirelease
+ List list = new ArrayList<>(project.getArtifacts().size() + 3);
+ list.add(new File(project.getBuild().getOutputDirectory()));
+ for (Artifact a : project.getArtifacts()) {
+ list.add(a.getFile());
+ }
+ return list;
+ }
}