Permalink
Browse files

Update build system to be compatible with SDK r14 and up

  • Loading branch information...
1 parent 30d1c3c commit ab46f6839fa9eb892819a3281dc30cc28c402c09 @sattvik sattvik committed Nov 30, 2011
View
32 README.rst
@@ -50,7 +50,16 @@ __ https://github.com/sattvik/clojure/tree/android-1.2.x
Android SDK Tools
Neko has been developed with the latest revision of the Android SDK tools,
- but should generally be compatible with all recent versions.
+ and is compatible with r14 and up of the Android SDK.
+
+.. WARNING::
+ Revision 14 of the Android SDK introduced some major changes in the Ant
+ build system. Neko has been updated to use the new build system. You will
+ probably need to change your project if you have been using an older version
+ of Neko/SDK. For more detailed information, `check the Android Tools
+ Project Site`__.
+
+__ http://tools.android.com/recent/buildchangesinrevision14
Android Platform SDK 7 (2.1/Eclair) or newer
In order to maintain backwards-compatibility, Neko does not support any APIs
@@ -66,14 +75,23 @@ project’s build and allow you to use the libraries within your application.
Build support
-------------
-To use Neko’s build support for Clojure, you will need to modify your project’s
-``build.xml`` file by adding a line to similar to the following::
+To use Neko’s build support for Clojure, you will need to make two
+modifications to your project’s
+``build.xml`` file.
+
+1. You must add a line to similar to the following
+ **before the line with
+ ``<import file="${sdk.dir}/tools/ant/build.xml" />``**.::
+
+ <import file="/path/to/neko/build-support/clojure.xml"/>
- <import file="/path/to/neko/build-support/clojure.xml"/>
+ The important thing is that the value of the ``file`` attribute should
+ resolve to the ``clojure.xml`` in the ``build-support`` directory of this
+ repository. It may be either a relative or absolute path.
-The important thing is that the value of the ``file`` attribute should resolve
-to the ``clojure.xml`` in the ``built-support`` directory of this repository.
-It may be either a relative or absolute path.
+2. You must find the line that reads ``<!-- version-tag: 1 -->`` and change the
+ ``1`` to ``custom``. If you do not do this, Android may overwrite your
+ changes.
For most projects, that is all you have to do. So long as your Clojure source
files are in ``src/clojure`` and you have placed a Clojure JAR file in
View
0 build.properties → ant.properties
File renamed without changes.
View
139 build-support/clojure.xml
@@ -36,58 +36,95 @@
<mkdir dir="${clojure.out.classes.absolute.dir}"/>
</target>
- <target name="-clojure-compile">
- <condition property="libs.ref"
- value="android.libraries.jars"
- else="jar.libs.ref">
- <isset property="android.library"/>
- </condition>
- <condition property="libs.dir"
- value="./libs"
- else="${jar.libs.dir}">
- <isset property="android.library"/>
- </condition>
- <condition property="extensible.classpath"
- value="${tested.project.absolute.dir}/bin/classes"
- else=".">
- <isset property="tested.project.absolute.dir" />
- </condition>
- <condition property="extensible.libs.classpath"
- value="${tested.project.absolute.dir}/libs"
- else="${libs.dir}">
- <isset property="tested.project.absolute.dir" />
- </condition>
- <condition property="clojure.warn.reflection.env"
- value="${clojure.warn.reflection}"
- else="false">
- <isset property="clojure.warn.reflection"/>
- </condition>
- <pathconvert property="clojure.project.libraries.src"
- refid="project.libraries.src">
- <globmapper from="*/src/java" to="*/src/clojure"/>
- </pathconvert>
- <java classname="clojure.main"
- classpath="${clojure.jar}"
- classpathref="android.target.classpath"
- fork="true"
- failonerror="true">
- <sysproperty key="clojure.compile.path" value="${clojure.out.classes.absolute.dir}"/>
- <sysproperty key="clojure.warn.reflection" value="${clojure.warn.reflection.env}"/>
- <classpath>
- <pathelement path="${extensible.classpath}"/>
- <pathelement path="${clojure.source.absolute.dir}"/>
- <path refid="${libs.ref}"/>
- <pathelement path="${clojure.project.libraries.src}"/>
- <fileset dir="${extensible.libs.classpath}" includes="*.jar" />
- <pathelement path="${out.classes.absolute.dir}"/>
- </classpath>
- <arg file="${android-clojure-support.dir}/clojure-compile.clj"/>
- <arg path="${clojure.source.absolute.dir}"/>
- <arg path="${clojure.project.libraries.src}"/>
- </java>
- </target>
+ <!-- Compiles this project's .java files into .class files. -->
+ <target name="-compile" depends="-build-setup, -pre-build, -code-gen, -pre-compile">
+ <do-only-if-manifest-hasCode elseText="hasCode = false. Skipping...">
+ <!-- If android rules are used for a test project, its classpath should include
+ tested project's location -->
+ <condition property="extensible.classpath"
+ value="${tested.project.absolute.dir}/bin/classes"
+ else=".">
+ <isset property="tested.project.absolute.dir" />
+ </condition>
+ <condition property="extensible.libs.classpath"
+ value="${tested.project.absolute.dir}/${jar.libs.dir}"
+ else="${jar.libs.dir}">
+ <isset property="tested.project.absolute.dir" />
+ </condition>
+ <condition property="clojure.warn.reflection.env"
+ value="${clojure.warn.reflection}"
+ else="false">
+ <isset property="clojure.warn.reflection"/>
+ </condition>
+ <javac encoding="${java.encoding}"
+ source="${java.source}" target="${java.target}"
+ debug="true" extdirs=""
+ destdir="${out.classes.absolute.dir}"
+ bootclasspathref="android.target.classpath"
+ verbose="${verbose}"
+ classpath="${extensible.classpath}"
+ classpathref="jar.libs.ref">
+ <src path="${source.absolute.dir}" />
+ <src path="${gen.absolute.dir}" />
+ <classpath>
+ <fileset dir="${extensible.libs.classpath}" includes="*.jar" />
+ </classpath>
+ </javac>
+ <java classname="clojure.main"
+ classpath="${clojure.jar}"
+ classpathref="android.target.classpath"
+ fork="true"
+ failonerror="true">
+ <sysproperty key="clojure.compile.path" value="${clojure.out.classes.absolute.dir}"/>
+ <sysproperty key="clojure.warn.reflection" value="${clojure.warn.reflection.env}"/>
+ <classpath>
+ <pathelement path="${extensible.classpath}"/>
+ <pathelement path="${clojure.source.absolute.dir}"/>
+ <path refid="jar.libs.ref"/>
+ <fileset dir="${extensible.libs.classpath}" includes="*.jar" />
+ <pathelement path="${clojure.out.classes.absolute.dir}"/>
+ </classpath>
+ <arg file="${android-clojure-support.dir}/clojure-compile.clj"/>
+ <arg path="${clojure.source.absolute.dir}"/>
+ </java>
+ <!-- if the project is a library then we generate a jar file -->
+ <if condition="${project.is.library}">
+ <then>
+ <echo>Creating library output jar file...</echo>
+ <property name="out.library.jar.file" location="${out.absolute.dir}/classes.jar" />
+ <if>
+ <condition>
+ <length string="${android.package.excludes}" trim="true" when="greater" length="0" />
+ </condition>
+ <then>
+ <echo>Custom jar packaging exclusion: ${android.package.excludes}</echo>
+ </then>
+ </if>
+ <jar destfile="${out.library.jar.file}">
+ <fileset dir="${out.classes.absolute.dir}" excludes="**/R.class **/R$*.class"/>
+ <fileset dir="${source.absolute.dir}" excludes="**/*.java ${android.package.excludes}" />
+ </jar>
+ </then>
+ </if>
- <target name="compile" depends="android_rules.compile,-clojure-compile"/>
+ <!-- if the project is instrumented, intrument the classes -->
+ <if condition="${build.is.instrumented}">
+ <then>
+ <echo>Instrumenting classes from ${out.absolute.dir}/classes...</echo>
+ <!-- It only instruments class files, not any external libs -->
+ <emma enabled="true">
+ <instr verbosity="${verbosity}"
+ mode="overwrite"
+ instrpath="${out.absolute.dir}/classes"
+ outdir="${out.absolute.dir}/classes">
+ </instr>
+ <!-- TODO: exclusion filters on R*.class and allowing custom exclusion from
+ user defined file -->
+ </emma>
+ </then>
+ </if>
+ </do-only-if-manifest-hasCode>
+ </target>
</project>
<!-- vim:set ts=4 sw=4 et: -->
View
79 build.xml
@@ -1,42 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project name="Clojure_Android_Toolkit" default="help">
+<project name="Neko" default="help">
-<!-- The local.properties file is created and updated by the 'android'
- tool.
- It contains the path to the SDK. It should *NOT* be checked into
- Version Control Systems. -->
- <property file="local.properties" />
+ <!-- The local.properties file is created and updated by the 'android' tool.
+ It contains the path to the SDK. It should *NOT* be checked into
+ Version Control Systems. -->
+ <loadproperties srcFile="local.properties" />
- <!-- The build.properties file can be created by you and is never touched
- by the 'android' tool. This is the place to change some of the
- default property values used by the Ant rules.
+ <!-- The ant.properties file can be created by you. It is only edited by the
+ 'android' tool to add properties to it.
+ This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
+ For other overridable properties, look at the beginning of the rules
+ files in the SDK, at tools/ant/build.xml
+
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
- <property file="build.properties" />
+ <property file="ant.properties" />
- <!-- The default.properties file is created and updated by the 'android'
+ <!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
+
+ This contains project specific properties such as project target, and library
+ dependencies. Lower level build properties are stored in ant.properties
+ (or in .classpath for Eclipse projects).
+
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
- <property file="default.properties" />
+ <loadproperties srcFile="project.properties" />
+ <!-- quick check on sdk.dir -->
+ <fail
+ message="sdk.dir is missing. Make sure to generate local.properties using 'android update project'"
+ unless="sdk.dir"
+ />
- <!-- Required pre-setup import -->
- <import file="${sdk.dir}/tools/ant/pre_setup.xml" />
-
- <import file="build-support/clojure.xml" />
<!-- extension targets. Uncomment the ones where you want to do custom work
in between standard targets -->
@@ -46,41 +54,34 @@
<target name="-pre-compile">
</target>
- [This is typically used for code obfuscation.
- Compiled code location: ${out.classes.absolute.dir}
- If this is not done in place, override ${out.dex.input.absolute.dir}]
+ /* This is typically used for code obfuscation.
+ Compiled code location: ${out.classes.absolute.dir}
+ If this is not done in place, override ${out.dex.input.absolute.dir} */
<target name="-post-compile">
</target>
-->
- <!-- Execute the Android Setup task that will setup some properties
- specific to the target, and import the build rules files.
+ <import file="build-support/clojure.xml" />
- The rules file is imported from
- <SDK>/tools/ant/
- Depending on the project type it can be either:
- - main_rules.xml
- - lib_rules.xml
- - test_rules.xml
+ <!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
- <setup> task.
+ <import> task.
- customize it to your needs.
- - Customize the whole script.
+ - Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
- into this file, *after* the <setup> task
- - disable the import of the rules by changing the setup task
- below to <setup import="false" />.
+ into this file, replacing the <import> task.
- customize to your needs.
+
+ ***********************
+ ****** IMPORTANT ******
+ ***********************
+ In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
+ in order to avoid having your file be overridden by tools such as "android update project"
-->
- <setup />
- <path id="android.libraries.src">
- <path refid="project.libraries.src"/>
- </path>
- <path id="android.libraries.jars">
- <path refid="project.libraries.jars"/>
- </path>
+ <!-- version-tag: custom -->
+ <import file="${sdk.dir}/tools/ant/build.xml" />
</project>
View
8 proguard.cfg
@@ -18,14 +18,18 @@
native <methods>;
}
--keepclasseswithmembernames class * {
+-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
--keepclasseswithmembernames class * {
+-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
+-keepclassmembers class * extends android.app.Activity {
+ public void *(android.view.View);
+}
+
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
View
2 default.properties → project.properties
@@ -4,7 +4,7 @@
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
-# "build.properties", and override values to adapt the script to your
+# "ant.properties", and override values to adapt the script to your
# project structure.
android.library=true
View
0 test-app/build.properties → test-app/ant.properties
File renamed without changes.
View
76 test-app/build.xml
@@ -1,40 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project name="CAT_Tester" default="help">
+<project name="NekoTestApp" default="help">
-<!-- The local.properties file is created and updated by the 'android'
- tool.
- It contains the path to the SDK. It should *NOT* be checked into
- Version Control Systems. -->
- <property file="local.properties" />
+ <!-- The local.properties file is created and updated by the 'android' tool.
+ It contains the path to the SDK. It should *NOT* be checked into
+ Version Control Systems. -->
+ <loadproperties srcFile="local.properties" />
- <!-- The build.properties file can be created by you and is never touched
- by the 'android' tool. This is the place to change some of the
- default property values used by the Ant rules.
+ <!-- The ant.properties file can be created by you. It is only edited by the
+ 'android' tool to add properties to it.
+ This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
+ For other overridable properties, look at the beginning of the rules
+ files in the SDK, at tools/ant/build.xml
+
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
- <property file="build.properties" />
+ <property file="ant.properties" />
- <!-- The default.properties file is created and updated by the 'android'
+ <!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
+
+ This contains project specific properties such as project target, and library
+ dependencies. Lower level build properties are stored in ant.properties
+ (or in .classpath for Eclipse projects).
+
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
- <property file="default.properties" />
-
+ <loadproperties srcFile="project.properties" />
- <!-- Required pre-setup import -->
- <import file="${sdk.dir}/tools/ant/pre_setup.xml" />
+ <!-- quick check on sdk.dir -->
+ <fail
+ message="sdk.dir is missing. Make sure to generate local.properties using 'android update project'"
+ unless="sdk.dir"
+ />
<!-- extension targets. Uncomment the ones where you want to do custom work
@@ -45,39 +54,34 @@
<target name="-pre-compile">
</target>
- [This is typically used for code obfuscation.
- Compiled code location: ${out.classes.absolute.dir}
- If this is not done in place, override ${out.dex.input.absolute.dir}]
+ /* This is typically used for code obfuscation.
+ Compiled code location: ${out.classes.absolute.dir}
+ If this is not done in place, override ${out.dex.input.absolute.dir} */
<target name="-post-compile">
</target>
-->
- <import file="../build-support/clojure.xml"/>
+ <import file="../build-support/clojure.xml" />
- <!-- Execute the Android Setup task that will setup some properties
- specific to the target, and import the build rules files.
-
- The rules file is imported from
- <SDK>/tools/ant/
- Depending on the project type it can be either:
- - main_rules.xml
- - lib_rules.xml
- - test_rules.xml
+ <!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
- <setup> task.
+ <import> task.
- customize it to your needs.
- - Customize the whole script.
+ - Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
- into this file, *after* the <setup> task
- - disable the import of the rules by changing the setup task
- below to <setup import="false" />.
+ into this file, replacing the <import> task.
- customize to your needs.
+
+ ***********************
+ ****** IMPORTANT ******
+ ***********************
+ In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
+ in order to avoid having your file be overridden by tools such as "android update project"
-->
- <setup />
+ <!-- version-tag: custom -->
+ <import file="${sdk.dir}/tools/ant/build.xml" />
</project>
-
-<!-- vim:set ts=4 sw=4 et: -->
View
8 test-app/proguard.cfg
@@ -18,14 +18,18 @@
native <methods>;
}
--keepclasseswithmembernames class * {
+-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
--keepclasseswithmembernames class * {
+-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
+-keepclassmembers class * extends android.app.Activity {
+ public void *(android.view.View);
+}
+
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
View
2 test/default.properties → test-app/project.properties
@@ -4,7 +4,7 @@
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
-# "build.properties", and override values to adapt the script to your
+# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.
View
1 test/build.properties → test/ant.properties
@@ -15,4 +15,5 @@
# 'key.alias' for the name of the key to use.
# The password will be asked during the build when you use the 'release' target.
+android.library.reference.1=..
tested.project.dir=../test-app
View
74 test/build.xml
@@ -1,42 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project name="CATTest" default="help">
+<project name="NekoTests" default="help">
-<!-- The local.properties file is created and updated by the 'android'
- tool.
- It contains the path to the SDK. It should *NOT* be checked into
- Version Control Systems. -->
- <property file="local.properties" />
+ <!-- The local.properties file is created and updated by the 'android' tool.
+ It contains the path to the SDK. It should *NOT* be checked into
+ Version Control Systems. -->
+ <loadproperties srcFile="local.properties" />
- <!-- The build.properties file can be created by you and is never touched
- by the 'android' tool. This is the place to change some of the
- default property values used by the Ant rules.
+ <!-- The ant.properties file can be created by you. It is only edited by the
+ 'android' tool to add properties to it.
+ This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
+ For other overridable properties, look at the beginning of the rules
+ files in the SDK, at tools/ant/build.xml
+
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
- <property file="build.properties" />
+ <property file="ant.properties" />
- <!-- The default.properties file is created and updated by the 'android'
+ <!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
- This file is an integral part of the build system for your
- application and should be checked into Version Control Systems. -->
- <property file="default.properties" />
+ This contains project specific properties such as project target, and library
+ dependencies. Lower level build properties are stored in ant.properties
+ (or in .classpath for Eclipse projects).
- <!-- Required pre-setup import -->
- <import file="${sdk.dir}/tools/ant/pre_setup.xml" />
+ This file is an integral part of the build system for your
+ application and should be checked into Version Control Systems. -->
+ <loadproperties srcFile="project.properties" />
- <import file="../build-support/clojure.xml"/>
+ <!-- quick check on sdk.dir -->
+ <fail
+ message="sdk.dir is missing. Make sure to generate local.properties using 'android update project'"
+ unless="sdk.dir"
+ />
<!-- extension targets. Uncomment the ones where you want to do custom work
@@ -47,35 +54,34 @@
<target name="-pre-compile">
</target>
- [This is typically used for code obfuscation.
- Compiled code location: ${out.classes.absolute.dir}
- If this is not done in place, override ${out.dex.input.absolute.dir}]
+ /* This is typically used for code obfuscation.
+ Compiled code location: ${out.classes.absolute.dir}
+ If this is not done in place, override ${out.dex.input.absolute.dir} */
<target name="-post-compile">
</target>
-->
- <!-- Execute the Android Setup task that will setup some properties
- specific to the target, and import the build rules files.
+ <import file="../build-support/clojure.xml" />
- The rules file is imported from
- <SDK>/tools/ant/
- Depending on the project type it can be either:
- - main_rules.xml
- - lib_rules.xml
- - test_rules.xml
+ <!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
- <setup> task.
+ <import> task.
- customize it to your needs.
- - Customize the whole script.
+ - Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
- into this file, *after* the <setup> task
- - disable the import of the rules by changing the setup task
- below to <setup import="false" />.
+ into this file, replacing the <import> task.
- customize to your needs.
+
+ ***********************
+ ****** IMPORTANT ******
+ ***********************
+ In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
+ in order to avoid having your file be overridden by tools such as "android update project"
-->
- <setup />
+ <!-- version-tag: custom -->
+ <import file="${sdk.dir}/tools/ant/build.xml" />
</project>
View
8 test/proguard.cfg
@@ -18,14 +18,18 @@
native <methods>;
}
--keepclasseswithmembernames class * {
+-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
--keepclasseswithmembernames class * {
+-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
+-keepclassmembers class * extends android.app.Activity {
+ public void *(android.view.View);
+}
+
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
View
2 test-app/default.properties → test/project.properties
@@ -4,7 +4,7 @@
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
-# "build.properties", and override values to adapt the script to your
+# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.

0 comments on commit ab46f68

Please sign in to comment.