3

我目前正在使用 Maven 3 使用maven-site-plugin 。

该插件按预期生成所有报告,但由于我的项目布局(如下所示),显示的主站点不显示报告。谁能建议我们如何共享内容或添加链接以显示如何将链接放入 site.xml 以显示内容。谢谢

site\site.xml 文件如下所示。

<project name="MyProject">
    <body>`enter code here`
        <links>
            <item name="My Site" href="http://hp.com" /> 
        </links>
        <menu name="Projects" inherit="top"> 
            <item name="Description and Usage" href="index.html"/>
            <item name="Goals" href="plugin-info.html"/>
            <item name="Usage" href="usage.html"/>
            <item name="FAQ" href="faq.html"/>          
        </menu>
        <menu ref="reports"/>       
    </body>
</project>

运行该站点没有问题,该站点出现,但没有任何链接起作用,并且报告不可见。我认为这是因为我的项目设置不标准。我有以下设置

PARENT_PROJECT
-pom.xml (this is where maven-site-plugin is defined and used)
-src
   site
       site.xml
-target (all reports are here inc a index.html)
---x EAR Project
     pom.xml
     target (all reports are here inc a index.html)
---x WEBAPP Project
     pom.xml
     target (all reports are here inc a index.html)
---x JAR Project
     pom.xml
     target (all reports are here inc a index.html)

出于某种未知原因,当我运行 site:run 并输入“localhost:8080”时,EAR\target\index.html 中的 index.html 出现了,而不是 PARENT_PROJECT\target\index.html 文件?

请注意, mvn:site 是从 PARENT_PROJECT 运行的

将 POM 更改为包括

<site>
    <id>nexus</id>
    <name>site</name>
    <url>http://localhost:8080</url>
</site>

由于它是一个多项目,现在按照此处的建议运行 site:stage http://maven.apache.org/plugins/maven-site-plugin/faq.html但注意到我无法运行该项目,因为 maven 声明“什么” mvn site”将为您做,在多项目构建中,为父级及其所有模块单独运行“mvn site”。父级和子级之间的链接在这里不起作用。但是,当您部署地点。”

4

4 回答 4

2

您也应该考虑使用 maven-site-plugin 的site:stage目标。从那个链接:

[site:stage] 可用于测试多模块构建中模块站点之间的链接是否有效。

于 2011-08-22T12:31:57.333 回答
1

我不确定这个问题是否与问题project-reports.html vs index.html当生成的链接错误时,您无法访问子模块有关。查看生成的文件(索引或项目报告)并通过修复 URL 来访问该文件。

于 2016-04-20T18:37:46.447 回答
0

今天遇到了同样的问题,我通过将我的 maven 更新到 3.0.4 来解决它。正在使用 Maven 3.0.3,并且该版本中的链接已损坏。

于 2012-08-09T23:34:27.813 回答
0

我不确定这是否是您的具体问题,但我体验到如果站点描述符已更改,Maven 站点不会更新 index.html。所以它保留 index.html 不变,除非你指定mvn clean.

所以试试

mvn clean site:site site:deploy
于 2021-03-18T21:00:12.277 回答