maven

Installing a Jar in Maven local repository

You have to run the following command in the terminal:

mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \
-DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>

where:

path-to-file: is the path to the jar you want to install in the local repository

group-id: the group in the maven repository you want to use

artifact-id: the name that the jar will receive when you want to use it in a pom.xml

version: the version of the jar/library

packaging: the type of package it is, usually is a jar

Using Android Library Projects with Maven

Ok so I've decided to start with a new blog (again) and to make a good first post I'm going to explain how to use Android Library Projects integrated with Maven.

Your Android project has to have the android maven plugin in its pom.xml file in order to unpack the android library project that you are going to package as an apklib.

The first thing you have to make is go to the root directory of your Android Library Project, compress it all in a zip file, and rename to the extension apklib

The files included in this gist are the maven script to convert your new apklib file into a dependency in your maven repo and the second one is the structure to add the dependency on the android pom.xml file.

This is the script to generate the apklib in your local maven repository

mvn install:install-file \
  -DgroupId=org.abc \
  -DartifactId=mywidget \
  -Dpackaging=apklib \
  -Dversion=1.0.0 \
  -Dfile=mylib.apklib \
  -DgeneratePom=true

and this is how you add the dependency in your pom.xml

 <dependency>
    <groupId>org.abc</groupId>
    <artifactId>mywidget</artifactId>
    <version>1.0.0</version>    
    <type>mylib.apklib</type>
</dependency>