An open API service indexing awesome lists of open source software.

https://github.com/dbeaudoinfortin/mavenaarunpackplugin

Use Android Archive Libraries files directly in your Java Maven project!
https://github.com/dbeaudoinfortin/mavenaarunpackplugin

aar android android-library java maven maven-plugin

Last synced: 2 days ago
JSON representation

Use Android Archive Libraries files directly in your Java Maven project!

Awesome Lists containing this project

README

          

# Maven AAR Unpack Plugin

A Maven plugin for unpacking Android Archive Library (AAR) files. Makes your life easier when your Maven Java project needs to compile against Android system libraries but you can't or don't want to install the Android SDK locally.

## How to use

Add the following to the `plugins` section of your `pom.xml`:

```xml

io.github.dbeaudoinfortin
maven-aar-unpack-plugin
0.0.3


aar-unpack
process-sources
aar-unpack

```

Then declare the Android Archive Library (AAR) dependencies as type `aar` in the `dependencies` section of your `pom.xml`:

```xml

androidx.graphics
graphics-core
1.0.2
provided
aar

```

If your AAR comes from the Google Maven repository then you might need to declare it in the `repositories` section of your `pom.xml`:

```xml

google
https://maven.google.com

```

## How it works

This plugin executes in the `process-sources` lifecycle phase, prior to the compilation phase. It scans the Maven project for dependencies that are declared as type `aar` and resolves them. The resolved `.aar` files are each extracted to individual sub-directories in the `/target` directory. Each project dependency is then modified to be system scoped with a system path that references the `classes.jar` file extracted from the `.aar` file. Finally, all dependencies are forcefully re-resolved prior to compilation, adding them to the `classpath` of the Maven compiler plugin.

## Configuration Options

As an alternative to declaring AARs as project dependencies, they can be explicitly declared under the configuration property `aars`, in the Maven dependency coordinate format `:[:[:]]:`. For example:

```xml

io.github.dbeaudoinfortin
maven-aar-unpack-plugin
0.0.3


aar-unpack
process-sources


androidx.graphics:graphics-core:1.0.2
androidx.graphics:graphics-shapes-android:1.0.1



aar-unpack


```
When explicitly declaring AARs, project dependencies will not be scanned. Declaring AARs using both methods may cause compilation issues.

## Eclipse Support

If you use the Eclipse IDE, you'll want to use my M2E connector for this project. Without it your project will show build errors. You can manually download it from the releases section of my [M2EMavenAARPlugin](https://github.com/dbeaudoinfortin/M2EMavenAARPlugin/) but you may find it easier to [install it from a site](https://github.com/dbeaudoinfortin/M2EMavenAARPlugin/blob/main/README.md#how-to-install) in Eclipse.

## Requirements

- Requires Java 8 or later.

## Legal Stuff

Copyright (c) 2025 David Fortin

This software is provided by David Fortin under the MIT License, meaning you are free to use it however you want, as long as you include the original copyright notice (above) and license notice in any copy you make. You just can't hold me liable in case something goes wrong. License details can be read [here](https://github.com/dbeaudoinfortin/MavenAARUnpackPlugin?tab=MIT-1-ov-file)