开发者

Is there a way for a Maven project to inherit report configurations from a pom dependency?

开发者 https://www.devze.com 2023-01-30 19:58 出处:网络
I know that it\'s possible to configure thesection 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

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 开发者_StackOverflowacross 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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消