m2e lifecycle-mapping not found

前端 未结 11 721
时光说笑
时光说笑 2020-11-29 00:24

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

相关标签:
11条回答
  • 2020-11-29 00:37

    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.

    0 讨论(0)
  • 2020-11-29 00:38

    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>
    
    0 讨论(0)
  • 2020-11-29 00:49

    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.

    0 讨论(0)
  • 2020-11-29 00:51

    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 讨论(0)
  • 2020-11-29 00:52

    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.

    0 讨论(0)
  • 2020-11-29 00:53

    Suprisingly these 3 steps helped me:

    mvn clean
    mvn package
    mvn spring-boot:run
    
    0 讨论(0)
提交回复
热议问题