gpt4 book ai didi

maven-2 - 多模块 Maven 站点

转载 作者:行者123 更新时间:2023-12-02 13:28:48 27 4
gpt4 key购买 nike

我有一个包含很多子模块的 Maven 项目,我使用父 pom 来控制目录中的插件,如下所示

-pom.xml (parent pom)
+- submodule1
+- submodule2
+- src\site\site.xml

因此src\site\site.xml包含如下自定义菜单

<project>
....
<body>
<menu name="Overview">
<item name="Introduction" href="introduction.html"/>
</menu>
<menu name="Development">
<item name="Getting started" href="designenv.html"/>
<item name="FAQ" href="designfaq.html" />
<item name="Javadoc" href="apidocs/index.html" />
</menu>
<menu ref="modules"/>
<menu ref="reports"/>
</body>
</project>

在我运行 mvn site:stage 后在 root 中(从 maven site plugin 建议),父网页很好,而 <sub-modules>\index.html不包含任何菜单(没有项目信息和项目报告)

我还注意到,如果我运行 mvn site在子模块下,index.html左侧不包含任何菜单,而单独的html存在于pmd.html、license.html等目录中

  • 我需要添加 src\site\site.xml在每个子模块或其他更好的方式?
  • 或者我在 pom.xml 做了什么蠢事吗?某处?

有什么提示吗?

[更新]也喜欢横幅图像,如果我像这样在父级中设置

<bannerLeft>
<name>edcp</name>
<src>images/mylogo.png</src>
</bannerLeft>

子模块的站点指向错误的方向,在 html 中,看起来像 ..\..\<submodule> ,不是..\images\mylogo.png

最佳答案

如果您想避免手动将 site.xml 复制到每个子模块,请使用 maven-resources-plugin可能是一个解决方法:将其添加到您的父 pom 中:

[...]
<properties>
<site.basedir>${project.basedir}</site.basedir>
</properties>
[...]
<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>copy-sitedescriptor</id>
<!-- fetch site.xml before creating site documentation -->
<phase>pre-site</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/src/site/</outputDirectory>
<resources>
<resource>
<directory>${site.basedir}/src/site/</directory>
<includes>
<include>**/site.xml</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>

并将其添加到您的每个子模块 poms 中:

<properties>
<site.basedir>${project.parent.basedir}</site.basedir>
</properties>

然后,在创建站点文档之前,站点描述符将从父项目复制到每个子模块(覆盖现有描述符)。请注意,每个子模块中必须存在 src/site 目录才能使其工作。这不是一个完美的解决方案,但可能比完整的手动解决方案更好。

关于maven-2 - 多模块 Maven 站点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5976123/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com