m2e lifecycle-mapping not found

Maven 2MavenMaven PluginM2eclipseM2e

Maven 2 Problem Overview


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?

Maven 2 Solutions


Solution 1 - Maven 2

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.

Solution 2 - Maven 2

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.

Solution 3 - Maven 2

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.

Solution 4 - Maven 2

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>

Solution 5 - Maven 2

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>

Solution 6 - Maven 2

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

Solution 7 - Maven 2

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.

Solution 8 - Maven 2

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.

Solution 9 - Maven 2

Suprisingly these 3 steps helped me:

mvn clean
mvn package
mvn spring-boot:run

Solution 10 - Maven 2

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>

Solution 11 - Maven 2

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTraderJoeChicagoView Question on Stackoverflow
Solution 1 - Maven 2Fred BriconView Answer on Stackoverflow
Solution 2 - Maven 2Hendy IrawanView Answer on Stackoverflow
Solution 3 - Maven 2Manfred HantschelView Answer on Stackoverflow
Solution 4 - Maven 2Robin479View Answer on Stackoverflow
Solution 5 - Maven 2Arend v. ReinersdorffView Answer on Stackoverflow
Solution 6 - Maven 2BenView Answer on Stackoverflow
Solution 7 - Maven 2user145880View Answer on Stackoverflow
Solution 8 - Maven 2prungeView Answer on Stackoverflow
Solution 9 - Maven 2tolgaView Answer on Stackoverflow
Solution 10 - Maven 2falsarellaView Answer on Stackoverflow
Solution 11 - Maven 2Amelia MaulanyView Answer on Stackoverflow