Android Artifacts hit Maven Central

It all started now quite a while ago when I got involved with the Maven Android Plugin and found that having to run a bunch of mvn install file commands sucked. I launched a ticket in the Android issue tracker that got rejected by Google even though there was clearly a community demand for the Android jar artifact to hit Maven central. As a next best step I created the Maven Android SDK Deployer and things cruised along okay for a bit. And then out of the blue Robert Manning, from the awesome SQuirrel SQL Client project, contacted me about the status and issues with getting the jars into Maven central if they are built from the open source code drop. And with Robert things really moved.

Initially we were concerned that we would have to verify the correctness of the jar and that might be a huge hazzle. Robert however did not despair and came up with the great approach of using the standard build process for Android. Then repackaging the jars and associated artifacts to a bundle suitable for upload to Maven central via the Sonatype open source sync. All this can be seen in the Android4Maven project. After much back and forth, explanations about the different contents of the jars, scripting and running the builds on Roberts side and testing we succeeded! As of today Maven central hosts the Android jar artifacts including source and javadoc packages for Android 1.5_r3, 1.5_r4, 1.6_r2 and 2.1_r1. As soon as 2.2. hits the git repos it will follow.

In order to use the artifacts in your project you will have to use a dependency like this

<dependency>
  <groupId>com.google.android</groupId>
  <artifactId>android</artifactId>
  <version>1.5_r4</version>
  <scope>provided</scope>
</dependency>

with the correct version number for your project.

If you are using some of the unit and instrumentation test classes you will have to also add a dependency to the android-test artifact like that

<dependency>
  <groupId>com.google.android</groupId>
  <artifactId>android-test</artifactId>
  <version>1.5_r4</version>
  <scope>provided</scope>
</dependency>

To see more examples of the usage check out my fork of the Maven Android Plugin Samples, that will probably be pulled upstream soon.

So with this step it got even easier to start a Android project and build it with Maven taking advantages of the power of the Maven Android Plugin and all the other plugins available to Maven users. It also means that other build systems like ivy, gradle and so on can take advantage of the artifacts. In the next while I will update the documentation in the book Maven: The Complete Reference, the wiki pages of the plugin and the Maven Android SDK Deployer. Until then update your project, enjoy and if you find any issues make sure to let us know.

Thanks again for Robert Manning for taking this on and gloriously succeeding and Brian Fox, Hugo Josefson, Juven Xu and Fabrizio Giudici for helping us.