eclipse 如何消除eclipse的“maven-enforcer-plugin(目标“enforce”)被m2e忽略”警告?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13040788/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to eliminate the "maven-enforcer-plugin (goal "enforce") is ignored by m2e" warning by eclipse?
提问by ams
I am configuring a multi-module parent child maven project using maven and eclipse m2e, I am using the latest stuff from eclipse Juno SR1 which is m2e 1.2.0
我正在使用 maven 和 eclipse m2e 配置一个多模块父子 maven 项目,我正在使用来自 eclipse Juno SR1 的最新东西,即 m2e 1.2.0
the parent pom uses the enforcer plugin, so the parent pom.xml has the following in its plugin section
父 pom 使用执行器插件,因此父 pom.xml 在其插件部分具有以下内容
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.1.1</version>
<executions>
<!-- Enforce that all versions of a transative dependency must converge. -->
<execution>
<id>enforce</id>
<configuration>
<rules>
<DependencyConvergence />
</rules>
</configuration>
<goals>
<goal>enforce</goal>
</goals>
</execution>
<!-- Black list certain jars -->
<execution>
<id>enforce-banned-dependencies</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<bannedDependencies>
<excludes>
<exclude>
commons-logging:commons-logging
</exclude>
</excludes>
</bannedDependencies>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
Each of the child projects has an error message saying maven-enforcer-plugin (goal "enforce") is ignored by m2e.
每个子项目都有一条错误消息说 maven-enforcer-plugin (goal "enforce") is ignored by m2e.
- What is the meaning of this message?
- How do I configure things to get rid of this message?
- do I need to configure the eclipse project settings or the pom.xml settings?
- 这条消息的含义是什么?
- 如何配置东西以摆脱此消息?
- 我需要配置 eclipse 项目设置还是 pom.xml 设置?
回答by ams
The eclipse maven plugin runs a projects pom.xml file in order figure out how the maven project is configured and translate the maven pom.xml configuration into an eclipse configuration. A pom.xml can reference an arbitrary number of maven plugins and each of those plugins has the potential to leak memory, or do things that are harmful to eclipse. So by default the m2e eclipse plugin ignores any maven plugins unless those maven plugins have a special m2e plugin connector that tells m2e how to integrate the maven plugin into eclipse. In summary m2e is defending the eclipse JVM process against a buggy maven plugin, by saying that for every maven plugin there needs to be an m2e connector to bridge between maven and eclipse.
eclipse maven 插件运行一个项目 pom.xml 文件,以确定 maven 项目是如何配置的,并将 maven pom.xml 配置转换为 eclipse 配置。pom.xml 可以引用任意数量的 maven 插件,每个插件都有可能泄漏内存,或者做一些对 eclipse 有害的事情。所以默认情况下,m2e eclipse 插件会忽略任何 maven 插件,除非那些 maven 插件有一个特殊的 m2e 插件连接器,告诉 m2e 如何将 maven 插件集成到 eclipse 中。总之,m2e 正在保护 eclipse JVM 进程免受有缺陷的 maven 插件的影响,通过说对于每个 maven 插件都需要有一个 m2e 连接器来桥接 maven 和 eclipse。
So to get rid of the warning I added the following to my plugin management section of the parent pom.xml
因此,为了摆脱警告,我将以下内容添加到父 pom.xml 的插件管理部分
<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.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<versionRange>[1.0.0,)</versionRange>
<goals>
<goal>enforce</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
It seems that org.eclipse.m2e:lifecycle-mapping
is a maven plugin designed to hold meta data to communicate with eclipse m2e plugin when it processes a maven pom.xml and this information is used to tell eclipse what do with maven plugins that are defined in pom.xml when eclipse runs the pom.xml as part of the eclipse UI.
这似乎org.eclipse.m2e:lifecycle-mapping
是一个 maven 插件,旨在在处理 maven pom.xml 时保存元数据以与 eclipse m2e 插件通信,并且此信息用于告诉 eclipse 在 eclipse 运行 pom.xml 时如何处理 pom.xml 中定义的 maven 插件pom.xml 作为 Eclipse UI 的一部分。
回答by afischer
From m2e version 1.4 and higher: You can integrate the needed lifecycle-configuration within the pom (parent-pom or project-pom) or you can integrate the informations into the global m2e-configuration within eclipse. Also you have some quickfix-actions for applying this changes.
从 m2e 1.4 及更高版本开始:您可以在 pom(父 pom 或项目 pom)中集成所需的生命周期配置,或者您可以将信息集成到 eclipse 中的全局 m2e 配置中。此外,您还有一些用于应用此更改的快速修复操作。
The last option is to look for m2e-connectors or to switch over to newer versions of different maven-plugins with integrated m2e-support (e.g. for jaxb-plugins).
最后一个选项是寻找 m2e-connectors 或切换到具有集成 m2e-support(例如 jaxb-plugins)的不同 maven-plugins 的较新版本。
Here (for enforcer-plugin) I think, the definition in the pom is the easiest way.
这里(对于enforcer-plugin)我认为,pom 中的定义是最简单的方法。
See also: https://www.eclipse.org/m2e/documentation/m2e-execution-not-covered.html
另见:https: //www.eclipse.org/m2e/documentation/m2e-execution-not-covered.html
回答by rmp
Just an FYI for those of you that have an issue with configuring your IDE in your build model. Keep an eye on this enhancement request currently targeted for the Kepler release:
对于在构建模型中配置 IDE 有问题的人,仅供参考。请密切关注当前针对 Kepler 版本的增强请求:
Bug 350414: Store ignored m2e connectors outside project pom.xmlhttps://bugs.eclipse.org/bugs/show_bug.cgi?id=350414
错误 350414:在项目 pom.xml 之外存储忽略的 m2e 连接器https://bugs.eclipse.org/bugs/show_bug.cgi?id=350414
回答by tosha Shah
For me it was similar issue
对我来说这是类似的问题
I had maven 3.0.3 and java 1.5
我有 maven 3.0.3 和 java 1.5
and my pom had
我的 pom 有
<executions>
<execution>
<id>enforce-versions</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>[3.0.3,2.2.1,)</version>
</requireMavenVersion>
<requireJavaVersion>
<version>[1.7, 1.8)</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
As you can see I dont really have met rules, hence I updated Java and got mvn going and I was all set. Hope this helps someone.
正如你所看到的,我并没有真正满足规则,因此我更新了 Java 并让 mvn 运行,我一切都准备好了。希望这可以帮助某人。
回答by sm?n
Another pitfall exists when having several pluginExecutionFilters. These must be at the right spot in the pom.xml! For me it was gnarly to find as no error or warning of the displacement existed.
当有多个 pluginExecutionFilters 时存在另一个陷阱。这些必须在 pom.xml 中的正确位置!对我来说,发现不存在位移的错误或警告是很困难的。
This is the right code for having several pluginExecutionFilters:
这是具有多个 pluginExecutionFilters 的正确代码:
<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.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<versionRange>[1.0.0,)</versionRange>
<goals>
<goal>enforce</goal>
</goals>
</pluginExecutionFilter>
<action><ignore/></action>
</pluginExecution>
<!-- now here follows the new filter -->
<pluginExecution>
<pluginExecutionFilter>
<groupId>com.googlecode.maven-java-formatter-plugin</groupId>
...
回答by Gray
How to eliminate the “maven-enforcer-plugin (goal ”enforce“) is ignored by m2e” warning by eclipse?
如何消除eclipse的“maven-enforcer-plugin(目标”enforce“)被m2e忽略”警告?
Although the eclipse lifecycle-mapping
plugin has worked for me on other projects, I can't change the pom.xml
since I am currently working in an IntelliJ shop with my covert instance of Eclipse and I don't want to expose myself by changing all of their pom files to include anything from group org.eclipse.m2e
.
尽管 eclipselifecycle-mapping
插件在其他项目上对我有用,但我无法更改它,pom.xml
因为我目前正在 IntelliJ 商店使用我的 Eclipse 隐蔽实例,而且我不想通过将所有 pom 文件更改为暴露自己包括 group 中的任何内容org.eclipse.m2e
。
After some experimentation, I've found that you can get this warning to not show up by changing the Lifecycle Mappings in the Maven preferences. Frankly I'm not 100% sure what this is doing but I've not seen any side effects so...
经过一些实验,我发现您可以通过更改 Maven 首选项中的生命周期映射来使此警告不显示。坦率地说,我不是 100% 确定这是在做什么,但我没有看到任何副作用,所以......
- In Eclipse, go to: Preferences → Maven → Lifecycle Mappings.
Clicking
Open workspace lifecycle mappings metadata
which will open thelifecycle-mapping-metadata.xml
file in a tab in the background. I assume that this cooresponds to the following file under your workspace subdir:.metadata/.plugins/org.eclipse.m2e.core/lifecycle-mapping-metadata.xml
Next add the following stanza to the bottom of the file inside of
<pluginExecutions>...</pluginExecutions>
.<pluginExecution> <pluginExecutionFilter> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-enforcer-plugin</artifactId> <versionRange>[1.0.0,)</versionRange> <goals> <goal>enforce</goal> </goals> </pluginExecutionFilter> <action> <ignore /> </action> </pluginExecution>
Once the XML file is saved you will need to go back to the preferences window and press
Reload workspace lifecycle mappings metadata
which compiles the file somehow.- Finally you will need to do a maven update-project on all of your projects to see the warnings go away.
- 在 Eclipse 中,转到:首选项 → Maven → 生命周期映射。
单击
Open workspace lifecycle mappings metadata
这将lifecycle-mapping-metadata.xml
在后台的选项卡中打开文件。我假设这对应于您的工作区子目录下的以下文件:.metadata/.plugins/org.eclipse.m2e.core/lifecycle-mapping-metadata.xml
接下来将以下节添加到
<pluginExecutions>...</pluginExecutions>
.<pluginExecution> <pluginExecutionFilter> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-enforcer-plugin</artifactId> <versionRange>[1.0.0,)</versionRange> <goals> <goal>enforce</goal> </goals> </pluginExecutionFilter> <action> <ignore /> </action> </pluginExecution>
保存 XML 文件后,您将需要返回首选项窗口并按
Reload workspace lifecycle mappings metadata
它以某种方式编译文件。- 最后,您需要对所有项目执行 maven update-project 以查看警告消失。
Hope this helps.
希望这可以帮助。