配置自定义标签

您可以通过<taglet/><taglets/><tagletArtifacts/>参数在 Javadoc 插件配置中配置任何自定义小标签,具体取决于使用的小标签数量。

有关 taglet 技术的更多信息,请参阅http://docs.oracle.com/javase/7/docs/technotes/guides/javadoc/taglet/overview.html

一个标签

对于一个已知的 Taglet,只需使用<taglet/>参数:

<project>
  ...
  <reporting> (or <build>)
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.3.2</version>
        <configuration>
          ...
          <taglet>package.to.YourTagletClass</taglet>
          <!-- <tagletpath>/path/to/taglet.jar</tagletpath> -->
          <tagletArtifact>
            <groupId>group-Taglet</groupId>
            <artifactId>artifact-Taglet</artifactId>
            <version>version-Taglet</version>
          </tagletArtifact>
          ...
        </configuration>
      </plugin>
    </plugins>
    ...
  </reporting> (or </build>)
  ...
</project>

几个小标签

对于几个已知的 Taglets,只需使用<taglets/>参数:

<project>
  ...
  <reporting> (or <build>)
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.3.2</version>
        <configuration>
          ...
          <taglets>
            <taglet>
              <tagletClass>package.to.YourFirstTagletClass</tagletClass>
              <!-- <tagletpath>/path/to/taglet.jar</tagletpath> -->
              <tagletArtifact>
                <groupId>group-FirstTaglet</groupId>
                <artifactId>artifact-FirstTaglet</artifactId>
                <version>version-FirstTaglet</version>
              </tagletArtifact>
            </taglet>

            <taglet>
              <tagletClass>package.to.YourSecondTagletClass</tagletClass>
              <!-- <tagletpath>/path/to/taglet.jar</tagletpath> -->
              <tagletArtifact>
                <groupId>group-SecondTaglet</groupId>
                <artifactId>artifact-SecondTaglet</artifactId>
                <version>version-SecondTaglet</version>
              </tagletArtifact>
            </taglet>
            ...
          </taglets>
          ...
        </configuration>
      </plugin>
    </plugins>
    ...
  </reporting> (or </build>)
  ...
</project>

如果是同一个 Taglet 工件中的多个 Taglet,则可以使用<taglets/><tagletArtifact/>参数:

<project>
  ...
  <reporting> (or <build>)
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.3.2</version>
        <configuration>
          ...
          <taglets>
            <taglet>
              <tagletClass>package.to.YourFirstTagletClass</tagletClass>
            </taglet>

            <taglet>
              <tagletClass>package.to.YourSecondTagletClass</tagletClass>
            </taglet>
            ...
          </taglets>

          <tagletArtifact>
            <groupId>group-Taglet</groupId>
            <artifactId>artifact-Taglet</artifactId>
            <version>version-Taglet</version>
          </tagletArtifact>
          ...
        </configuration>
      </plugin>
    </plugins>
    ...
  </reporting> (or </build>)
  ...
</project>

如果你不知道 Taglet 或者你想自动检测 Taglet 类名,你可以使用<tagletArtifacts/>参数:

<project>
  ...
  <reporting> (or <build>)
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.3.2</version>
        <configuration>
          ...
          <tagletArtifacts>
            <tagletArtifact>
              <groupId>group-FirstTaglet</groupId>
              <artifactId>artifact-FirstTaglet</artifactId>
              <version>version-FirstTaglet</version>
            </tagletArtifact>

            <tagletArtifact>
              <groupId>group-SecondTaglet</groupId>
              <artifactId>artifact-SecondTaglet</artifactId>
              <version>version-SecondTaglet</version>
            </tagletArtifact>
            ...
          </tagletArtifacts>
          ...
        </configuration>
      </plugin>
    </plugins>
    ...
  </reporting> (or </build>)
  ...
</project>