How to generate an aggregated scaladoc for a maven site?

前端 未结 1 1479
情书的邮戳
情书的邮戳 2021-02-05 16:59

I have a multi-module Maven build and I would like to generate an aggregated Scaladoc in my root module, similar to what the aggregate goal for the maven-javadoc-plugin does. My

相关标签:
1条回答
  • 2021-02-05 17:52

    This doesn't answer the question exactly as asked, but is a solution that may actually be preferred for mixed java/scala projects until ScalaDoc is capable of parsing JavaDoc comments. It produces a single aggregated JavaDoc that includes documentation from all of the project's Scala source files as well.

    The solution is simple: configure Maven to use the GenJavaDoc Scala compiler plugin so that ScalaDocs can be converted to JavaDocs. Then, use the normal javadoc:aggregate goal to aggregate the project as normal.

    Here is a sample Maven profile to do this. It configures the Scala compiler to generate the JavaDocs corresponding to the Scala sources, configures Maven to treat the genjavadoc directory created by the Scala compiler as a source directory, and then configures the javadoc plugin itself (this last may be optional if you have no special JavaDoc plugin configuration requirements).

    <profile>
      <id>javadoc</id>
      <build>
        <plugins>
          <plugin>
            <groupId>net.alchim31.maven</groupId>
            <artifactId>scala-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>doc</id>
                <phase>generate-sources</phase>
                <goals>
                  <goal>compile</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <args>
                <arg>-P:genjavadoc:out=${project.build.directory}/genjavadoc</arg>
              </args>
              <compilerPlugins>
                <compilerPlugin>
                  <groupId>com.typesafe.genjavadoc</groupId>
                  <artifactId>genjavadoc-plugin_${scala.binary.full.version}</artifactId>
                  <version>0.4</version>
                </compilerPlugin>
              </compilerPlugins>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <executions>
              <execution>
                <phase>generate-sources</phase>
                <goals>
                  <goal>add-source</goal>
                </goals>
                <configuration>
                  <sources>
                    <source>${project.build.directory}/genjavadoc</source>
                  </sources>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>2.9</version>
            <configuration>
              <minmemory>64m</minmemory>
              <maxmemory>2g</maxmemory>
              <outputDirectory>${project.build.directory}</outputDirectory>
              <detectLinks>true</detectLinks>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    
    0 讨论(0)
提交回复
热议问题