Skip to content

Commit

Permalink
Update build system to be compatible with SDK r14 and up
Browse files Browse the repository at this point in the history
  • Loading branch information
sattvik committed Nov 30, 2011
1 parent 30d1c3c commit ab46f68
Show file tree
Hide file tree
Showing 14 changed files with 255 additions and 176 deletions.
32 changes: 25 additions & 7 deletions README.rst
Expand Up @@ -50,7 +50,16 @@ __ https://github.com/sattvik/clojure/tree/android-1.2.x


Android SDK Tools Android SDK Tools
Neko has been developed with the latest revision of the 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 Android Platform SDK 7 (2.1/Eclair) or newer
In order to maintain backwards-compatibility, Neko does not support any APIs In order to maintain backwards-compatibility, Neko does not support any APIs
Expand All @@ -66,14 +75,23 @@ project’s build and allow you to use the libraries within your application.
Build support Build support
------------- -------------


To use Neko’s build support for Clojure, you will need to modify your project’s To use Neko’s build support for Clojure, you will need to make two
``build.xml`` file by adding a line to similar to the following:: 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 2. You must find the line that reads ``<!-- version-tag: 1 -->`` and change the
to the ``clojure.xml`` in the ``built-support`` directory of this repository. ``1`` to ``custom``. If you do not do this, Android may overwrite your
It may be either a relative or absolute path. changes.


For most projects, that is all you have to do. So long as your Clojure source 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 files are in ``src/clojure`` and you have placed a Clojure JAR file in
Expand Down
File renamed without changes.
139 changes: 88 additions & 51 deletions build-support/clojure.xml
Expand Up @@ -36,58 +36,95 @@
<mkdir dir="${clojure.out.classes.absolute.dir}"/> <mkdir dir="${clojure.out.classes.absolute.dir}"/>
</target> </target>


<target name="-clojure-compile"> <!-- Compiles this project's .java files into .class files. -->
<condition property="libs.ref" <target name="-compile" depends="-build-setup, -pre-build, -code-gen, -pre-compile">
value="android.libraries.jars" <do-only-if-manifest-hasCode elseText="hasCode = false. Skipping...">
else="jar.libs.ref"> <!-- If android rules are used for a test project, its classpath should include
<isset property="android.library"/> tested project's location -->
</condition> <condition property="extensible.classpath"
<condition property="libs.dir" value="${tested.project.absolute.dir}/bin/classes"
value="./libs" else=".">
else="${jar.libs.dir}"> <isset property="tested.project.absolute.dir" />
<isset property="android.library"/> </condition>
</condition> <condition property="extensible.libs.classpath"
<condition property="extensible.classpath" value="${tested.project.absolute.dir}/${jar.libs.dir}"
value="${tested.project.absolute.dir}/bin/classes" else="${jar.libs.dir}">
else="."> <isset property="tested.project.absolute.dir" />
<isset property="tested.project.absolute.dir" /> </condition>
</condition> <condition property="clojure.warn.reflection.env"
<condition property="extensible.libs.classpath" value="${clojure.warn.reflection}"
value="${tested.project.absolute.dir}/libs" else="false">
else="${libs.dir}"> <isset property="clojure.warn.reflection"/>
<isset property="tested.project.absolute.dir" /> </condition>
</condition> <javac encoding="${java.encoding}"
<condition property="clojure.warn.reflection.env" source="${java.source}" target="${java.target}"
value="${clojure.warn.reflection}" debug="true" extdirs=""
else="false"> destdir="${out.classes.absolute.dir}"
<isset property="clojure.warn.reflection"/> bootclasspathref="android.target.classpath"
</condition> verbose="${verbose}"
<pathconvert property="clojure.project.libraries.src" classpath="${extensible.classpath}"
refid="project.libraries.src"> classpathref="jar.libs.ref">
<globmapper from="*/src/java" to="*/src/clojure"/> <src path="${source.absolute.dir}" />
</pathconvert> <src path="${gen.absolute.dir}" />
<java classname="clojure.main" <classpath>
classpath="${clojure.jar}" <fileset dir="${extensible.libs.classpath}" includes="*.jar" />
classpathref="android.target.classpath" </classpath>
fork="true" </javac>
failonerror="true"> <java classname="clojure.main"
<sysproperty key="clojure.compile.path" value="${clojure.out.classes.absolute.dir}"/> classpath="${clojure.jar}"
<sysproperty key="clojure.warn.reflection" value="${clojure.warn.reflection.env}"/> classpathref="android.target.classpath"
<classpath> fork="true"
<pathelement path="${extensible.classpath}"/> failonerror="true">
<pathelement path="${clojure.source.absolute.dir}"/> <sysproperty key="clojure.compile.path" value="${clojure.out.classes.absolute.dir}"/>
<path refid="${libs.ref}"/> <sysproperty key="clojure.warn.reflection" value="${clojure.warn.reflection.env}"/>
<pathelement path="${clojure.project.libraries.src}"/> <classpath>
<fileset dir="${extensible.libs.classpath}" includes="*.jar" /> <pathelement path="${extensible.classpath}"/>
<pathelement path="${out.classes.absolute.dir}"/> <pathelement path="${clojure.source.absolute.dir}"/>
</classpath> <path refid="jar.libs.ref"/>
<arg file="${android-clojure-support.dir}/clojure-compile.clj"/> <fileset dir="${extensible.libs.classpath}" includes="*.jar" />
<arg path="${clojure.source.absolute.dir}"/> <pathelement path="${clojure.out.classes.absolute.dir}"/>
<arg path="${clojure.project.libraries.src}"/> </classpath>
</java> <arg file="${android-clojure-support.dir}/clojure-compile.clj"/>
</target> <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> </project>


<!-- vim:set ts=4 sw=4 et: --> <!-- vim:set ts=4 sw=4 et: -->
79 changes: 40 additions & 39 deletions build.xml
@@ -1,42 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?> <?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' <!-- The local.properties file is created and updated by the 'android' tool.
tool. It contains the path to the SDK. It should *NOT* be checked into
It contains the path to the SDK. It should *NOT* be checked into Version Control Systems. -->
Version Control Systems. --> <loadproperties srcFile="local.properties" />
<property file="local.properties" />


<!-- The build.properties file can be created by you and is never touched <!-- The ant.properties file can be created by you. It is only edited by the
by the 'android' tool. This is the place to change some of the 'android' tool to add properties to it.
default property values used by the Ant rules. This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update: Here are some properties you may want to change/update:
source.dir source.dir
The name of the source directory. Default is 'src'. The name of the source directory. Default is 'src'.
out.dir out.dir
The name of the output directory. Default is 'bin'. 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 Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action. be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your This file is an integral part of the build system for your
application and should be checked into Version Control Systems. 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. 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 This file is an integral part of the build system for your
application and should be checked into Version Control Systems. --> 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 <!-- extension targets. Uncomment the ones where you want to do custom work
in between standard targets --> in between standard targets -->
Expand All @@ -46,41 +54,34 @@
<target name="-pre-compile"> <target name="-pre-compile">
</target> </target>
[This is typically used for code obfuscation. /* This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir} Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir}] If this is not done in place, override ${out.dex.input.absolute.dir} */
<target name="-post-compile"> <target name="-post-compile">
</target> </target>
--> -->


<!-- Execute the Android Setup task that will setup some properties <import file="build-support/clojure.xml" />
specific to the target, and import the build rules files.


The rules file is imported from <!-- Import the actual build file.
<SDK>/tools/ant/
Depending on the project type it can be either:
- main_rules.xml
- lib_rules.xml
- test_rules.xml
To customize existing targets, there are two options: To customize existing targets, there are two options:
- Customize only one target: - Customize only one target:
- copy/paste the target into this file, *before* the - copy/paste the target into this file, *before* the
<setup> task. <import> task.
- customize it to your needs. - 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) - copy/paste the content of the rules files (minus the top node)
into this file, *after* the <setup> task into this file, replacing the <import> task.
- disable the import of the rules by changing the setup task
below to <setup import="false" />.
- customize to your needs. - 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 -->
<path id="android.libraries.src"> <import file="${sdk.dir}/tools/ant/build.xml" />
<path refid="project.libraries.src"/>
</path>
<path id="android.libraries.jars">
<path refid="project.libraries.jars"/>
</path>


</project> </project>
8 changes: 6 additions & 2 deletions proguard.cfg
Expand Up @@ -18,14 +18,18 @@
native <methods>; native <methods>;
} }


-keepclasseswithmembernames class * { -keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet); public <init>(android.content.Context, android.util.AttributeSet);
} }


-keepclasseswithmembernames class * { -keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int); public <init>(android.content.Context, android.util.AttributeSet, int);
} }


-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}

-keepclassmembers enum * { -keepclassmembers enum * {
public static **[] values(); public static **[] values();
public static ** valueOf(java.lang.String); public static ** valueOf(java.lang.String);
Expand Down
2 changes: 1 addition & 1 deletion default.properties → project.properties
Expand Up @@ -4,7 +4,7 @@
# This file must be checked in Version Control Systems. # This file must be checked in Version Control Systems.
# #
# To customize properties used by the Ant build system use, # 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 structure.


android.library=true android.library=true
Expand Down
File renamed without changes.

0 comments on commit ab46f68

Please sign in to comment.