I'm new to Maven and want to use the Jacoco Maven Plugin to build my projects.
I've set up an example project with TestNG the only dependency.
Here is part of the pom.xml:
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.6.2.201302030002</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>
</plugins>
</build>
And i get this error:
Plugin execution not covered by lifecycle configuration: org.jacoco:jacoco-maven- plugin:0.6.2.201302030002:prepare-agent (execution: default, phase: initialize)
What am I doing wrong ? Cheers
I eventually chose to ignore the plugin and use the CLI mvn command instead for the test with code coverage.
Inside your Eclipse IDE, right click on the red color-marked warning for the jacoco-maven-plugin. You should three options in the popup to fix the warning, choose to ignore the warning, that would result an automatically generated section in your pom.xml, that started with a line of comments,
At a command line, run the mvn command before each checkin, and that should trigger the test goal with coverage,
You can ignore the plugin goal, adding something like this to your pom.xml
This problem is specific to Eclipse, as outlined on the M2E wiki. Sorry I can't help more than that, as I don't use Eclipse.
As this is related to the Eclipse Maven plugin, alternatively this can be set locally in Eclipse's preferences. Moving the configuration out of the project's pom file helps the code simple and clean, free of IDE particulars.
Go to Eclipse --> Preferences --> Maven --> Lifecycle Mappings. Add
lifecycle-mapping-metadata.xml
as the following:Reload the life-cycle mappings file and then
Maven
-->Update Project
Eclipse now offers a quick fix to disable the warning and save those in user preferences (in Eclipse --> Preferences --> Maven --> Lifecycle Mappings lifecycle-mapping-metadata.xml as noted by @iker-aguayo ) so you don't have to manually create or edit the file. This is useful in cases where you can't update the pom (such as using an open source project where you cannot commit.)