首页 > 解决方案 > 通过“构建工具”在多模块中的 Maven 站点描述符

问题描述

我目前在一个多模块项目中使用 maven-site-plugin。实际上我对所有项目都使用默认皮肤,但现在我想改变它。因为其中许多是多模块项目,所以我已经使用了一个“构建工具”扩展,其中包含 checkstyle、findbugs 等的配置。

我对站点描述符的想法现在是将站点描述符也集成到“构建工具”中。所以我必须为每个项目和模块只维护一个站点描述符。

我已经尝试了不同的方法和配置与集成,如 maven-site-plugin 的构建扩展或插件依赖项。我结合了站点目录配置的不同路径和描述符文件的“构建工具”内部的方法,但没有任何效果。每次插件回退到默认皮肤。只有直接集成到单个项目中才有效。

我现在的问题是,有没有办法实现该计划,或者我必须真正将站点描述符(site.xml 等)集成到每个项目/父模块中并单独维护它?

谢谢和最好的问候阿波罗


更新

以下链接是示例项目的两个变体。

https://1drv.ms/u/s!AoIm6kXLf_KHroRFHb_zT3W6dELPKQ

在变体“example_dependency”中,“build-tools”模块通过插件中的依赖项集成,如 maven-spotbugs 或 maven-site。变体“example_extensions”尝试构建标签的扩展机制,例如https://spotbugs.github.io/spotbugs-maven-plugin/examples/multi-module-config.html下的 spotbugs 示例

依赖变体是可构建的,但它没有找到自定义站点描述符文件。对于此示例,它只是一个其他站点皮肤。我认为问题在于站点目录的路径定义。在这里,我尝试了不同的变体但没有成功。

扩展变体在初始构建时抛出以下错误,因此我无法测试 spotbugs 示例的方式。

PS C:\Users\apollox\Desktop\example_extensions> mvn install site
[INFO] Scanning for projects...
Downloading from nexus-mirror: https://.../nexus/content/groups/public/com/example/multi-module/extensions/build-tools/0.1-SNAPSHOT/maven-metadata.xml
Downloading from nexus-mirror: https://.../nexus/content/groups/public/com/example/multi-module/extensions/build-tools/0.1-SNAPSHOT/build-tools-0.1-SNAPSHOT.pom
[WARNING] The POM for com.example.multi-module.extensions:build-tools:jar:0.1-SNAPSHOT is missing, no dependency information available
Downloading from nexus-mirror: https://.../nexus/content/groups/public/com/example/multi-module/extensions/build-tools/0.1-SNAPSHOT/build-tools-0.1-SNAPSHOT.jar
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Unresolveable build extension: Plugin com.example.multi-module.extensions:build-tools:0.1-SNAPSHOT or one of its dependencies could not be resolved: Could not find artifact com.example.multi-module.extensions:build-tools:jar:0.1-SNAPSHOT in nexus-mirror (https://.../nexus/content/groups/public/) @
 @
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR]   The project com.example.multi-module.extensions:example-progs:0.1-SNAPSHOT (C:\Users\apollox\Desktop\example_extensions\example-progs\pom.xml) has 1 error
[ERROR]     Unresolveable build extension: Plugin com.example.multi-module.extensions:build-tools:0.1-SNAPSHOT or one of its dependencies could not be resolved: Could not find artifact com.example.multi-module.extensions:build-tools:jar:0.1-SNAPSHOT in nexus-mirror (https://.../nexus/content/groups/public/) -> [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/PluginManagerException

标签: mavenmaven-site-plugin

解决方案


推荐阅读