HDDS-13144. Fix mvn javadoc:aggregate goal. (#8891)

Co-authored-by: Wei-Chiu Chuang <weichiu@apache.org>
diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml
index 089766b..c2d9e39 100644
--- a/.github/workflows/check.yml
+++ b/.github/workflows/check.yml
@@ -254,7 +254,9 @@
         uses: actions/upload-artifact@v4
         with:
           name: ${{ (inputs.split && format('{0}-{1}', inputs.script, inputs.split)) || inputs.script }}
-          path: target/${{ inputs.script }}
+          path: |
+            target/${{ inputs.script }}
+            target/reports/apidocs
         continue-on-error: true
 
       # The following steps are hard-coded to be run only for 'build' check,
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index e8477c9..90a2ed5 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -199,6 +199,19 @@
       sha: ${{ needs.build-info.outputs.sha }}
       timeout-minutes: 15
 
+  javadoc:
+    needs:
+      - build-info
+      - build
+    uses: ./.github/workflows/check.yml
+    secrets: inherit
+    with:
+      java-version: ${{ needs.build-info.outputs.java-version }}
+      needs-ozone-repo: true
+      script: javadoc
+      sha: ${{ needs.build-info.outputs.sha }}
+      timeout-minutes: 30
+
   repro:
     needs:
       - build-info
diff --git a/hadoop-ozone/csi/pom.xml b/hadoop-ozone/csi/pom.xml
index e3da207..df81c78 100644
--- a/hadoop-ozone/csi/pom.xml
+++ b/hadoop-ozone/csi/pom.xml
@@ -27,6 +27,7 @@
 
   <properties>
     <classpath.skip>false</classpath.skip>
+    <maven.javadoc.skip>true</maven.javadoc.skip>
     <!-- no tests in this module so far -->
     <maven.test.skip>true</maven.test.skip>
   </properties>
diff --git a/hadoop-ozone/dev-support/checks/javadoc.sh b/hadoop-ozone/dev-support/checks/javadoc.sh
new file mode 100755
index 0000000..fa1bfcc
--- /dev/null
+++ b/hadoop-ozone/dev-support/checks/javadoc.sh
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+# 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.
+
+set -e
+
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+cd "$DIR/../../.." || exit 1
+
+mvn javadoc:aggregate
diff --git a/hadoop-ozone/mini-cluster/pom.xml b/hadoop-ozone/mini-cluster/pom.xml
index 6f65052..b5c2ff6 100644
--- a/hadoop-ozone/mini-cluster/pom.xml
+++ b/hadoop-ozone/mini-cluster/pom.xml
@@ -25,6 +25,10 @@
   <name>Apache Ozone Mini Cluster</name>
   <description>Apache Ozone Mini Cluster for Integration Tests</description>
 
+  <properties>
+    <maven.javadoc.skip>true</maven.javadoc.skip>
+  </properties>
+
   <dependencies>
     <dependency>
       <groupId>com.google.guava</groupId>
diff --git a/pom.xml b/pom.xml
index e6436fe..2f68506 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1851,6 +1851,11 @@
           <artifactId>maven-javadoc-plugin</artifactId>
           <version>${maven-javadoc-plugin.version}</version>
           <configuration>
+            <excludePackageNames>org.apache.hadoop.hdds.protocol.datanode.proto:org.apache.hadoop.hdds.protocol.proto:org.apache.hadoop.hdds.protocol.proto3:org.apache.hadoop.hdds.protocol.scm.proto:org.apache.hadoop.ozone.protocol.proto:org.apache.hadoop.ozone.protocol.proto3:org.apache.hadoop.ozone.security.proto:org.apache.hadoop.ozone.security.proto3:org.apache.hadoop.ozone.storage.proto:org.apache.ozone.recon.schema.generated:org.apache.ozone.recon.schema.generated.tables</excludePackageNames>
+            <sourceFileExcludes>
+              <exclude>**/package-info.java</exclude>
+              <exclude>**/org/apache/ozone/recon/schema/generated/tables/**/*.java</exclude>
+            </sourceFileExcludes>
             <doclint>none</doclint>
             <notimestamp>true</notimestamp>
           </configuration>