6

I have a large multi-module Maven build, presently with a mix of PowerMock and Mockito tests (moving all PowerMock tests to Mockito soon). The default jacoco-maven-plugin config in the parent pom is for "offline" instrumentation, but the one module with Mockito tests is using online instrumentation. I believe each of the jacoco.exec files in the modules are being built correctly.

One of the child modules, called "jacoco-aggregate", just tries to use the "merge" and "report-aggregate" goals. I'm using "merge" because I'm integrating with SonarQube, and the version we're using will only allow a single exec file. From the output I can see, the "merge" goal seems to be working correctly.

The "report-aggregate" goal seems to have a problem. It's presently generating no coverage at all. The table that is displayed is empty.

The following is the current output I get when building in the jacoco child module itself:

[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ jacoco-aggregate ---
[INFO] Deleting <myhome>\git\oce_usl\usl-parent\jacoco-aggregate\target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (filter) @ jacoco-aggregate ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory <myhome>\git\oce_usl\usl-parent\jacoco-aggregate\src\main\resources
[INFO] 
[INFO] --- depends-maven-plugin:1.2:generate-depends-file (generate-depends-file) @ jacoco-aggregate ---
[INFO] Created: <myhome>\git\oce_usl\usl-parent\jacoco-aggregate\target\classes\META-INF\maven\dependencies.properties
[INFO] 
[INFO] --- jacoco-maven-plugin:0.7.8:report (default-report) @ jacoco-aggregate ---
[INFO] Skipping JaCoCo execution due to missing execution data file.
[INFO] 
[INFO] --- maven-javadoc-plugin:2.10.4:jar (module-javadoc-jar) @ jacoco-aggregate ---
[INFO] Not executing Javadoc as the project is not a Java classpath-capable package
[INFO] 
[INFO] --- jacoco-maven-plugin:0.7.8:report-aggregate (report-aggregate) @ jacoco-aggregate ---
[INFO] 
[INFO] --- jacoco-maven-plugin:0.7.8:merge (merge) @ jacoco-aggregate ---
[INFO] Loading execution data file <myhome>\git\oce_usl\usl-parent\jacoco-aggregate\..\usl-account-impl\target\jacoco.exec
[INFO] Loading execution data file <myhome>\git\oce_usl\usl-parent\jacoco-aggregate\..\usl-core-impl\target\jacoco.exec
[INFO] Loading execution data file <myhome>\git\oce_usl\usl-parent\jacoco-aggregate\..\usl-creditcheck-impl\target\jacoco.exec
[INFO] Loading execution data file <myhome>\git\oce_usl\usl-parent\jacoco-aggregate\..\usl-ordercreation-impl\target\jacoco.exec
[INFO] Loading execution data file <myhome>\git\oce_usl\usl-parent\jacoco-aggregate\..\usl-payment-impl\target\jacoco.exec
[INFO] Loading execution data file <myhome>\git\oce_usl\usl-parent\jacoco-aggregate\..\usl-productandoffer-impl\target\jacoco.exec
[INFO] Writing merged execution data to <myhome>\git\oce_usl\usl-parent\jacoco-aggregate\target\jacoco.exec
[INFO] 

The following is an excerpt from the "jacoco-aggregate" pom:

<artifactId>jacoco-aggregate</artifactId>
<version>2.3.0-SNAPSHOT</version>
<name>jacoco-aggregate</name>
<packaging>pom</packaging>
<dependencies>
   <dependency>
       <groupId>com.att.detsusl</groupId>
       <artifactId>usl-account-impl</artifactId>
       <version>2.3.0-SNAPSHOT</version>
       <scope>compile</scope>
   </dependency>
   <dependency>
       <groupId>com.att.detsusl</groupId>
       <artifactId>usl-core-impl</artifactId>
       <version>2.3.0-SNAPSHOT</version>
       <scope>compile</scope>
   </dependency>
   <dependency>
       <groupId>com.att.detsusl</groupId>
       <artifactId>usl-creditcheck-impl</artifactId>
       <version>2.3.0-SNAPSHOT</version>
       <scope>compile</scope>
   </dependency>
   <dependency>
       <groupId>com.att.detsusl</groupId>
       <artifactId>usl-csi-jaxb-base</artifactId>
       <version>2.3.0-SNAPSHOT</version>
       <scope>compile</scope>
   </dependency>
   <dependency>
       <groupId>com.att.detsusl</groupId>
       <artifactId>usl-ordercreation-impl</artifactId>
       <version>2.3.0-SNAPSHOT</version>
       <scope>compile</scope>
   </dependency>
   <dependency>
       <groupId>com.att.detsusl</groupId>
       <artifactId>usl-payment-impl</artifactId>
       <version>2.3.0-SNAPSHOT</version>
       <scope>compile</scope>
   </dependency>
   <dependency>
       <groupId>com.att.detsusl</groupId>
       <artifactId>usl-productandoffer-impl</artifactId>
       <version>2.3.0-SNAPSHOT</version>
       <scope>compile</scope>
   </dependency>
   <dependency>
       <groupId>com.att.detsusl</groupId>
       <artifactId>usl-servicefactory-impl</artifactId>
       <version>2.3.0-SNAPSHOT</version>
       <scope>compile</scope>
   </dependency>
   <dependency>
    <groupId>com.att.detsusl</groupId>
    <artifactId>usl-csi-icas-impl</artifactId>
    <version>2.3.0-SNAPSHOT</version>
    <scope>compile</scope>
   </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.7.8</version>
            <executions>
                <execution>
                    <id>report-aggregate</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>report-aggregate</goal>
                    </goals>
                </execution>
                <execution>
                   <id>merge</id>
                   <phase>verify</phase>
                   <goals>
                       <goal>merge</goal>
                   </goals>
                   <configuration>
                       <fileSets>
                           <fileSet>
                               <directory>${project.basedir}/../usl-account-impl/target</directory>
                               <includes>
                                <include>*.exec</include>
                               </includes>
                           </fileSet>
                           <fileSet>
                               <directory>${project.basedir}/../usl-core-impl/target</directory>
                               <includes>
                                <include>*.exec</include>
                               </includes>
                           </fileSet>
                           <fileSet>
                               <directory>${project.basedir}/../usl-creditcheck-impl/target</directory>
                               <includes>
                                <include>*.exec</include>
                               </includes>
                           </fileSet>
                           <fileSet>
                               <directory>${project.basedir}/../usl-csi-jaxb-base/target</directory>
                               <includes>
                                <include>*.exec</include>
                               </includes>
                           </fileSet>
                           <fileSet>
                               <directory>${project.basedir}/../usl-ordercreation-impl/target</directory>
                               <includes>
                                <include>*.exec</include>
                               </includes>
                           </fileSet>
                           <fileSet>
                               <directory>${project.basedir}/../usl-payment-impl/target</directory>
                               <includes>
                                <include>*.exec</include>
                               </includes>
                           </fileSet>
                           <fileSet>
                               <directory>${project.basedir}/../usl-productandoffer-impl/target</directory>
                               <includes>
                                <include>*.exec</include>
                               </includes>
                           </fileSet>
                           <fileSet>
                               <directory>${project.basedir}/../usl-servicefactory-impl/target</directory>
                               <includes>
                                <include>*.exec</include>
                               </includes>
                           </fileSet>
                       </fileSets>
                   </configuration>
                </execution>
              <execution>
                  <id>prepare-agent</id>
                  <phase>none</phase>
                  <goals>
                      <goal>prepare-agent</goal>
                  </goals>
              </execution>
                <execution>
                    <id>default-instrument</id>
                    <phase>none</phase>
                    <goals>
                        <goal>instrument</goal>
                    </goals>
                </execution>
                <execution>
                    <id>default-restore-instrumented-classes</id>
                    <phase>none</phase>
                    <goals>
                        <goal>restore-instrumented-classes</goal>
                    </goals>
                </execution>
                <execution>
                   <id>report</id>
                  <phase>none</phase>
                   <goals>
                       <goal>report</goal>
                   </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>

Note that I'm specifying executions for other jacoco goals because those are specified in the parent pom, which are expected to be used by ordinary code modules. Setting the "phase" to "none" is a way to effectively disable that goal (not that it's particularly clean).

Before I run the build manually in "jacoco-aggregate", I've looked at the several "jacoco.exec" files being referenced in the other modules, and they all exist and are non-empty.

David M. Karr
  • 14,317
  • 20
  • 94
  • 199

1 Answers1

2

First - seems that you do merge after report-aggregate, so last one doesn't see jacoco.exec.

Also note that report-aggregate looks into reactor projects, i.e. if you have

root
  \child_1
  \child_2

then during execution of mvn ... in root reactor will contain all 3, while during execution of cd child_2 && mvn ... reactor will contain only child_2.

Godin
  • 9,801
  • 2
  • 39
  • 76