Maven 2插件,构建+ surefire [英] Maven 2 plugin, build + surefire

查看:122
本文介绍了Maven 2插件,构建+ surefire的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在< build>中定义了一个插件,标签,并想在我的站点命令中使用它,我该怎么做?我是否必须在< reporting>中定义插件?再次标记?

If i define a plugin in the <build> tag and want to use this in my site command how do i do that? Do i have to define the plugin within <reporting> tag again?

那我可能已经在build标记中完成并且想要在报告标记中进行的配置又如何呢? (例如,我不想仅在两个生命周期中使用一次插件就指定两次配置文件的位置)

And how about the configuration which i probably have done within the build tag and want to take place at the reporting tag as well? (i dont want to specifie for example a location of a configuration file twice just to use a plugin in 2 lifecycles)

例如:我在build标签中定义我的checkstyle插件,并为要使用的规则配置自定义位置.我这样做是因为规则打包在一个jar中,因此我可以将其定义为依赖项.如果我在报告标签中这样做,这将是不可能的.但是我也需要在报告标记中使用此插件,以便surfire可以为checkstyle生成报告.因此,我还必须在报告标记中定义插件.

As example: I define my checkstyle plugin in the build tag and configrue a custom location for the rules to be used. I do that because the rules are packed in a jar so i can define it as dependency. This would not be possible if i do it in the reporting tag. But i need to use this plugin in the reporting tag aswell so surfire can generate a report for checkstyle. So i have to define the plugin within the reporting tag aswell.

也许我在这里做错了什么,但除此之外我不知道该怎么做.我不喜欢的是,我的pom中有两个插件(在build标签和report标签中)两次.

Maybe i'm doing something complete wrong here but i don't see how i can do it other then that. What i dont like is that i have 1 plugin twice in my pom (in the build tag and reporting tag).

我希望有人可以验证我的解决方案是否可行,或者给我建议如何做得更好.

I hope somebody can verify my solution is ok, or give me an advise how to do it better.

thx

kuku

推荐答案

定义Maven插件通常会在给定的生命周期阶段绑定到执行.插件本身指定了该生命周期的阶段,但是如果您有特殊需要,可以更改此阶段.

A maven plugin is typically bound to execution in a given lifecycle phase when you define it. The plugin itself specifies which lifecycle phase this is, but you can change this if you have special needs.

如果您使用的是多模块构建,则可以定义一组带有通用父pom中所需的所有参数的插件.通常将对构建中的每个子模块执行此操作.如果您不希望发生这种情况,可以在父pom中定义它,如下所示:

If you have a multi-module build you can define a set of plugins with all parameters required in a common parent-pom. This will normally be executed for every sub-module in the build. If you do not want this to happen you can define it (in the parent pom) like this:

<plugin>
   <artifactId>maven-surefire-plugin</artifactId>
       <configuration>
            <skip>true</skip>
       </configuration>
   ... More plugin cofniguration stuff ...
 </plugin>

如果您使用一个或多个嵌套模块想要启用此插件,则可以说:

If you in one or more nested moudules want to enable this plugin you can just say:

<plugin>
   <artifactId>maven-surefire-plugin</artifactId>
       <configuration>
            <skip>false</skip>
       </configuration>
   ... Maybe Configuration ....
 </plugin>

在该特定模块中.您可以选择是否要重新配置从父定义继承的默认参数.

In that specific module. You can choose if you want to reconfigure the default parameters which are inherited from the parent definition or not.

我认为这就是您要寻找的?

I think this is what you're looking for ?

这篇关于Maven 2插件,构建+ surefire的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆