When running a Maven project in Eclipse or Spring Tool Suite (STS), we get an exception that is similar to this:-
Plugin execution not covered by lifecycle configuration: org.jacoco:jacoco-maven-plugin:0.6.4.201312101107:prepare-agent (execution: pre-unit-test, phase: initialize)
This problem stems from m2eclipse (m2e) plugin, which provides Maven support in Eclipse-based IDEs.
STEP 1: Suppress the Error Message
The simplest solution is to instruct m2e to silently ignore the plugin execution by adding the following configuration in the project root pom.xml:-
IMPORTANT: Please make sure to enter the correct plugin’s
goals that causes the problem in the first place.
<pluginManagement> <plugins> <plugin> <groupId>org.eclipse.m2e</groupId> <artifactId>lifecycle-mapping</artifactId> <version>1.0.0</version> <configuration> <lifecycleMappingMetadata> <pluginExecutions> <pluginExecution> <pluginExecutionFilter> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <versionRange>[0.0.1,)</versionRange> <goals> <goal>prepare-agent</goal> </goals> </pluginExecutionFilter> <action> <ignore /> </action> </pluginExecution> </pluginExecutions> </lifecycleMappingMetadata> </configuration> </plugin> </plugins> </pluginManagement>
STEP 2: Learn More About This Problem
Eclipse provides a great documentation regarding this issue. You can learn the “what”, “why” and “how” at http://wiki.eclipse.org/M2E_plugin_execution_not_covered
STEP 3: A More Elegant Fix
The problem with the above fix is we clutter our pristine Maven project configuration with an IDE plugin specific configuration that has nothing to do with the project in the first place.
So, the best solution is ditch Eclipse-based IDEs and switch to IntelliJ IDEA… because you either have idea, or don’t.
Leave a Reply