5

When I try to import a maven project into eclispe juno I am getting the following error.jacoco maven error in eclipse.

I have the following lines in my pom.xml.

 </plugin>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>0.6.3.201306030806</version>
        <configuration>
          <destfile>${basedir}/target/jacoco/jacoco.exec</destfile>
          <datafile>${basedir}/target/jacoco/jacoco.exec</datafile>
        </configuration>
        <executions>
          <execution>
            <id>jacoco-initialize</id>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
          <execution>
            <id>jacoco-site</id>
            <phase>package</phase>
            <goals>
              <goal>report</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>

Why is maven giving this error? Any idea.

liv2hak
  • 14,472
  • 53
  • 157
  • 270

3 Answers3

8

The m2e plugin reports the error, because it can not find a m2e plugin that can handle the jacoco-maven-pluign configuration and execution within eclipse.

Thus the build on the command line via maven might lead to other results than the eclipse build.

You are using the jacoco-maven-plugin and I don't think it is necessarry to install a m2e plugin for jacoco.

You can either try to find a jacoco m2e adapter update site and install it or you move the jacoco-maven-plugin into a profile and only activate it when you need it.

EDIT

You can also tell the eclipse m2e plugin to ignore the jacoco-maven-plugin configuration. Add the follwing plugin configuration to the pluginManagement

<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.0,)</versionRange>
                                <goals>
                                    <goal>prepare-agent</goal>
                                    <goal>report</goal>
                                </goals>
                            </pluginExecutionFilter>
                            <action>
                                <ignore />
                            </action>
                        </pluginExecution>
                    </pluginExecutions>
                </lifecycleMappingMetadata>
            </configuration>
        </plugin>
    </plugins>
</pluginManagement>

This should work too.

You will find more information in the m2e documentation

René Link
  • 48,224
  • 13
  • 108
  • 140
  • How do I install that? – liv2hak Aug 25 '13 at 06:41
  • You can install it using eclipse Help -> Install New Software ... and enter the update site. Thus you install it like a "normal" eclipse plugin because it is one. Restart eclipse and the m2e error should disappear. – René Link Aug 25 '13 at 08:17
7

Install EclEmma plugin from the marketplace and reload projects

Damian
  • 437
  • 5
  • 11
  • Thanks! I've also tried pointing eclipse to my local maven installation, and adding this plugin is what finally fixed this error for me. – willcwf Feb 26 '16 at 17:12
  • 1
    This appears to be incorrect - as far as I can tell, installing the EclEmma Eclipse plugin does not include a m2e plugin that can handle the jacoco-maven-plugin configuration and execution within Eclipse. The correct solution is to use a m2e lifecycle mapping as described here http://stackoverflow.com/questions/14843892/jacoco-maven-plugin-plugin-execution-not-covered-by-lifecycle-configuration – vorburger Apr 18 '16 at 13:25
0
  1. Right click on the Maven project.

  2. Hover over the Maven option.

  3. Choose update project.

Worked for me, Hope it helps you too.

RobC
  • 22,977
  • 20
  • 73
  • 80