在多个生命周期中运行maven目标

Jef*_*rey 10 profile plugins maven-2

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

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

<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>
Run Code Online (Sandbox Code Playgroud)

我不想将其复制到报告部分,因为复制很多.有没有一个好方法来实现这一点呢?

谢谢,

杰夫

Dav*_*itz 10

定义这个:

<executions>
        <execution>
                <phase>verify</phase>
                <goals>
                        <goal>cobertura</goal>
                </goals>
        </execution>
        <execution>
                <phase>pre-site</phase>
                <goals>
                        <goal>cobertura</goal>
                </goals>
        </execution>
</executions>
Run Code Online (Sandbox Code Playgroud)