如何为Maven站点生成汇总的Scaladoc? [英] How to generate an aggregated scaladoc for a maven site?

查看:95
本文介绍了如何为Maven站点生成汇总的Scaladoc?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个多模块Maven构建,我想在我的根模块中生成一个聚合的Scaladoc,类似于maven-javadoc-plugin的聚合目标.我的第一次尝试是:

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 first attempt was:

<project ...>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-site-plugin</artifactId>
                    <configuration>
                        <reportPlugins>
                            <plugin>
                                <artifactId>maven-project-info-reports-plugin</artifactId>
                            </plugin>
                            <plugin>
                                <groupId>net.alchim31.maven</groupId>
                                <artifactId>scala-maven-plugin</artifactId>
                                <reports>
                                    <report>doc</report>
                                </reports>
                                <configuration>
                                    <aggregateDirectOnly>false</aggregateDirectOnly>
                                    <sendJavaToScalac>false</sendJavaToScalac>
                                </configuration>
                            </plugin>
                            <plugin>
                                <artifactId>maven-javadoc-plugin</artifactId>
                                <reports>
                                    <report>aggregate</report>
                                </reports>
                            </plugin>
                        </reportPlugins>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>

但是,aggregateDirectOnly属性似乎没有任何作用.我总是只为单个jar型POM获得Scaladoc.

However, the aggregateDirectOnly property does not seem to have any effect. I always get the Scaladoc for the individual jar-type POMs only.

我还尝试将forceAggregate设置为true,但是也没有任何作用.

I also tried to set forceAggregate to true, but it had no effect, too.

该怎么做?

推荐答案

这不能完全正确地回答问题 ,但实际上是混合Java/scala项目首选的解决方案直到ScalaDoc能够解析JavaDoc注释.它会生成一个汇总的JavaDoc,其中还包括该项目所有Scala源文件中的文档.

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.

解决方案很简单:将Maven配置为使用 GenJavaDoc Scala编译器插件,以便可以转换ScalaDocs JavaDocs.然后,使用正常的javadoc:aggregate目标正常聚集项目.

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.

这里是一个示例Maven配置文件.它配置Scala编译器以生成与Scala源相对应的JavaDocs,配置Maven将Scala编译器创建的genjavadoc目录视为源目录,然后配置javadoc插件本身(如果您有没有特殊的JavaDoc插件配置要求.

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>

这篇关于如何为Maven站点生成汇总的Scaladoc?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆