android-maven-plugin打包失败了,分层项目和apklib依赖

时间:2014-02-17 14:48:26

标签: android maven android-maven-plugin apklib

我有一个主根项目让我们把它称为A在哪里是pom.xml,包含所有模块的列表和包装pom的类型

<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.example</groupId>
<artifactId>A</artifactId>
<version>0.0.1</version>
<packaging>pom</packaging>

<properties>
    <android.version>4.1.1.4</android.version>
    <android.target.version>17</android.target.version>
    <android.plugin.version>3.6.0</android.plugin.version>
    <android.roboelectric.version>2.2</android.roboelectric.version>
    <android.support.version.4>r7</android.support.version.4>
</properties>

<modules>
    <module>AA</module>
    <module>AB</module>
</modules>

这个项目有两个孩子,以免说项目AA和AB也有poms

项目AA是包装类型apklib并且有编译安装的nop问题也在android-maven-plugin(android:apklib)这里是pom

<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
    <groupId>com.example</groupId>
    <artifactId>A</artifactId>
    <version>0.0.1</version>
</parent>

<groupId>com.example</groupId>
<artifactId>AB</artifactId>
<packaging>apklib</packaging>

<build>
    <finalName>${project.artifactId}-${project.parent.version}</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>
    </pluginManagement>
    <plugins>
        <plugin>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <configuration>
                <sdk>
                    <platform>17</platform>
                    <path>${env.ANDROID_HOME}</path>
                </sdk>
            </configuration>
        </plugin>
    </plugins>
</build>

项目AB依赖于项目AA,如plow那样

<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
    <groupId>com.example</groupId>
    <artifactId>A</artifactId>
    <version>0.0.1</version>
</parent>

<groupId>com.example</groupId>
<artifactId>AB</artifactId>
<packaging>apklib</packaging>

<dependencies>
    <dependency>
        <groupId>com.examplet</groupId>
        <artifactId>AA</artifactId>
        <version>0.0.1</version>
        <type>apklib</type>
    </dependency>
</dependencies>

<build>
    <finalName>${project.artifactId}-${project.version}</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>
    </pluginManagement>
    <plugins>
        <plugin>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <configuration>
                <sdk>
                    <platform>17</platform>
                </sdk>
            </configuration>
        </plugin>
    </plugins>
</build>

在包装过程中甚至是android:apklib我发布了类似这样的错误

  

无法在项目util上执行目标:无法解析依赖项   对于项目com.example.AB:apklib:0.0.1:无法收集   [com.example.AA:apklib:0.0.1(已提供)]的依赖项:失败   读取com.example.AA的工件描述符:apklib:0.0.1:不能   find artifact com.example:A:pom:0.0.1 in central   (http://repo.maven.apache.org/maven2) - &gt; [帮助1]

我在项目AA上运行了mvn install,看起来已经安装在.m2

有什么想法吗?提前谢谢。

1 个答案:

答案 0 :(得分:0)

好的,我解决了问题,问题是我在没有安装的情况下更改了root pom,所以我再次运行mvn install on root project并解决了这个问题。