选择性 Javadocs 报告

要有选择地运行 Javadocs 报告,您只需要包含您喜欢的 Javadocs 报告。如常见问题解答中所述,配置取决于使用的 <build/> 标签或 <reporting/> 标签。

使用 <build/> 标签

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.3.2</version>
        <configuration>
          <!-- Default configuration for all reports -->
          ...
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>javadoc</goal>
              <goal>test-javadoc</goal>
            </goals>
            <phase>site</phase>
            <configuration>
              <!-- Specific configuration for the given reports -->
              ...
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  ...
</project>

由于阶段是site,您需要调用mvn site来生成选定的报告(仅 main 和 test javadocs)。

使用 <reporting/> 标签

<project>
  ...
  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.3.2</version>
        <configuration>
          <!-- Default configuration for all reports -->
          ...
        </configuration>
        <reportSets>
          <reportSet>
            <id>default</id>
            <configuration>
              <!-- Specific configuration for the given reports -->
              ...
            </configuration>
            <reports>
              <report>javadoc</report>
              <report>test-javadoc</report>
            </reports>
          </reportSet>
          <reportSet>
            <id>aggregate</id>
            <configuration>
              <!-- Specific configuration for the given reports -->
              ...
            </configuration>
            <reports>
              <report>aggregate</report>
            </reports>
          </reportSet>
        </reportSets>
      </plugin>
    </plugins>
  </reporting>
  ...
</project>

只需调用mvn site即可生成选定的报告(主要、测试和聚合 javadocs)。