在多个生命周期中运行Maven目标 [英] Running maven goal in multiple lifecycles

查看:102
本文介绍了在多个生命周期中运行Maven目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一种情况,我想在验证阶段和报告阶段都运行cobertura插件.我有两个配置文件,它们都应该运行cobertura插件,但是在配置文件A中,我只想创建xml/html输出,但是在配置文件B中,我将生成包括这些结果的完整站点文档.

I have a case where I want to run the cobertura plugin in both the verify phase and the reporting phase. I have two profiles and they should both be running the cobertura plugin, but in profile A, I only want to create the xml/html output, but in profile B, I will be generating full site documentation that includes these results.

我已经将cobertura配置为作为验证阶段的一部分运行的插件,但是即使这样做,即使我运行mvn verify site,cobertura报告也不会出现在站点文档中.似乎我需要在插件和报告部分中都列出它(因为我不会在配置文件A中运行网站,因此如果我仅在插件中使用它,就不会在该配置文件中调用它).到目前为止,我的POM的插件部分包括:

I have cobertura configured as a plugin that runs as part of the verify phase, but if I do that, even if I run mvn verify site, the cobertura report does not appear in the site documentation. It seems as though I need to have it listed in both the plugins and the reporting section (since I won't be running site in profile A, it won't get called in that profile if I only have it in the plugins). So far the plugins section of my POM includes:

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin </artifactId>
<version>2.2</version>
<configuration>
    <instrumentation>
        <excludes>
            <exclude>com/somepkg/**</exclude>
        </excludes>
    </instrumentation>
    <formats>
        <format>xml</format>
        <format>html</format>
    </formats>
</configuration>        
<executions>
    <execution>
        <phase>verify</phase>
        <goals>
            <goal>cobertura</goal>
        </goals>
    </execution>
</executions>
</plugin>

我也不想将其复制到报告部分,因为这有很多重复之处.否则,有什么好方法吗?

I don't want to copy this into the reporting section too since this is a lot to duplicate. Is there a good way to accomplish this otherwise?

谢谢

杰夫

推荐答案

定义此:

<executions>
        <execution>
                <phase>verify</phase>
                <goals>
                        <goal>cobertura</goal>
                </goals>
        </execution>
        <execution>
                <phase>pre-site</phase>
                <goals>
                        <goal>cobertura</goal>
                </goals>
        </execution>
</executions>

这篇关于在多个生命周期中运行Maven目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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