0

我有主根项目,我们称它为 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,并且在 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 依赖于 pom 中的项目 AA,如下所示

<?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 的工件描述符:在中央 ( http://repo.maven.apache.org/maven2 )中找不到工件 com.example:A:pom:0.0.1 -> [帮助1]

我已经在项目 AA 上运行 mvn install 并且看起来它安装在 .m2 中

有任何想法吗?提前致谢。

4

1 回答 1

0

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

于 2014-02-17T15:00:02.610 回答