且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Eclipse Maven错误插件执行不被生命周期配置所覆盖:

更新时间:2023-09-18 11:33:10

更新的m2e版本如果Maven插件不提供m2e生命周期映射。较新的插件提供商通过其JAR中的文件 META-INF / m2e / lifecycle-mapping-metadata.xml 进行映射。如果此文件不存在,则Eclipse会抱怨。



通过为POM添加旧插件的生命周期映射,可能会降低这些投诉。在给定的示例中,此映射在配置文件中完成,当配置文件在Eclipse中运行时(m2e.version属性已设置),该配置文件会自动激活,并且在正常的maven构建完成时,该配置文件不起作用。

 <个人资料> 
<个人资料>
< id> m2e< / id>
< activate>
< property>
< name> m2e.version< / name>
< / property>
< / activation>
< build>
< pluginManagement>
< plugins>
< plugin>
< groupId> org.eclipse.m2e< / groupId>
< artifactId>生命周期映射< / artifactId>
< version> 1.0.0< / version>
< configuration>
< lifecycleMappingMetadata>
< pluginExecutions>
< pluginExecution>
< pluginExecutionFilter>
< groupId> org.bsc.maven< / groupId>
< artifactId> maven-processor-plugin< / artifactId>
< versionRange> [2.0.6,)< / versionRange>
< goals>
< goal>进程< / goal>
< / goals>
< / pluginExecutionFilter>
< action>
< ignore />
< / action>
< / pluginExecution>
< / pluginExecutions>
< / lifecycleMappingMetadata>
< / configuration>
< / plugin>
< / plugins>
< / pluginManagement>
< / build>
< / profile>

上面的示例禁用了Eclipse构建中的插件。也可以通过指定< execute /> 作为动作来实现。



请注意, em> pluginExecutionFilter 必须匹配插件和您要映射的插件的目标。可以指定多个 pluginExecution 元素来映射不同的插件。


I am using Eclipse Juno with Maven 3.0.5 on Windows 7. The project was previously on Windows XP and I have moved to Windows 7 64 bit machine.

I have copied my Eclipse Spring 3, Hibernate 4 and JSF 2.0 project and when I try to compile I am getting the following error

Plugin execution not covered by lifecycle configuration: 
org.bsc.maven:maven-processor-plugin:2.0.6:process (execution: process, phase: 
generate-sources)

I tried as mentioned in this thread by adding the following in Eclipse.ini file, however it didn't solve the issue.

-vm
c:\Program Files\Java\jdk1.7.0_21\jre\bin\server\jvm.dll

Tried building maven install and clean, but problem still persists.

How can I resolve this issue? Any help is highly appreciable.

Thanks

Maven snippet

<plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>              
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <compilerArgument>-proc:none</compilerArgument>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.bsc.maven</groupId>
                <artifactId>maven-processor-plugin</artifactId>
                <version>2.0.6</version>
                <executions>
                    <execution>
                        <id>process</id>
                        <goals>
                            <goal>process</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                            <!-- source output directory -->
                            <outputDirectory>target/metamodel</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>

Newer versions of m2e complain if a Maven plugin does not provide a m2e lifecycle mapping. Newer plugins provider such a mapping via the file META-INF/m2e/lifecycle-mapping-metadata.xml in their JAR. If this file is not present, then Eclipse complains.

It is possible quite down these complaints by adding a lifecycle mapping for older plugins to your POM. In the given example, this mapping is done inside a profile which is automatically activated when a build is running in Eclipse (m2e.version property is set) and it is not active when a regular maven build is done.

<profiles>
  <profile>
    <id>m2e</id>
    <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>org.bsc.maven</groupId>
                      <artifactId>maven-processor-plugin</artifactId>
                      <versionRange>[2.0.6,)</versionRange>
                      <goals>
                        <goal>process</goal>
                      </goals>
                    </pluginExecutionFilter>
                    <action>
                      <ignore />
                    </action>
                  </pluginExecution>
                </pluginExecutions>
              </lifecycleMappingMetadata>
            </configuration>
          </plugin>         
        </plugins>
      </pluginManagement>
    </build>
  </profile>

The example above disables the plugin in Eclipse builds. It is also possible enable it by specifying <execute /> as action .

Mind that the settings under pluginExecutionFilter must match the plugin and the goals of the plugin that you wish to map. Multiple pluginExecution elements can be specified to map different plugins.