繁体   English   中英

Jacoco 插件与 maven 的集成

[英]Jacoco Plugin integration with maven

执行 maven(mvn clean install) 时发生以下错误

无法执行目标 org.jacoco:jacoco-maven-plugin:0.7.2.201409121644 :prepare-agent (default) on project testng: 目标 org.jacoco 的执行默认值:jacoco-maven-plugin:0.7.2.201409121644 failed: : 无法在插件 'org.jacoco:jacoco-maven-plugin:0.7.2.201409 121644' 中加载 mojo 'prepare-agent'。 缺少必需的类:org/jacoco/core/runtime/AgentOptions

请找到pom

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.6.3.201306030806</version>
<executions>
    <execution>
        <id>jacoco-initialize</id>
        <phase>initialize</phase>
        <goals>
            <goal>prepare-agent</goal>
        </goals>
    </execution>
    <execution>
        <id>jacoco-site</id>
        <phase>package</phase>
        <goals>
            <goal>report</goal>
        </goals>
    </execution>
</executions>
</plugin>

尝试使用新版本的jacoco-maven-plugin

<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.8.1</version>
    <executions>
        <execution>
            <goals>
                <goal>prepare-agent</goal>
            </goals>
        </execution>
        <execution>
            <id>report</id>
            <phase>prepare-package</phase>
            <goals>
                <goal>report</goal>
            </goals>
        </execution>
    </executions>
</plugin>

我把如下:

<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.8.5</version>
    <configuration>
        <target>
            <propertyfile file="lombok.config">
                <entry key="config.stopBubbling" value="true" />
                <entry key="lombok.addLombokGeneratedAnnotation" value="true" />
            </propertyfile>
        </target>
        <excludes>
            <exclude>**/domain/**</exclude>
            <exclude>**/enumeration/**</exclude>
            <exclude>**/exception/**</exclude>
        </excludes>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>prepare-agent</goal>
            </goals>
        </execution>
        <!-- attached to Maven test phase -->
        <execution>
            <id>report</id>
            <phase>test</phase>
            <goals>
                <goal>report</goal>
            </goals>
        </execution>
        <!-- Add this checking -->
        <execution>
            <id>jacoco-check</id>
            <goals>
                <goal>check</goal>
            </goals>
            <configuration>
                <rules>
                    <rule>
                        <element>PACKAGE</element>
                        <limits>
                            <limit>
                                <counter>INSTRUCTION</counter>
                                <value>COVEREDRATIO</value>
                                <minimum>65%</minimum>
                            </limit>
                        </limits>
                    </rule>
                </rules>
            </configuration>
        </execution>
    </executions>
</plugin>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM