Domanda

I am running Jacoco's Maven plugin. The prepare-agent goal runs fine, but does not generate jacoco.exec file for some reason. Subsequently the report goal complains Skipping JaCoCo execution due to missing execution data file.

Any ideas?

È stato utile?

Soluzione

Having read https://groups.google.com/forum/#!topic/jacoco/LzmCezW8VKA, it turns out that prepare-agent sets a surefire property called argLine. If you override this property (something that https://issues.apache.org/jira/browse/SUREFIRE-951 encourages you to do) then jacoco never ends up running.

The solution is to replace:

<argLine>-Dfile.encoding=${project.build.sourceEncoding}</argLine>

with

<argLine>-Dfile.encoding=${project.build.sourceEncoding} ${argLine}</argLine>

Meaning, append jacoco's argLine to the new value.

UPDATE: As pointed out by Fodder, if you aren't always running JaCoCo and no other plugin sets ${argLine} then Maven will complain that ${argLine} is undefined. To resolve this, simply define what ${argLine} should look like when JaCoCo is skipped:

<properties>
    <argLine/>
</properties>

In this case use @{argLine} instead of ${argLine} as explained here.

Altri suggerimenti

If you aren't always running JaCoCo when building then @Gili's solution doesn't work, as it can't find argLine. Instead add a property argLine in you POM with the custom values. JaCoCo's prepare agent will append to that property, and Surefire will use the appended argLine.

<properties>
    <argLine>whatever your custom argline variables are</argLine>
</properties>

<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <!-- Don't put argLine config here! -->
    </plugin>
</plugins>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top