Java maven pom xml 文件中的错误:构建 Android 项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21016211/
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
Error in maven pom xml file: Building Android project
提问by Amrit Pal Singh
I am getting the error in plugin tag in pom xml file. The error is on plugin tag, before groupId.
我在 pom xml 文件中的插件标记中收到错误。错误在插件标签上,在 groupId 之前。
Error:-
错误:-
Plugin execution not covered by lifecycle configuration:com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.8.2:consume-aar (execution: default-consume-aar, phase: compile)
Any one knows how to resolve this problem. Below mentioned is the pom.xml file contents
任何人都知道如何解决这个问题。下面提到的是 pom.xml 文件内容
pom.xml file
pom.xml 文件
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.simpligility.android</groupId>
<artifactId>helloflashlight</artifactId>
<version>1.0.0</version>
<packaging>apk</packaging>
<name>HelloFlashlight</name>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<finalName>${project.artifactId}</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.8.2</version>
<extensions>true</extensions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
<sdk>
<!-- platform as api level (api level 16 = platform 4.1)-->
<platform>16</platform>
</sdk>
</configuration>
</plugin>
</plugins>
</build>
</project>
回答by blackbuild
Eclipse M2E warns you that your lifecycle contains an unknown plugin. M2E cannot decide, whether it is irrelevant and can be ignored or it is an integral part of your lifecycle.
Eclipse M2E 警告您您的生命周期包含一个未知插件。M2E 无法决定它是无关紧要的、可以忽略的还是您生命周期中不可或缺的一部分。
This information can either be provided as entry in your pom.xml, in a special lifecycle-file for your eclipse or by installing a specific configuration plugin, which is usually the best solution.
此信息可以作为 pom.xml 中的条目提供,也可以在 eclipse 的特殊生命周期文件中提供,或者通过安装特定的配置插件来提供,这通常是最佳解决方案。
In your case, there exists a configurator plugin for the android-maven-plugin, take a look at: http://rgladwell.github.io/m2e-android/, which should solve your problem quite neatly.
在您的情况下,android-maven-plugin 存在一个配置器插件,请查看:http: //rgladwell.github.io/m2e-android/,它应该可以非常巧妙地解决您的问题。
回答by gowtham
That is because of new m2eclipse plugin, a feature of it newly introduced.
那是因为新的 m2eclipse 插件,它新引入的一个特性。
For all the build executions that are specified in your pom.xml if there are respective config information in lifecycle-mapping-metadata.xml
file of m2eclipse plugin, It shows that error.
对于在 pom.xml 中指定的所有构建执行,如果lifecycle-mapping-metadata.xml
m2eclipse 插件的文件中有相应的配置信息,则会显示该错误。
You can get more info here
你可以在这里获得更多信息
You can ignore that error, that doesn't effect your project execution.
您可以忽略该错误,这不会影响您的项目执行。
回答by alexander
To silence the error in pom.xml the following could be added in there:
要消除 pom.xml 中的错误,可以在其中添加以下内容:
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<versionRange>[1.0.0,)</versionRange>
<goals>
<goal>consume-aar</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</pluginExecution>
</action>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
. . .
回答by myc1986
To solve the problem , we must add in the pom.xml all of the following elements :
为了解决这个问题,我们必须在 pom.xml 中添加以下所有元素:
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
</plugin>
Here is the final pom xml :
这是最终的 pom xml :
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>testMyc</groupId>
<artifactId>srgfrzfd</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>apk</packaging>
<name>srgfrzfd</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<platform.version> 4.1.1.4
</platform.version>
<android.plugin.version>3.8.2</android.plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>${platform.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>${android.plugin.version}</version>
<extensions>true</extensions>
</plugin>
</plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
</plugin>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
<sdk>
<platform>16</platform>
</sdk>
</configuration>
</plugin>
</plugins>
</build>
</project>
and the following tag in the "lifecycle-mapping-metadata.xml" file that is in the "Windows" > and preferably maven > lifecycle mapping > " Open workspace lifecycle mapping metadata " eclipse menu
以及“Windows”中的“lifecycle-mapping-metadata.xml”文件中的以下标记>最好是maven>生命周期映射>“打开工作区生命周期映射元数据”eclipse菜单
<?xml version="1.0" encoding="UTF-8"?>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<versionRange>[1.0.0,)</versionRange>
<goals>
<goal>consume-aar</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
Save the file in your workspace in use .
将文件保存在您的工作区中使用。
Answer supplied set by myc1986
由 myc1986 提供的答案
回答by Ricardo Gladwell
As of Maven Eclipse(m2e) version 0.12 all Maven life-cycle goals must map to an installed m2e extension. In this case, the android-maven-pluginadded a new goal, consume-aar
to support the new Android Library archive format.
从Maven Eclipse(m2e) 0.12 版开始,所有 Maven 生命周期目标都必须映射到已安装的 m2e 扩展。在这种情况下,android-maven-plugin添加了一个新目标,consume-aar
以支持新的 Android 库存档格式。
The Android for Maven Eclipse(m2e-android) plugin does not have AAR support yet (because Google have not added AAR support to the ADT yet) so this goal is unmapped and this is why you're getting this error message.
在Android的对Maven的Eclipse(M2E-机器人)插件没有AAR的支持,但(在ADT因为谷歌还没有添加AAR还支持),所以这个目标是映射的,这就是为什么你收到此错误消息。
You can exclude un-mapped life-cycle goals by simply following the instructions here:
您只需按照此处的说明操作即可排除未映射的生命周期目标:
https://wiki.eclipse.org/M2E_plugin_execution_not_covered
https://wiki.eclipse.org/M2E_plugin_execution_not_covered
Alternatively, simply right-click on the error message in Eclipse and choosing Quick Fix
-> Ignore for every pom with such errors
.
或者,只需右键单击 Eclipse 中的错误消息并选择Quick Fix
-> Ignore for every pom with such errors
。