Maven - shiraji/androidannotations GitHub Wiki
This page teaches you how to configure AndroidAnnotations on an Android project that uses Maven.
Please first read the Introduction page of the android-maven-plugin.
The pom.xml configuration is straightforward.
Add the following dependencies:
<dependencies>
<!-- [...] -->
<dependency>
<groupId>org.androidannotations</groupId>
<artifactId>androidannotations</artifactId>
<version>XXX</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.androidannotations</groupId>
<artifactId>androidannotations-api</artifactId>
<version>XXX</version>
</dependency>
</dependencies>
Make sure your project is built at least with Java 1.6:
<build>
<plugins>
<!-- [...] -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
- Configure Eclipse + Maven or IntelliJ + Maven
- Start using AndroidAnnotations
If you want to use snapshot versions of AndroidAnnotations, you should configure your project with the snapshot repository:
<dependencies>
<!-- [...] -->
<dependency>
<groupId>org.androidannotations</groupId>
<artifactId>androidannotations</artifactId>
<version>YYY-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.androidannotations</groupId>
<artifactId>androidannotations-api</artifactId>
<version>YYY-SNAPSHOT</version>
</dependency>
</dependencies>
<!-- [...] -->
<repositories>
<repository>
<id>snapshots-repository</id>
<name>Sonatype oss snapshot repo</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>
Some companies use a central nexus repository that works as a cache, so that all artifacts are downloaded from this repository to accelerate artifact download. Usually, you will find the following configuration in settings.xml :
<settings>
<mirrors>
<mirror>
<id>internal-repo</id>
<name>Maven 2 Repository</name>
<url>http://maven.mycompany.com/content/groups/mycompany</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
<!-- ... -->
</settings>
If you don't have access to the configuration of this repository to add AndroidAnnotations' repository, or if it takes time, don't panic, and change your settings.xml to match the following configuration :
<settings>
<mirrors>
<mirror>
<id>internal-repo</id>
<name>Maven 2 Repository</name>
<url>http://maven.mycompany.com/content/groups/mycompany</url>
<mirrorOf>*,!snapshots-repository</mirrorOf>
</mirror>
</mirrors>
<profiles>
<profile>
<id>AndroidAnnotationsRepository</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>snapshots-repository</id>
<name>Sonatype oss snapshot repo</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>
</profile>
</profiles>
</settings>
The key setting here is <mirrorOf>*,!snapshots-repository</mirrorOf>
, it says : "download everything from the central repository, except artifacts coming from the AndroidAnnotations repository".