【问题标题】:Running maven goal in multiple lifecycles在多个生命周期中运行 maven 目标
【发布时间】:2009-07-09 11:56:30
【问题描述】:

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

我已将 cobertura 配置为作为验证阶段的一部分运行的插件,但如果我这样做,即使我运行 mvn verify site,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>

我也不想将其复制到报告部分,因为要复制的内容很多。有没有什么好的方法可以做到这一点?

谢谢,

杰夫

【问题讨论】:

    标签: maven-2 plugins profile


    【解决方案1】:

    定义这个:

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

    【讨论】:

    • 再看一遍,maven 有没有一个叫做reporting 的阶段? maven.apache.org/guides/introduction/…。它似乎没有像我预期的那样工作......
    • 正确,据我所知,报告正在网站生成中发生
    • 我发现如果我只是将插件放在报告部分和我的其他构建中,我只需从命令行运行目标,效果最好。唯一的问题是我似乎无法指定从命令行执行时要使用的版本。我希望它会从报告插件中获取它,但事实并非如此。有什么办法吗?
    • 仅供参考 - 我已经创建了属性来管理版本。我仍然需要在两个地方(插件和报告)列出插件,但是配置会自动从报告部分中提取,但版本不是。所以我在两个地方都列出了插件 groupId、artifactId 和 version(并且 version 是一个属性)
    猜你喜欢
    • 2020-02-22
    • 2014-04-18
    • 2020-09-05
    • 1970-01-01
    • 2011-09-25
    • 2014-12-25
    • 1970-01-01
    • 2016-02-18
    • 2013-05-28
    相关资源
    最近更新 更多