简体   繁体   中英

Create Android Archive Library(AAR) with maven only

I am developing a library project which I would like to distribute to other developers.

There have been many discussions on this topic on internet, people suggested to create a distribute version library project which contains only my library project's jar & other resources. It sounds good.

Then, I suddenly found there are people suggested to create Android Archive Library (AAR). But they all uses a tool named Gradle

I am using Eclipse with Maven for my Android library project. My question is, is it possible to generate AAR achieve for my android library project without using Gradle but only with Maven? If so, how?

The android-maven-plugin allows to package a project as aar-file.

From their documentation http://simpligility.github.io/android-maven-plugin/ :

Produce an AAR

If you have a bunch of Java code that you want to share then the best solution is to create a Java project and publish as a plain Java archive (ie jar).

But if you have code plus Android resources that you want to share then you really want to share that as an Android archive (ie AAR). Fortunately this is easy.

Just add configure your project to have packaging aar (and add the android-maven-plugin to build/plugins section of your maven project). Eg

<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.mycoolcompany</groupId>
  <artifactId>general-lib</artifactId>
  <version>1.2.3-SNAPSHOT</version>
  <packaging>aar</packaging>

  ...
</project>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM