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

elharo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new afaca6fe [MJAVADOC-390] Collect reactor dependencies for detectLinks 
when aggregating (#1456)
afaca6fe is described below

commit afaca6fe0ef503164d44fa868b004f31cdbd7d97
Author: Arturo Bernal <[email protected]>
AuthorDate: Fri Nov 27 14:32:08 2026 +0100

    [MJAVADOC-390] Collect reactor dependencies for detectLinks when 
aggregating (#1456)
    
    getDependenciesLinks only read the execution root project's own 
dependencies, so when aggregating (javadoc:aggregate), a dependency declared 
only in a non-root reactor module never got a -link entry.
    
    Now it collects dependencies from every reactor project when isAggregator() 
is true, de-duplicated via a LinkedHashSet, and keeps the single-project 
behavior unchanged otherwise.
    
    Added a new IT (MJAVADOC-390_aggregate-detectLinks) with a dependency 
declared only in a non-root module, verified it fails on master and passes with 
the fix; confirmed no regression on the existing per-module detectLinks IT.
---
 .../invoker.properties                             | 18 ++++++
 .../module1/pom.xml                                | 35 +++++++++++
 .../src/main/java/com/mycompany/app/App.java       | 28 +++++++++
 .../module2/pom.xml                                | 45 +++++++++++++++
 .../src/main/java/com/mycompany/app2/App2.java     | 28 +++++++++
 .../MJAVADOC-390_aggregate-detectLinks/pom.xml     | 67 ++++++++++++++++++++++
 .../verify.groovy                                  | 47 +++++++++++++++
 .../maven/plugins/javadoc/AbstractJavadocMojo.java | 13 ++++-
 8 files changed, 279 insertions(+), 2 deletions(-)

diff --git 
a/src/it/projects/MJAVADOC-390_aggregate-detectLinks/invoker.properties 
b/src/it/projects/MJAVADOC-390_aggregate-detectLinks/invoker.properties
new file mode 100644
index 00000000..b2f6f55a
--- /dev/null
+++ b/src/it/projects/MJAVADOC-390_aggregate-detectLinks/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 = clean compile javadoc:aggregate
diff --git a/src/it/projects/MJAVADOC-390_aggregate-detectLinks/module1/pom.xml 
b/src/it/projects/MJAVADOC-390_aggregate-detectLinks/module1/pom.xml
new file mode 100644
index 00000000..2163f3c7
--- /dev/null
+++ b/src/it/projects/MJAVADOC-390_aggregate-detectLinks/module1/pom.xml
@@ -0,0 +1,35 @@
+<?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>
+
+  <parent>
+    <groupId>org.apache.maven.plugins.maven-javadoc-plugin.it</groupId>
+    <artifactId>mjavadoc390-parent</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <relativePath>../pom.xml</relativePath>
+  </parent>
+
+  <artifactId>mjavadoc390-module1</artifactId>
+  <packaging>jar</packaging>
+</project>
diff --git 
a/src/it/projects/MJAVADOC-390_aggregate-detectLinks/module1/src/main/java/com/mycompany/app/App.java
 
b/src/it/projects/MJAVADOC-390_aggregate-detectLinks/module1/src/main/java/com/mycompany/app/App.java
new file mode 100644
index 00000000..e90433e3
--- /dev/null
+++ 
b/src/it/projects/MJAVADOC-390_aggregate-detectLinks/module1/src/main/java/com/mycompany/app/App.java
@@ -0,0 +1,28 @@
+package com.mycompany.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.
+ */
+
+/** Module1 has no dependencies of its own. */
+public class App {
+    /** Prints a greeting. */
+    public static void main(String[] args) {
+        System.out.println("Hello World!");
+    }
+}
diff --git a/src/it/projects/MJAVADOC-390_aggregate-detectLinks/module2/pom.xml 
b/src/it/projects/MJAVADOC-390_aggregate-detectLinks/module2/pom.xml
new file mode 100644
index 00000000..9860577c
--- /dev/null
+++ b/src/it/projects/MJAVADOC-390_aggregate-detectLinks/module2/pom.xml
@@ -0,0 +1,45 @@
+<?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>
+
+  <parent>
+    <groupId>org.apache.maven.plugins.maven-javadoc-plugin.it</groupId>
+    <artifactId>mjavadoc390-parent</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <relativePath>../pom.xml</relativePath>
+  </parent>
+
+  <artifactId>mjavadoc390-module2</artifactId>
+  <packaging>jar</packaging>
+
+  <!-- Only this module declares this dependency: the parent (execution root 
for the aggregate goal)
+       and module1 do not. -->
+  <dependencies>
+    <dependency>
+      <groupId>commons-lang</groupId>
+      <artifactId>commons-lang</artifactId>
+      <version>2.4</version>
+    </dependency>
+  </dependencies>
+</project>
diff --git 
a/src/it/projects/MJAVADOC-390_aggregate-detectLinks/module2/src/main/java/com/mycompany/app2/App2.java
 
b/src/it/projects/MJAVADOC-390_aggregate-detectLinks/module2/src/main/java/com/mycompany/app2/App2.java
new file mode 100644
index 00000000..04c483b5
--- /dev/null
+++ 
b/src/it/projects/MJAVADOC-390_aggregate-detectLinks/module2/src/main/java/com/mycompany/app2/App2.java
@@ -0,0 +1,28 @@
+package com.mycompany.app2;
+
+/*
+ * 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.
+ */
+
+/** Module2 is the only module depending on commons-lang. */
+public class App2 {
+    /** Prints a greeting. */
+    public static void main(String[] args) {
+        System.out.println("Hello World 2!");
+    }
+}
diff --git a/src/it/projects/MJAVADOC-390_aggregate-detectLinks/pom.xml 
b/src/it/projects/MJAVADOC-390_aggregate-detectLinks/pom.xml
new file mode 100644
index 00000000..80bd2ca1
--- /dev/null
+++ b/src/it/projects/MJAVADOC-390_aggregate-detectLinks/pom.xml
@@ -0,0 +1,67 @@
+<?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.apache.maven.plugins.maven-javadoc-plugin.it</groupId>
+  <artifactId>mjavadoc390-parent</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <name>MJAVADOC-390</name>
+  <description>detectLinks=true must collect dependencies from every reactor 
module when aggregating, not only
+    the execution root project.</description>
+  <url>https://issues.apache.org/jira/browse/MJAVADOC-390</url>
+
+  <modules>
+    <module>module1</module>
+    <module>module2</module>
+  </modules>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <artifactId>maven-javadoc-plugin</artifactId>
+          <version>@project.version@</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-javadoc-plugin</artifactId>
+        <configuration>
+          <detectLinks>true</detectLinks>
+          <debug>true</debug>
+          <failOnError>false</failOnError>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/it/projects/MJAVADOC-390_aggregate-detectLinks/verify.groovy 
b/src/it/projects/MJAVADOC-390_aggregate-detectLinks/verify.groovy
new file mode 100644
index 00000000..9e46b2fd
--- /dev/null
+++ b/src/it/projects/MJAVADOC-390_aggregate-detectLinks/verify.groovy
@@ -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.
+ */
+
+import org.codehaus.plexus.util.FileUtils
+
+// MJAVADOC-390: javadoc:aggregate runs on the execution root project, but 
commons-lang is declared only
+// on module2. detectLinks must still pick up its link, not just the root's 
own (empty) dependency set.
+
+File options = new File(basedir, "target/reports/apidocs/options")
+if (!options.exists() || !options.isFile()) {
+    System.err.println(options.getAbsolutePath() + " file is missing or not a 
file.")
+    return false
+}
+
+String content = FileUtils.fileRead(options)
+String log = FileUtils.fileRead(new File(basedir, "build.log"))
+
+int link = content.indexOf("-link")
+if (link == -1) {
+    System.err.println("-link not added: " + options)
+    return false
+}
+
+if (!content.substring(link).contains("commons.apache.org")) {
+    System.err.println("link for commons-lang (declared only in module2) not 
added: " + options)
+    if (!log.contains("Error fetching link: 
http://commons.apache.org/lang/apidocs";)) {
+        return false
+    }
+}
+
+return true
diff --git 
a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java 
b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
index 22c9fcfc..696c0685 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
@@ -5384,7 +5384,7 @@ public abstract class AbstractJavadocMojo extends 
AbstractMojo {
      * Using Maven, a Javadoc link is given by 
<code>${project.url}/apidocs</code>.
      *
      * @return the detected Javadoc links using the Maven conventions for all 
dependencies defined in the current
-     *         project or an empty list.
+     *         project, or in every reactor project when aggregating, or an 
empty list.
      * @see #detectLinks
      * @see #isValidJavadocLink(String, boolean)
      * @since 2.6
@@ -5398,7 +5398,16 @@ public abstract class AbstractJavadocMojo extends 
AbstractMojo {
 
         List<String> dependenciesLinks = new ArrayList<>();
 
-        final Set<Artifact> dependencies = project.getDependencyArtifacts();
+        // An aggregator only resolves the execution root project's own 
dependencies, so a dependency
+        // declared solely in a non-root reactor module would otherwise never 
get a link.
+        final Set<Artifact> dependencies = new LinkedHashSet<>();
+        if (isAggregator()) {
+            for (MavenProject reactorProject : reactorProjects) {
+                dependencies.addAll(reactorProject.getDependencyArtifacts());
+            }
+        } else {
+            dependencies.addAll(project.getDependencyArtifacts());
+        }
         for (Artifact artifact : dependencies) {
             if (artifact.getFile() == null || !artifact.getFile().exists()) {
                 continue;

Reply via email to