Maven 项目有没有办法从 pom 依赖项继承报告配置?
我知道可以在父 POM 中配置该部分并将其应用于多模块项目中的子模块。但是,我希望有一个单独的 POM 作为依赖项进行引用,这样我就可以拥有一个可以“混合”到各个项目的报告配置,而无需在多个项目中复制我的报告配置。 (参见“依赖 POM”:http ://sonatype.com/books/maven-book/reference/pom-relationships-sect-pom-best-practice.html)
例如,对于我的Widget项目,我有一个父POM(widget-parent )有两个子模块,widget-core 和 widget-web。我想要一个单独的 POM,静态分析,widget-parent 所依赖的。静态分析将有一个块来定义 Checkstyle 和 FindBugs 报告。当我构建 Widget 时,我希望 Checkstyle 和 FindBugs 能够在 widget-core 和 widget-web 上运行。
如果您的解决方案仅适用于特定版本的 Maven,请告诉我。我们还没有升级到 3.x。
I know that it's possible to configure the section in a parent POM and have it apply to the sub-modules in a multi-module project. However, I'd like to have a separate POM to reference as a dependency so I can have a reporting configuration I can "mix in" to various projects without having to replicate my reporting configuration across multiple projects. (See "dependency POMs" here: http://sonatype.com/books/maven-book/reference/pom-relationships-sect-pom-best-practice.html)
For example, for my Widget project, I have a parent POM (widget-parent) with two sub-modules, widget-core and widget-web. I'd like to have a separate POM, static-analysis, that widget-parent depends on. static-analysis would have a block that would define Checkstyle and FindBugs reporting. When I build Widget, I would expect Checkstyle and FindBugs to be run on widget-core and widget-web.
If your solution only works in a particular version of Maven, let me know. We haven't upgraded to 3.x yet.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 Maven 3 中,pom 中的报告元素消失了,取而代之的是站点插件的配置元素。然后,您可以使用常用的pluginManagement 来定义随处使用的配置。无论如何,我建议升级到 Maven 3,这给了你另一个很好的理由。
更新:报告元素已恢复,并可再次与最新版本的站点插件一起使用。
With Maven 3 the reporting element in the pom is gone and replaced by a configuration element for the site plugin. You can then use the usual pluginManagement to define a configuration that is used everywhere. I would suggest to upgrade to Maven 3 in general anyway and this gives you another good reason..
Update: The reporting element has been brought back and works again with latest versions of the site plugin.
据推测,这从 2017 年春季发布的 Maven 3.5 开始就有效;请参阅相关问题。
下的插件中定义的配置现在也将在
下使用。如果您不知道如何进行插件管理,请参阅文档以获取更多信息在 Maven 中工作。
This supposedly works since Maven 3.5, which was released in spring of 2017; see the related issue.
Configuration defined in plugins under
<build><pluginManagement>
will be used under<reporting>
too now.Refer to the documentation for further info, if you don't know how plugin-management works in Maven.