Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-22716

Jacoco: Zero coverage with java8

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      I have a Java 7 project I am trying to port to Java 8.
      Everything else is working fine except maven tests, which result in zero coverage when project source/target is 1.8. Upon inspecting the resulting jacoco.exec it appears to be intact and showing executed classes properly.

      I don't see any jacoco related errors in the build log and build is successful with both java versions.

      I'm using jenkins 1.560, jacoco-maven-plugin 0.7.0.201403182114, jenkins jacoco plugin 1.0.14.

      I don't know if this is an issue with jacoco-maven-plugin or if it's actually a problem with maven-compiler-plugin or aspectj-maven-plugin.
      The only differences between Java 7 and 8 in my pom.xml are related to maven-compiler-plugin and aspectj-maven-plugin:

      <properties>
      		<jdk.version>1.7</jdk.version>
      </properties>
      
      			<plugin>
      				<groupId>org.apache.maven.plugins</groupId>
      				<artifactId>maven-compiler-plugin</artifactId>
      				<configuration>
      					<source>${jdk.version}</source>
      					<target>${jdk.version}</target>
      					<showDeprecation>false</showDeprecation>
      				</configuration>
      			</plugin>
      
      <groupId>org.codehaus.mojo</groupId>
      					<artifactId>aspectj-maven-plugin</artifactId>
      					<version>1.6</version>
      					<configuration>
      						<showWeaveInfo>true</showWeaveInfo>
      						<source>${jdk.version}</source>
      						<target>${jdk.version}</target>
      						<Xlint>ignore</Xlint>
      						<complianceLevel>${jdk.version}</complianceLevel>
      
      

        Attachments

          Activity

          Hide
          apernel Austin Pernell added a comment -

          I'm seeing the same issue with 1.8. The html reports work just fine, and the jacoco.exec looks to be okay, but it's not showing any coverage (where it was working fine before). I'm using sbt and jacoco4sbt to generate the exec file.

          Show
          apernel Austin Pernell added a comment - I'm seeing the same issue with 1.8. The html reports work just fine, and the jacoco.exec looks to be okay, but it's not showing any coverage (where it was working fine before). I'm using sbt and jacoco4sbt to generate the exec file.
          Hide
          peterkittreilly peterkittreilly added a comment -

          I got this to work locally.
          1) changed the dependency in jacoco-plugin to 0.7.1.201405082137 (the lastest one 0.7.0+ supports java8)
          2) changed an import -
          -import org.jacoco.core.data.ExecFileLoader;
          +import org.jacoco.core.tools.ExecFileLoader;
          3) compiled the hpi with java8, mvn package -DskipTests (the tests cannot stomach java8)

          • It should compile with java7, but I have not done that yet.

          Complete diff:

          diff --git a/pom.xml b/pom.xml
          index a6162ba..d8ec723 100644
          — a/pom.xml
          +++ b/pom.xml
          @@ -54,7 +54,7 @@
          <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
          <project.build.outputEncoding>UTF-8</project.build.outputEncoding>
          <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

          • <jacoco.version>0.6.3.201306030806</jacoco.version>
            + <jacoco.version>0.7.1.201405082137</jacoco.version>
            </properties>

          <repositories>
          diff --git a/src/main/java/hudson/plugins/jacoco/report/CoverageReport.java b/src/main/java/hudson/plugins/jacoco/report/CoverageReport.java
          index 5a35d57..199968e 100644
          — a/src/main/java/hudson/plugins/jacoco/report/CoverageReport.java
          +++ b/src/main/java/hudson/plugins/jacoco/report/CoverageReport.java
          @@ -21,7 +21,7 @@ import javax.servlet.ServletException;
          import org.jacoco.core.analysis.IClassCoverage;
          import org.jacoco.core.analysis.IMethodCoverage;
          import org.jacoco.core.analysis.IPackageCoverage;
          -import org.jacoco.core.data.ExecFileLoader;
          +import org.jacoco.core.tools.ExecFileLoader;
          import org.jacoco.core.data.ExecutionDataWriter;
          import org.kohsuke.stapler.HttpResponse;
          import org.kohsuke.stapler.StaplerRequest;

          I will add a pull request.
          but I do not know if this will handle 0.6 exec files.

          Show
          peterkittreilly peterkittreilly added a comment - I got this to work locally. 1) changed the dependency in jacoco-plugin to 0.7.1.201405082137 (the lastest one 0.7.0+ supports java8) 2) changed an import - -import org.jacoco.core.data.ExecFileLoader; +import org.jacoco.core.tools.ExecFileLoader; 3) compiled the hpi with java8, mvn package -DskipTests (the tests cannot stomach java8) It should compile with java7, but I have not done that yet. Complete diff: diff --git a/pom.xml b/pom.xml index a6162ba..d8ec723 100644 — a/pom.xml +++ b/pom.xml @@ -54,7 +54,7 @@ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.build.outputEncoding>UTF-8</project.build.outputEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <jacoco.version>0.6.3.201306030806</jacoco.version> + <jacoco.version>0.7.1.201405082137</jacoco.version> </properties> <repositories> diff --git a/src/main/java/hudson/plugins/jacoco/report/CoverageReport.java b/src/main/java/hudson/plugins/jacoco/report/CoverageReport.java index 5a35d57..199968e 100644 — a/src/main/java/hudson/plugins/jacoco/report/CoverageReport.java +++ b/src/main/java/hudson/plugins/jacoco/report/CoverageReport.java @@ -21,7 +21,7 @@ import javax.servlet.ServletException; import org.jacoco.core.analysis.IClassCoverage; import org.jacoco.core.analysis.IMethodCoverage; import org.jacoco.core.analysis.IPackageCoverage; -import org.jacoco.core.data.ExecFileLoader; +import org.jacoco.core.tools.ExecFileLoader; import org.jacoco.core.data.ExecutionDataWriter; import org.kohsuke.stapler.HttpResponse; import org.kohsuke.stapler.StaplerRequest; I will add a pull request. but I do not know if this will handle 0.6 exec files.
          Hide
          peterkittreilly peterkittreilly added a comment -

          Ok, I made a pull request. https://github.com/jenkinsci/jacoco-plugin/pull/43
          Peter

          Show
          peterkittreilly peterkittreilly added a comment - Ok, I made a pull request. https://github.com/jenkinsci/jacoco-plugin/pull/43 Peter
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Dominik Stadler
          Path:
          pom.xml
          src/main/java/hudson/plugins/jacoco/report/CoverageReport.java
          http://jenkins-ci.org/commit/jacoco-plugin/2bb41d2139aca492d4387b1535e1ba0bf1ac9069
          Log:
          Merge pull request #43 from flukebuilder/master

          Update to latest JaCoCo 0.7.1 to support java8, fixes JENKINS-22716

          Compare: https://github.com/jenkinsci/jacoco-plugin/compare/93bf627cd317...2bb41d2139ac

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Dominik Stadler Path: pom.xml src/main/java/hudson/plugins/jacoco/report/CoverageReport.java http://jenkins-ci.org/commit/jacoco-plugin/2bb41d2139aca492d4387b1535e1ba0bf1ac9069 Log: Merge pull request #43 from flukebuilder/master Update to latest JaCoCo 0.7.1 to support java8, fixes JENKINS-22716 Compare: https://github.com/jenkinsci/jacoco-plugin/compare/93bf627cd317...2bb41d2139ac
          Hide
          centic centic added a comment -

          I have applied the changes, will be included in the next release which hopefully is done shortly.

          Show
          centic centic added a comment - I have applied the changes, will be included in the next release which hopefully is done shortly.

            People

            • Assignee:
              centic centic
              Reporter:
              risto_oikarinen Risto Oikarinen
            • Votes:
              5 Vote for this issue
              Watchers:
              12 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: