编程语言
首页 > 编程语言> > 使用Javadocs的Maven多模块项目站点

使用Javadocs的Maven多模块项目站点

作者:互联网

我想使用Maven为我的应用程序创建网站.这是一个多模块应用程序,父模块是简单站点模块,第一个子模块是应用程序的核心,第二个子模块是GUI(Swing).

我现在对父pom.xml使用关注

<modules>
    <module>core</module>
    <module>kayako-desktop</module>
</modules>
<build>
    <plugins>
        <plugin>
            <artifactId>maven-site-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <locales>en</locales>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>2.7</version>
            <executions>
                <execution>
                    <phase>install</phase>
                    <goals>
                        <goal>aggregate</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
<reporting>
    <plugins>
        <plugin>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>2.7</version>
            <configuration>
                <aggregate>true</aggregate>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-changes-plugin</artifactId>
            <version>2.4</version>
        </plugin>
    </plugins>
</reporting>

我核心的pom:

<build>
    <plugins>
        <plugin>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>2.7</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <id>attach-javadocs</id>
                    <goals>
                        <goal>jar</goal>
                        <goal>javadoc</goal>
                    </goals>
                </execution>

            </executions>
        </plugin>
    </plugins>
</build>
<reporting>
    <plugins>
        <plugin>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>2.7</version>
            <configuration>
                <links>
                    <link>http://download.oracle.com/javase/6/docs/api/</link>
                </links>    
            </configuration>
        </plugin>    
    </plugins>

</reporting>

(我从两者中都删除了不相关的部分)

问题:我尝试了mvn site:stage,但未从核心模块中收集javadoc.我怎么了

解决方法:

在< reportPlugins>中配置javadoc插件. maven-site-plugin的配置部分,在父pom中.

这对我有用.

在父pom中:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-site-plugin</artifactId>
            <version>3.3</version>
            <configuration>
                <reportPlugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>2.9</version>
                        <reportSets>
                            <reportSet>
                                <id>aggregate</id>
                                <reports>
                                    <report>aggregate</report>
                                </reports>
                            </reportSet>
                        </reportSets>
                        <configuration>
                        <!-- Here you can add special configurations for your javadoc, if needed -->
                        </configuration>
                    </plugin>
                    <!-- Here you can also configure more report plugins -->
                    <!-- for your site, such as maven-project-info-reports-plugin -->
                </reportPlugins>
            </configuration>
        </plugin>
    <!-- ... -->
    </plugins>
</build>
<!-- ... -->
<distributionManagement>
    <site>
        <id>website</id>
        <url>http://site.url/can/be/tentative/or/hypothetical</url>
    </site>
</distributionManagement>

在每个子poms中,您还可以配置站点插件的特定报告,例如,surefire测试报告或项目信息.但是,您无需在此放置任何javadoc插件配置(除非您还希望子模块使用非聚合的javadocs).

然后,您应该能够从父目录执行mvn site site:stage.要查看汇总的Javadocs,请将浏览器指向该目录中的target / staging / index.html,然后在页面左侧的索引中单击“项目报告”,然后单击“ JavaDocs”.

附加提示:

有时,我想快速查看汇总的javadocs,而不必做一个整个站点site:stage,这会做更多的事情并且需要更长的时间.因此,我还直接在< plugin>中包含了maven-javadoc-plugin的配置.父pom的部分.这样,我可以运行mvn javadoc:aggregate并快速在target / site / apidocs / index.html中获取聚集的javadocs.

标签:maven-2,javadoc,maven-javadoc-plugin,maven-site-plugin,java
来源: https://codeday.me/bug/20191208/2091444.html