Automating the Build in Jenkins with Ant - PerfectCarl/androidannotations GitHub Wiki
Most methods for building with the Java 6 annotation processor involve copying ant code out of the Android SDK directory and modifying it. This method works but it seems like it may cause trouble down the road. This method sets build properties and implements empty ant targets to enable AndroidAnnotations to build in ant.
If you already have your project set up in Eclipse then open up a terminal window in your project directory and issue:
android update project --name MyApp --target android-8 --path .
If that does not work for you then please complete the reading available at Android Command Line Reference
Create a file named ant.properties in your project directory with the following contents
java.target=1.6
java.source=1.6
source.dir = src;.apt_generated
The build.xml file generated by the android tools has a view targets that do not have any instructions in them. These targets are called by the main build.xml by including a file called custom_rules.xml. The following is the contents of my custom_rules.xml which is in my project directory.
<?xml version="1.0" encoding="UTF-8"?>
<project name="Clinkle_custom" default="help">
<property name="apt_generated.dir" value="${basedir}/.apt_generated/" />
<target name="-pre-clean">
<delete dir="${apt_generated.dir}" verbose="${verbose}" />
<mkdir dir="${apt_generated.dir}" />
</target>
<target name="-pre-compile">
<echo>-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=</echo>
<echo> AndroidAnnotations is generating code </echo>
<echo>-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=</echo>
<javac encoding="${java.encoding}"
source="${java.source}" target="${java.target}"
debug="true" extdirs="" includeantruntime="false"
destdir="${out.classes.absolute.dir}"
bootclasspathref="android.target.classpath"
verbose="${verbose}"
classpath="${extensible.classpath}"
classpathref="project.libraries.jars"
fork="${need.javac.fork}">
<src path="${source.absolute.dir}" />
<src path="${gen.absolute.dir}" />
<classpath>
<fileset dir="libs" includes="*.jar" />
<fileset dir="ext-libs" includes="*.jar" />
</classpath>
<compilerarg value="-proc:only" />
<compilerarg value="-processor" />
<compilerarg value="com.googlecode.androidannotations.AndroidAnnotationProcessor" />
<compilerarg value="-s" />
<compilerarg value="${apt_generated.dir}" />
</javac>
<echo>-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=</echo>
</target>
</project>
MyProject/
.apt_generated/
.classpath
.factorypath
.project
.settings/org.eclipse.jdt.apt.core.prefs
.settings/org.eclipse.jdt.core.prefs
AndroidManifest.xml
ant.properties
build.xml
custom_rules.xml
ext-libs/androidannotations-2.5.1.jar
libs/androidannotations-2.5.1-api.jar
libs/androlog-1.0.1.jar
local.properties
project.properties
res/
src/
test/