androidmaven-3maven-pluginpom.xmlapklib

How to generate .apklib and .apk in same maven build?


So I am using Android Maven Plugin to generate apklib snapshot for one of my library project. But the library project is also self sufficient to run on its own so I am thinking that may be we should generate .apklib and .apk both at the same time using maven.

Here is the pom configuration.

<groupId>com.comanyname.apps.lib</groupId>
<artifactId>MyProject-lib</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>apklib</packaging>
<name>MyProject-lib</name>

I tried adding another packaging like this

<groupId>com.comanyname.apps.lib</groupId>
<artifactId>MyProject-lib</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>apklib</packaging>
<packaging>apk</packaging>
<name>MyProject-lib</name>

I don't know if it is possible. I can switch the packaging to apk/apklib one at a time though.


Solution

  • So I was able to create apk and apklib by creating two profiles.

    <profiles>
            <profile>
                <id>local</id>
                <activation>
                    <activeByDefault>true</activeByDefault>
                </activation>
                <properties>
                    <projectVersion>1.0.0-SNAPSHOT</projectVersion>
                    <packagingType>apk</packagingType>
                </properties>
            </profile>
            <profile>
                <id>build</id>
                <properties>
                    <projectVersion>1.0.0-SNAPSHOT</projectVersion>
                    <packagingType>apklib</packagingType>
                </properties>
            </profile>
    </profiles>