androidmavenandroid-maven-pluginapklib

android-maven-plugin packaging failed with hierarchical project and apklib dependency


I have main root project let's call it as A where is pom.xml with list of all modules and type of packaging 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>

This project has two children lest say project AA and AB also with poms

project AA is packaging type apklib and has nop problems with compilation installation also over android-maven-plugin (android:apklib) here is 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>

project AB has dependency to project AA in pom like bellow

<?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>

During packaging or even android:apklib I'm geeting error something like this

Failed to execute goal on project util: Could not resolve dependencies for project com.example.AB:apklib:0.0.1: Failed to collect dependencies for [com.example.AA:apklib:0.0.1 (provided)]: Failed to read artifact descriptor for com.example.AA:apklib:0.0.1: Could not find artifact com.example:A:pom:0.0.1 in central (http://repo.maven.apache.org/maven2) -> [Help 1]

I have runned mvn install on project AA and looks that it's installed in .m2

Any ideas? Thanks in advance.


Solution

  • Ok I resolved the issue the problem was that I have changed root pom without installing it so I just runned once again mvn install on root project and that resolved the issue.