diff --git a/src/it/modular-processor-shared-dep/annotation-user/pom.xml b/src/it/modular-processor-shared-dep/annotation-user/pom.xml
new file mode 100644
index 000000000..472236ec1
--- /dev/null
+++ b/src/it/modular-processor-shared-dep/annotation-user/pom.xml
@@ -0,0 +1,47 @@
+
+
+
+ 4.1.0
+
+ org.apache.maven.plugins.compiler.it
+ modular-processor-shared-dep
+ 1.0-SNAPSHOT
+
+ annotation-user
+
+
+
+ org.apache.maven.plugins.compiler.it
+ shared-lib
+ 1.0-SNAPSHOT
+ modular-jar
+
+
+ org.apache.maven.plugins.compiler.it
+ modular-processor
+ 1.0-SNAPSHOT
+ modular-processor
+
+
+
diff --git a/src/it/modular-processor-shared-dep/annotation-user/src/main/java/module-info.java b/src/it/modular-processor-shared-dep/annotation-user/src/main/java/module-info.java
new file mode 100644
index 000000000..86fda5a57
--- /dev/null
+++ b/src/it/modular-processor-shared-dep/annotation-user/src/main/java/module-info.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.
+ */
+module user.app {
+ requires shared.lib;
+}
diff --git a/src/it/modular-processor-shared-dep/annotation-user/src/main/java/user/SimpleAnnotation.java b/src/it/modular-processor-shared-dep/annotation-user/src/main/java/user/SimpleAnnotation.java
new file mode 100644
index 000000000..46baa6fef
--- /dev/null
+++ b/src/it/modular-processor-shared-dep/annotation-user/src/main/java/user/SimpleAnnotation.java
@@ -0,0 +1,28 @@
+/*
+ * 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 user;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.SOURCE)
+public @interface SimpleAnnotation {}
diff --git a/src/it/modular-processor-shared-dep/annotation-user/src/main/java/user/SimpleObject.java b/src/it/modular-processor-shared-dep/annotation-user/src/main/java/user/SimpleObject.java
new file mode 100644
index 000000000..e3fd2e594
--- /dev/null
+++ b/src/it/modular-processor-shared-dep/annotation-user/src/main/java/user/SimpleObject.java
@@ -0,0 +1,28 @@
+/*
+ * 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 user;
+
+import sharedlib.SharedUtil;
+
+@SimpleAnnotation
+public class SimpleObject {
+ public String hello() {
+ return SharedUtil.greet("world");
+ }
+}
diff --git a/src/it/modular-processor-shared-dep/invoker.properties b/src/it/modular-processor-shared-dep/invoker.properties
new file mode 100644
index 000000000..29d3dcf16
--- /dev/null
+++ b/src/it/modular-processor-shared-dep/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/modular-processor-shared-dep/modular-processor/pom.xml b/src/it/modular-processor-shared-dep/modular-processor/pom.xml
new file mode 100644
index 000000000..025882355
--- /dev/null
+++ b/src/it/modular-processor-shared-dep/modular-processor/pom.xml
@@ -0,0 +1,35 @@
+
+
+
+ 4.1.0
+
+ org.apache.maven.plugins.compiler.it
+ modular-processor-shared-dep
+ 1.0-SNAPSHOT
+
+ modular-processor
+
+
+ org.apache.maven.plugins.compiler.it
+ shared-lib
+ 1.0-SNAPSHOT
+
+
+
diff --git a/src/it/modular-processor-shared-dep/modular-processor/src/main/java/module-info.java b/src/it/modular-processor-shared-dep/modular-processor/src/main/java/module-info.java
new file mode 100644
index 000000000..447e7b671
--- /dev/null
+++ b/src/it/modular-processor-shared-dep/modular-processor/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 modular.processor {
+ requires shared.lib;
+ requires java.compiler;
+
+ provides javax.annotation.processing.Processor with
+ processor.SimpleProcessor;
+}
diff --git a/src/it/modular-processor-shared-dep/modular-processor/src/main/java/processor/SimpleProcessor.java b/src/it/modular-processor-shared-dep/modular-processor/src/main/java/processor/SimpleProcessor.java
new file mode 100644
index 000000000..c6ef709a2
--- /dev/null
+++ b/src/it/modular-processor-shared-dep/modular-processor/src/main/java/processor/SimpleProcessor.java
@@ -0,0 +1,43 @@
+/*
+ * 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 processor;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.TypeElement;
+
+import java.util.Set;
+
+import sharedlib.SharedUtil;
+
+@SupportedSourceVersion(SourceVersion.RELEASE_17)
+@SupportedAnnotationTypes("user.SimpleAnnotation")
+public class SimpleProcessor extends AbstractProcessor {
+ public SimpleProcessor() {}
+
+ @Override
+ public boolean process(Set extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ // Use SharedUtil to verify the transitive dependency is accessible.
+ SharedUtil.greet("test");
+ return false;
+ }
+}
diff --git a/src/it/modular-processor-shared-dep/pom.xml b/src/it/modular-processor-shared-dep/pom.xml
new file mode 100644
index 000000000..6fef7321a
--- /dev/null
+++ b/src/it/modular-processor-shared-dep/pom.xml
@@ -0,0 +1,48 @@
+
+
+
+ 4.1.0
+
+ org.apache.maven.plugins.compiler.it
+ modular-processor-shared-dep
+ 1.0-SNAPSHOT
+ pom
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ @project.version@
+
+ 17
+
+
+
+
+
+
+
+ shared-lib
+ modular-processor
+ annotation-user
+
+
diff --git a/src/it/modular-processor-shared-dep/shared-lib/pom.xml b/src/it/modular-processor-shared-dep/shared-lib/pom.xml
new file mode 100644
index 000000000..b27f1af43
--- /dev/null
+++ b/src/it/modular-processor-shared-dep/shared-lib/pom.xml
@@ -0,0 +1,28 @@
+
+
+
+ 4.1.0
+
+ org.apache.maven.plugins.compiler.it
+ modular-processor-shared-dep
+ 1.0-SNAPSHOT
+
+ shared-lib
+
diff --git a/src/it/modular-processor-shared-dep/shared-lib/src/main/java/module-info.java b/src/it/modular-processor-shared-dep/shared-lib/src/main/java/module-info.java
new file mode 100644
index 000000000..79f7a7a98
--- /dev/null
+++ b/src/it/modular-processor-shared-dep/shared-lib/src/main/java/module-info.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.
+ */
+module shared.lib {
+ exports sharedlib;
+}
diff --git a/src/it/modular-processor-shared-dep/shared-lib/src/main/java/sharedlib/SharedUtil.java b/src/it/modular-processor-shared-dep/shared-lib/src/main/java/sharedlib/SharedUtil.java
new file mode 100644
index 000000000..ff569eb17
--- /dev/null
+++ b/src/it/modular-processor-shared-dep/shared-lib/src/main/java/sharedlib/SharedUtil.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 sharedlib;
+
+public class SharedUtil {
+ public static String greet(String name) {
+ return "Hello, " + name;
+ }
+}
diff --git a/src/it/modular-processor-shared-dep/verify.groovy b/src/it/modular-processor-shared-dep/verify.groovy
new file mode 100644
index 000000000..a03826391
--- /dev/null
+++ b/src/it/modular-processor-shared-dep/verify.groovy
@@ -0,0 +1,23 @@
+/*
+ * 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 classFile = new File(basedir, 'annotation-user/target/classes/user/SimpleObject.class')
+assert classFile.exists() : "SimpleObject.class should have been compiled"
+
+def moduleInfo = new File(basedir, 'annotation-user/target/classes/module-info.class')
+assert moduleInfo.exists() : "module-info.class should have been compiled"
diff --git a/src/main/java/org/apache/maven/plugin/compiler/ToolExecutor.java b/src/main/java/org/apache/maven/plugin/compiler/ToolExecutor.java
index 907d32390..985662ef9 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/ToolExecutor.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/ToolExecutor.java
@@ -278,11 +278,42 @@ protected ToolExecutor(final AbstractCompilerMojo mojo, DiagnosticListener sup
dependencies.putAll(dependencyResolution.getDispatchedPaths());
}
mojo.resolveProcessorPathEntries(dependencies);
+ supplementProcessorModulePath();
mojo.amendincrementalCompilation(incrementalBuildConfig, dependencies.keySet());
generatedSourceDirectories = mojo.addGeneratedSourceDirectory(dependencies.keySet());
copyDependencyValues();
}
+ /**
+ * Ensures that modules on the {@code --processor-module-path} can resolve their dependencies.
+ * When a dependency appears both on the {@code --module-path} (as a direct project dependency)
+ * and as a transitive dependency of a processor module, the dependency resolver places it
+ * only on the {@code --module-path}. However, {@code javac} resolves the processor module
+ * layer independently, so the dependency must also appear on the {@code --processor-module-path}.
+ *
+ *
Note: this applies only to modular paths. For classpath-based processors, {@code javac}
+ * uses a single class loader that can see both the classpath and the processor path,
+ * so no supplementing is needed.
+ *
+ * @see Issue #1039
+ */
+ private void supplementProcessorModulePath() {
+ Collection processorModules = dependencies.get(JavaPathType.PROCESSOR_MODULES);
+ if (processorModules == null || processorModules.isEmpty()) {
+ return;
+ }
+ Collection modules = dependencies.get(JavaPathType.MODULES);
+ if (modules == null || modules.isEmpty()) {
+ return;
+ }
+ Deque supplemented = dependencies(JavaPathType.PROCESSOR_MODULES);
+ for (Path module : modules) {
+ if (!supplemented.contains(module)) {
+ supplemented.add(module);
+ }
+ }
+ }
+
/**
* Copies all values of the dependency map in unmodifiable lists.
* This is used for creating a snapshot of the current state of the dependency map.