如何在Maven中包含ScalaDoc选项

时间:2015-03-20 23:02:21

标签: scala maven scaladoc

我可以通过手动使用“scaladoc -diagrams ...”

来生成类层次结构图

我也可以通过“mvn scala:doc”

生成Maven的基本ScalaDoc

但是当我从Maven运行ScalaDoc时,我怎么能把“-diagrams”放进去?一般来说,我如何输入“scaladoc -help”中列出的任何选项。

我在我的pom.xml中有这个,但它不起作用。

        <plugin>
            <groupId>org.scala-tools</groupId>
            <artifactId>maven-scala-plugin</artifactId>
            <version>2.14-SNAPSHOT</version>
            <configuration>
                <args>
                    <arg>-diagrams</arg>
                </args>
            </configuration>
         </plugin>

更新

这也不起作用:

        <plugin>
            <groupId>org.scala-tools</groupId>
            <artifactId>maven-scala-plugin</artifactId>

            <executions>
                <execution>
                    <id>generate-scaladoc</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>doc</goal>
                    </goals>
                    <configuration>
                        <diagrams>true</diagrams>
                        <args>
                            <arg>-diagrams</arg>
                        </args>
                    </configuration>
                </execution>
            </executions>
      </plugin>

2 个答案:

答案 0 :(得分:0)

我还没试过这个,但一般来说,你可以添加executions元素来将目标绑定到特定的phase maven生命周期。查看结合java和scala项目的this example

            <executions>
                <execution>
                    <id>scala-doc</id>
                    <phase>process-resources</phase> <!-- or wherever -->
                    <goals>
                        <goal>doc</goal>
                    </goals>
                </execution>                                    
            </executions>

答案 1 :(得分:0)

我可以使用scala-maven-plugin's attach-javadocs 执行为scala maven项目生成Java-docs,如下所示:

                 <plugin>
                    <groupId>net.alchim31.maven</groupId>
                    <artifactId>scala-maven-plugin</artifactId>
                    <version>3.2.0</version>
                    <executions>
                        <execution>
                            <!-- this is so we don't end with a compile error in maven-compiler-plugin -->
                            <phase>process-sources</phase>
                            <goals>
                                <goal>compile</goal>
                                <goal>testCompile</goal>
                            </goals>
                            <configuration>
                            </configuration>
                        </execution>
                        <execution>
                            <id>attach-javadocs</id>
                            <goals>
                                <goal>doc-jar</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

添加上述指定的插件配置后,只需运行mvn clean install,它将生成javadoc的jar和源jar