未能与Jacoco一起执行maven目标

时间:2014-11-17 01:02:28

标签: java maven jacoco

我在jacoco上尝试超过15个版本,但仍然有问题。 我尝试过在互联网上找到的不同的pom.xml文件,但仍然没有任何影响。

在我的pom.xml下面

<project>
<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>org.jacoco</groupId>
    <artifactId>org.jacoco.build</artifactId>
    <version>0.6.5.201403032054</version>
    <relativePath>../org.jacoco.build</relativePath>
</parent>
<artifactId>jacoco</artifactId>
<packaging>pom</packaging>
<name>JaCoCo :: Distribution</name>
<description>JaCoCo Standalone Distribution</description>
<properties>
    <jarsigner.skip>true</jarsigner.skip>
</properties>

<build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.14.1</version>
            <configuration>
                <reuseForks>true</reuseForks>
                <argLine>${argLine} -Xmx2048m</argLine>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.14.1</version>
            <configuration>
                <reuseForks>true</reuseForks>
                <argLine>${argLine} -Xmx4096m -XX:MaxPermSize=512M ${itCoverageAgent}</argLine>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>integration-test</goal>
                        <goal>verify</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.6.5.201403032054</version>
            <executions>
                <execution>
                    <id>prepare-unit-tests</id>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                </execution>
                <!-- prepare agent for measuring integration tests -->
                <execution>
                    <id>prepare-integration-tests</id>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                    <phase>pre-integration-test</phase>
                    <configuration>
                        <propertyName>itCoverageAgent</propertyName>
                    </configuration>
                </execution>
                <execution>
                    <id>jacoco-site</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                    <configuration>
                        <finalName>jacoco-${qualified.bundle.version}</finalName>
                        <appendAssemblyId>false</appendAssemblyId>
                        <descriptors>
                            <descriptor>assembly.xml</descriptor>
                        </descriptors>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-enforcer-plugin</artifactId>
            <executions>
                <execution>
                    <id>enforce-distribution-size</id>
                    <goals>
                        <goal>enforce</goal>
                    </goals>
                    <phase>verify</phase>
                    <configuration>
                        <rules>
                            <requireFilesSize>
                                <maxsize>2500000</maxsize>
                                <minsize>2100000</minsize>
                                <files>
                                    <file>${project.build.directory}/jacoco-${qualified.bundle.version}.zip</file>
                                </files>
                            </requireFilesSize>
                        </rules>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

输出:

[ERROR] Failed to execute goal org.jacoco:jacoco-maven-    plugin:0.6.5.201403032054:check    (default-cli) on project jacoco: The parameters 'rules' for goal org.jacoco:jacoco-maven-plugin:0.6.5.201403032054:check are missing or invalid -> [Help 1]

输出取决于版本jacoco。

你有什么想法吗?

1 个答案:

答案 0 :(得分:0)

我怀疑您正在运行jacoco的特定目标(check具体目标),这意味着您没有运行任何phase的任何特定lifecycle

像:

mvn jacoco:check

请注意,您的执行enforce-distribution-size绑定到verify生命周期的default阶段 - 因此,如果您希望执行enforce-distribution-size,则应该:

  1. 以至少verify的相位运行(我假设您不想这样做)或
  2. <id>的{​​{1}}重命名为<execution>(请参阅this),如果您需要具有特定default-cli目标的专家,请说jacoco目标。比如,更改以下行:
  3. check

    <id>enforce-distribution-size</id>

    这就是你需要做的全部。