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?

falsarella
  • 12,217
  • 9
  • 69
  • 115
TraderJoeChicago
  • 6,205
  • 8
  • 50
  • 54
  • Potential solution for future readers, perhaps not for the original question though: http://stackoverflow.com/a/23707050/1590950 – indivisible Jun 02 '15 at 07:43

11 Answers11

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.

falsarella
  • 12,217
  • 9
  • 69
  • 115
Fred Bricon
  • 5,369
  • 1
  • 31
  • 45
  • 2
    Having the same issue but not quite sure what is meant by this answer, any chance of an example? – Edd Grant Oct 06 '11 at 09:58
  • 1
    Does anyone know where one can find "the eclipse connector" for "org.scala-tools:maven-scala-plugin"? – Ustaman Sangat Mar 14 '12 at 14:25
  • 2
    I think what he meant is actually build/pluginManagement section, not dependencyManagement. – Hendy Irawan Jul 15 '12 at 02:48
  • that's correct, Hendy, thanks for noticing the error. I edited my answer with the proper info. – Fred Bricon Jul 16 '12 at 08: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 '12 at 14:03
  • It's possible the buildhelper connector doesn't support the config you set in you pom.xml. But I'd make sure "Maven > Update project" (after removing the config) really doesn't fix the error marker before saying it's broken. You should paste here your buildhelper plugin configuration snippet – Fred Bricon Nov 20 '12 at 21:41
  • @Fred Bricon, i have the exact same issue, but i do have the `org.eclipse.m2e` specification in the `build/pluginManagement` section. i'm running his goal, trying to deploy my web service to a local tomcat installation as part of the maven build process. that being said, why would i still have this issue, especially if that snippet was generated by an apache archetype? – liltitus27 Dec 11 '13 at 21:40
  • I'd need to see some sample pom to understand what is happening – Fred Bricon Dec 11 '13 at 22:11
  • What about CI builds? – demaniak Nov 18 '14 at 08:36
  • plugins defined in build/pluginManagement/plugins are not resolved during CLI builds, only in build/plugins (you can run mvn help:effective-pom to see what plugins are active). So CI builds totally ignore org.eclipse.m2e:lifecycle-mapping from the pluginManagement section. – Fred Bricon Nov 19 '14 at 17:14
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.

Hendy Irawan
  • 20,498
  • 11
  • 103
  • 114
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>
Robin479
  • 1,606
  • 15
  • 16
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>
billc.cn
  • 7,187
  • 3
  • 39
  • 79
Arend v. Reinersdorff
  • 4,110
  • 2
  • 36
  • 40
  • 1
    **N.B. this syntax will fail to deploy to Sonatypes Maven Central**: https://issues.sonatype.org/browse/OSSRH-56004 – Adam Gent Nov 07 '22 at 18:14
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.

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

Ben
  • 4,785
  • 3
  • 27
  • 39
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.

user145880
  • 31
  • 1
1

Suprisingly these 3 steps helped me:

mvn clean
mvn package
mvn spring-boot:run
tolga
  • 2,462
  • 4
  • 31
  • 57
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>
falsarella
  • 12,217
  • 9
  • 69
  • 115
  • Some how adding `` instead of `` doesn't get propagated to child modules. I had to use `` to get the child modules to behave. – NuCradle May 24 '19 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

  • 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 '19 at 08:33
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.

prunge
  • 22,460
  • 3
  • 73
  • 80