Jacoco maven插件准备代理目标增加两次

时间:2018-04-23 10:01:37

标签: maven-3 jacoco-maven-plugin

工具:

Maven 3.2

Maven Jacoco Plugin - 版本0.5.5.201112152213

问题:

下面是pom.xml中包含的jacoco pugin

<build>
     <plugins>
       <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.5.5.201112152213</version>
            <configuration>
              <destFile>${basedir}/target/reports/jacoco.exec</destFile>
              <dataFile>${basedir}/target/reports/jacoco.exec</dataFile>
            </configuration>
            <executions>
              <execution>
                <id>jacoco-initialize</id>
                <goals>
                  <goal>prepare-agent</goal>
                </goals>
              </execution>
              <execution>
                <id>jacoco-site</id>
                <phase>package</phase>
                <goals>
                  <goal>report</goal>
                </goals>
              </execution>
            </executions>
       </plugin>
     </plugins>
  </build>

运行有效pom后,我的输出低于输出 -

<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.5.5.201112152213</version>
    <executions>
      <execution>
        <id>agent</id>
        <goals>
          <goal>prepare-agent</goal>
        </goals>
        <configuration>
          <destFile>C:\JDeveloper\mywork\myAppTest/target/coverage-reports/jacoco-unit.exec</destFile>
          <dataFile>C:\JDeveloper\mywork\myAppTest/target/coverage-reports/jacoco-unit.exec</dataFile>
          <append>true</append>
        </configuration>
      </execution>
      <execution>
        <id>jacoco-initialize</id>
        <goals>
          <goal>prepare-agent</goal>
        </goals>
        <configuration>
          <destFile>C:\JDeveloper\mywork\myAppTest/target/coverage-reports/jacoco-unit.exec</destFile>
          <dataFile>C:\JDeveloper\mywork\myAppTest/target/coverage-reports/jacoco-unit.exec</dataFile>
          <append>true</append>
        </configuration>
      </execution>
      <execution>
        <id>jacoco-site</id>
        <phase>package</phase>
        <goals>
          <goal>report</goal>
        </goals>
        <configuration>
          <destFile>C:\JDeveloper\mywork\myAppTest/target/coverage-reports/jacoco-unit.exec</destFile>
          <dataFile>C:\JDeveloper\mywork\myAppTest/target/coverage-reports/jacoco-unit.exec</dataFile>
          <append>true</append>
        </configuration>
      </execution>
    </executions>
    <configuration>
      <destFile>C:\JDeveloper\mywork\myAppTest/target/coverage-reports/jacoco-unit.exec</destFile>
      <dataFile>C:\JDeveloper\mywork\myAppTest/target/coverage-reports/jacoco-unit.exec</dataFile>
      <append>true</append>
    </configuration>
  </plugin>

似乎准备代理人的目标已被包括两次。多余的目标是

<id>agent</id>pom.xml文件中没有,但尚未添加。

所以,我的问题是:为什么这个目标会被包含在pom中,即使目标已经明确配置为id <id>jacoco-initialize</id>.

编辑:

进一步深入研究问题,我从子模块中完全删除了插件(jacoco-maven-plugin),当我运行mvn help:effective-pom时,有趣的是它仍显示jacoco-maven-plugin只有一个目标,如下所示。它是另外添加的相同的一个。这意味着父模块正在添加此插件。但是在父模块中没有引用此插件

<execution>
        <id>agent</id>
        <goals>
          <goal>prepare-agent</goal>
        </goals>
        <configuration>
          <destFile>C:\JDeveloper\mywork\myAppTest/target/coverage-reports/jacoco-unit.exec</destFile>
          <dataFile>C:\JDeveloper\mywork\myAppTest/target/coverage-reports/jacoco-unit.exec</dataFile>
          <append>true</append>
        </configuration>
  </execution>

0 个答案:

没有答案