60

I am trying to use the solution described here to solve the annoying "Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:build-helper-maven-plugin:1.7:add-source (execution: default, phase: generate-sources)" when I place the following plugin on my pom.xml:

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
    <execution>
        <phase>generate-sources</phase>
        <goals><goal>add-source</goal></goals>
        <configuration>
            <sources>
                <source>src/bootstrap/java</source>
            </sources>
        </configuration>
    </execution>
</executions>
</plugin>

But when I run mvn clean install I get this:

Reason: POM 'org.eclipse.m2e:lifecycle-mapping' not found in repository: Unable to download the artifact from any repository

Does anyone have a clue on how to make m2e and maven happy?

1

11 Answers 11

114

The org.eclipse.m2e:lifecycle-mapping plugin doesn't exist actually. It should be used from the <build><pluginManagement> section of your pom.xml. That way, it's not resolved by Maven but can be read by m2e.

But a more practical solution to your problem would be to install the m2e build-helper connector in eclipse. You can install it from the Window > Preferences > Maven > Discovery > Open Catalog. That way build-helper-maven-plugin:add-sources would be called in eclipse without having you to change your pom.xml.

10
  • 2
    Having the same issue but not quite sure what is meant by this answer, any chance of an example?
    – Edd Grant
    Oct 6, 2011 at 9:58
  • 1
    Does anyone know where one can find "the eclipse connector" for "org.scala-tools:maven-scala-plugin"? Mar 14, 2012 at 14:25
  • 2
    I think what he meant is actually build/pluginManagement section, not dependencyManagement. Jul 15, 2012 at 2:48
  • that's correct, Hendy, thanks for noticing the error. I edited my answer with the proper info. Jul 16, 2012 at 8:57
  • 2
    Fred, installing the build-helper connector didn't resolve the original "plugin execution not covered by lifecycle" error. But adding in the PluginManagement config does.
    – William
    Nov 19, 2012 at 14:03
11

Try using the build/pluginManagement section, e.g. :

<pluginManagement>
    <plugins>
        <plugin>
            <groupId>org.eclipse.m2e</groupId>
            <artifactId>lifecycle-mapping</artifactId>
            <version>1.0.0</version>
            <configuration>
                <lifecycleMappingMetadata>
                    <pluginExecutions>
                        <pluginExecution>
                            <pluginExecutionFilter>
                                <groupId>org.bsc.maven</groupId>
                                <artifactId>maven-processor-plugin</artifactId>
                                <versionRange>[2.0.2,)</versionRange>
                                <goals>
                                    <goal>process</goal>
                                </goals>
                            </pluginExecutionFilter>
                            <action>
                                <execute />
                            </action>
                        </pluginExecution>
                    </pluginExecutions>                         
                </lifecycleMappingMetadata>
            </configuration>
        </plugin>
    </plugins>
</pluginManagement>

Here's an example to generate bundle manifest during incremental compilation inside Eclipse :

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>org.apache.felix</groupId>
                                    <artifactId>maven-bundle-plugin</artifactId>
                                    <versionRange>[1.0.0,)</versionRange>
                                    <goals>
                                        <goal>manifest</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <execute />
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>2.3.7</version>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                </instructions>
            </configuration>
            <executions>
                <execution>
                    <id>manifest</id>
                    <phase>process-classes</phase>
                    <goals>
                        <goal>manifest</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

versionRange is required, if omitted m2e (as of 1.1.0) will throw NullPointerException.

1
  • Best solution so far. Just adding <pluginManagement> for org.eclipse.m2e below under <build> resolved the said issue Jun 4, 2016 at 18:25
9

You can use this dummy plugin:

mvn archetype:generate -DgroupId=org.eclipse.m2e -DartifactId=lifecycle-mapping -Dversion=1.0.0 -DarchetypeArtifactId=maven-archetype-mojo

After generating the project install/deploy it.

0
9

Here's how I do it: I put m2e's lifecycle-mapping plugin in a separate profile instead of the default <build> section. the profile is auto-activated during eclipse builds by presence of a m2e property (instead of manual activation in settings.xml or otherwise). this will handle the m2e cases, while command-line maven will simply skip the profile and the m2e lifecycle-mapping plugin without any warnings, and everybody is happy.

<project>
  ...
  <profiles>
    ...
    <profile>
      <id>m2e</id>
      <!-- This profile is only active when the property "m2e.version"
        is set, which is the case when building in Eclipse with m2e. -->
      <activation>
        <property>
          <name>m2e.version</name>
        </property>
      </activation>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.eclipse.m2e</groupId>
              <artifactId>lifecycle-mapping</artifactId>
              <version>1.0.0</version>
              <configuration>
                <lifecycleMappingMetadata>
                  <pluginExecutions>
                    <pluginExecution>
                      <pluginExecutionFilter>
                        <groupId>...</groupId>
                        <artifactId>...</artifactId>
                        <versionRange>[0,)</versionRange>
                        <goals>
                          <goal>...</goal>
                        </goals>
                      </pluginExecutionFilter>
                      <action>

                        <!-- either <ignore> XOR <execute>,
                          you must remove the other one. -->

                        <!-- execute: tells m2e to run the execution just like command-line maven.
                          from m2e's point of view, this is not recommended, because it is not
                          deterministic and may make your eclipse unresponsive or behave strangely. -->
                        <execute>
                          <!-- runOnIncremental: tells m2e to run the plugin-execution
                            on each auto-build (true) or only on full-build (false). -->
                          <runOnIncremental>false</runOnIncremental>
                        </execute>

                        <!-- ignore: tells m2eclipse to skip the execution. -->
                        <ignore />

                      </action>
                    </pluginExecution>
                  </pluginExecutions>
                </lifecycleMappingMetadata>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>
    ...
  </profiles>
  ...
</project>
5
  • There is absolutly no possibility to configure the lifecycle-mapping plugin for all plugins at once?
    – BlackEye
    Aug 13, 2014 at 9:39
  • @BlackEye You may add multiple pluginExecution entries for different plugins. Sep 3, 2014 at 11:30
  • 2
    You can generate this boilerplate XML by doing an auto-fix to "Ignore" the Maven error. Then change <ignore></ignore> to <execute><runOnIncremental>true</runOnIncremental></execute> Feb 6, 2015 at 14:38
  • Thanks for the info on the m2e.version property, couldn't find any documentation on that at all but it seems to work!
    – jazd
    Jun 6, 2019 at 20:40
  • Best answer. No idea about this property either. Dec 2, 2021 at 20:51
9

m2e 1.7 introduces a new syntax for lifecycle mapping metadata that doesn't cause this warning anymore:

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
    <execution>

        <!-- This executes the goal in Eclipse on project import.
             Other options like are available, eg ignore.  -->
        <?m2e execute?>

        <phase>generate-sources</phase>
        <goals><goal>add-source</goal></goals>
        <configuration>
            <sources>
                <source>src/bootstrap/java</source>
            </sources>
        </configuration>
    </execution>
</executions>
</plugin>
1
4

I have opened a (trivial) bug for this at m2e. Vote for it if you want the warning message to be gone for good...

https://bugs.eclipse.org/bugs/show_bug.cgi?id=367870

3

I was having the same issue, where:

No marketplace entries found to handle build-helper-maven-plugin:1.8:add-source in Eclipse. Please see Help for more information.

and clicking the Window > Preferences > Maven > Discovery > open catalog button would report no connection.

Updating from 7u40 to 7u45 on Centos 6.4 and OSX fixes the issue.

1

Suprisingly these 3 steps helped me:

mvn clean
mvn package
mvn spring-boot:run
0

Maven is trying to download m2e's lifecycle-mapping artifact, which M2E uses to determine how to process plugins within Eclipse (adding source folders, etc.). For some reason this artifact cannot be downloaded. Do you have an internet connection? Can other artifacts be downloaded from repositories? Proxy settings?

For more details from Maven, try turning M2E debug output on (Settings/Maven/Debug Output checkbox) and it might give you more details as to why it cannot download from the repository.

1
  • That artifact is just missing. I can download other artifacts. Is it gone for good? Sep 14, 2011 at 5:02
0

It happens due to a missing plugin configuration (as per vaadin's demo pom.xml comment):

This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.

<pluginManagement>
    <plugins>
        <!--This plugin's configuration is used to store Eclipse m2e ettings only. It has no influence on the Maven build itself.-->
        <plugin>
            <groupId>org.eclipse.m2e</groupId>
            <artifactId>lifecycle-mapping</artifactId>
            <version>1.0.0</version>
            <configuration>
                <lifecycleMappingMetadata>
                    <pluginExecutions>
                        <pluginExecution>
                            <pluginExecutionFilter>
                                <groupId>com.vaadin</groupId>
                                <artifactId>
                                    vaadin-maven-plugin
                                </artifactId>
                                <versionRange>
                                    [7.1.5,)
                                </versionRange>
                                <goals>
                                    <goal>resources</goal>
                                    <goal>update-widgetset</goal>
                                    <goal>compile</goal>
                                    <goal>update-theme</goal>
                                    <goal>compile-theme</goal>
                                </goals>
                            </pluginExecutionFilter>
                            <action>
                                <ignore></ignore>
                            </action>
                        </pluginExecution>
                    </pluginExecutions>
                </lifecycleMappingMetadata>
            </configuration>
        </plugin>
    </plugins>
</pluginManagement>
1
  • Some how adding <version> instead of <versionRange> doesn't get propagated to child modules. I had to use <versionRange> to get the child modules to behave.
    – NuCradle
    May 24, 2019 at 15:03
0

this step works on me : 1. Remove your project on eclipse 2. Re import project 3. Delete target folder on your project 4. mvn or mvnw install

1
  • Could you please arrange the steps in a proper format and elaborate your answer, this will help others to quickly go through your answer and understand it way better. Thank you :)
    – Ruchir
    Sep 15, 2019 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.