Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Build system updates

  • Loading branch information...
commit 232e3a1ee5810de5a62ea7e47d50b1a35cd51c61 1 parent af2d610
@sattvik authored
Showing with 103 additions and 29 deletions.
  1. +80 −29 build.xml
  2. +19 −0 dx-proguard.cfg
  3. +4 −0 local.properties.example
View
109 build.xml
@@ -9,8 +9,13 @@
</description>
+ <property file="local.properties"/>
+
+ <!-- General android properties -->
+ <property name="android.enabled" value="false"/>
<property name="android.version" value="7"/>
<property name="android.sdk.dir" location="/opt/android-sdk-update-manager"/>
+
<property name="android.platform-tools.dir" location="${android.sdk.dir}/platform-tools"/>
<property name="android.platform.dir" location="${android.sdk.dir}/platforms/android-${android.version}"/>
<property name="android.jar" location="${android.platform.dir}/android.jar"/>
@@ -59,7 +64,6 @@
<not><equals arg1="${clojure.version.interim}" arg2="false" trim="true"/></not>
</condition>
-
<property name="clojure.version.label"
value="${clojure.version.major}.${clojure.version.minor}${clojure.version.incremental.label}${clojure.version.qualifier.label}${clojure.version.interim.label}"/>
@@ -84,7 +88,7 @@
<property name="snapshot.repo.dir" location="/var/www/maven-snapshot-repository"/>
<property name="stable.repo.dir" location="/var/www/maven-repository"/>
- <target name="init">
+ <target name="init" depends="clean">
<tstamp/>
<mkdir dir="${build}"/>
<antcall target="init-version"/>
@@ -100,33 +104,80 @@
<chmod file="pom.xml" perm="ugo-w"/>
</target>
- <target name="dx-lite" depends="init">
- <jar jarfile="${dx-lite.jar}">
- <zipfileset src="${dx.jar}">
- <exclude name="junit/**"/>
- <exclude name="META-INF/**"/>
- <exclude name="**/_tests"/>
- <exclude name="**/_tests/_*.class"/>
- </zipfileset>
- </jar>
+ <target name="-check-proguard" depends="init">
+ <available property="proguard.available"
+ classpath="${proguard.jar}" classname="proguard.ProGuard"/>
</target>
- <target name="compile-java" depends="init,dx-lite"
- description="Compile Java sources.">
- <javac srcdir="${jsrc}" destdir="${build}" includeJavaRuntime="yes"
- includeantruntime="false"
- debug="true" target="1.5">
- <classpath>
- <pathelement path="${dx-lite.jar}"/>
- <pathelement path="${android.jar}"/>
- </classpath>
- </javac>
+ <target name="-shrink-dx-jar" depends="-check-proguard"
+ if="proguard.available">
+ <echo>ProGuard available, shrinking to create dx-lite.jar</echo>
+ <taskdef resource="proguard/ant/task.properties"
+ classpath="${proguard.jar}"/>
+ <proguard>
+ -injars ${dx.jar}
+ -outjar ${dx-lite.jar}
+ -libraryjars ${android.jar}
+ @dx-proguard.cfg
+ </proguard>
</target>
+ <target name="-copy-dx-jar" depends="-check-proguard"
+ unless="proguard.available">
+ <echo>No ProGuard available, using simple copy to create dx-lite.jar</echo>
+ <jar jarfile="${dx-lite.jar}">
+ <zipfileset src="${dx.jar}">
+ <exclude name="junit/**"/>
+ <exclude name="META-INF/**"/>
+ <exclude name="**/_tests"/>
+ <exclude name="**/_tests/_*.class"/>
+ </zipfileset>
+ </jar>
+ </target>
+
+ <target name="dx-lite" depends="-shrink-dx-jar,-copy-dx-jar"
+ description="Creates a stripped version of dx.jar"/>
+
+ <macrodef name="compile-java">
+ <element name="compile-elements"
+ implicit="yes"
+ optional="yes"/>
+ <sequential>
+ <javac srcdir="${jsrc}"
+ destdir="${build}"
+ includeJavaRuntime="true"
+ includeAntRuntime="false"
+ debug="true"
+ source="1.5" target="1.5">
+ <compile-elements/>
+ </javac>
+ </sequential>
+ </macrodef>
+
+ <target name="-compile-java-nodalvik" depends="init">
+ <compile-java>
+ <include name="**/*.java"/>
+ <exclude name="**/Dalvik*.java"/>
+ </compile-java>
+ </target>
+
+ <target name="-compile-java-dalvik" depends="init,dx-lite" if="android.enabled">
+ <compile-java>
+ <include name="**/Dalvik*.java"/>
+ <classpath>
+ <pathelement path="${dx-lite.jar}"/>
+ <pathelement path="${android.jar}"/>
+ </classpath>
+ </compile-java>
+ </target>
+
+ <target name="compile-java" depends="-compile-java-nodalvik,-compile-java-dalvik"
+ description="Compile Java sources."/>
+
<target name="compile-clojure" depends="compile-java"
description="Compile Clojure sources.">
<java classname="clojure.lang.Compile"
- classpath="${build}:${cljsrc}:${dx-lite.jar}:${android.jar}"
+ classpath="${build}:${cljsrc}"
failonerror="true">
<sysproperty key="clojure.compile.path" value="${build}"/>
<!-- <sysproperty key="clojure.compile.warn-on-reflection" value="true"/> -->
@@ -155,8 +206,7 @@
</target>
<target name="compile-tests"
- description="Compile the subset of tests that require compilation."
- unless="${skiptests}">
+ description="Compile the subset of tests that require compilation.">
<delete dir="${test-classes}"/>
<mkdir dir="${test-classes}"/>
<java classname="clojure.lang.Compile"
@@ -169,8 +219,7 @@
</target>
<target name="test-only"
- description="Run clojure tests without recompiling first"
- unless="${skiptests}">
+ description="Run clojure tests without recompiling first">
<java classname="clojure.main" failonerror="true">
<classpath>
<path location="${test-classes}"/>
@@ -230,7 +279,7 @@
<copy file="${src_jar}" tofile="${src_noversion_jar}" />
</target>
- <target name="clojure-jar-no-sources" depends="clojure-jar">
+ <target name="clojure-jar-no-sources" depends="clojure-jar" if="android.enabled">
<jar jarfile="${nosrc_jar}">
<zipfileset src="${clojure_jar}">
<include name="**/*.class"/>
@@ -244,7 +293,7 @@
<copy file="${nosrc_jar}" tofile="${nosrc_noversion_jar}" />
</target>
- <target name="dex" depends="clojure-jar-no-sources">
+ <target name="dex" depends="clojure-jar-no-sources" if="android.enabled">
<exec executable="${dx}" failonerror="true">
<arg value="--dex"/>
<arg value="--output=${dex.file}" />
@@ -253,7 +302,7 @@
</exec>
</target>
- <target name="clojure-jar-dex" depends="dex">
+ <target name="clojure-jar-dex" depends="dex" if="android.enabled">
<jar jarfile="${dex_jar}">
<fileset dir="${cljsrc}" includes="clojure/version.properties"/>
<mappedresources>
@@ -272,6 +321,8 @@
<delete dir="${test-classes}"/>
<delete dir="${dist}"/>
<delete file="pom.xml"/>
+ <delete file="${dex.file}"/>
+ <delete file="${dx-lite.jar}"/>
<delete verbose="true">
<fileset dir="${basedir}" includes="*.jar"/>
<fileset dir="${basedir}" includes="*.zip"/>
View
19 dx-proguard.cfg
@@ -0,0 +1,19 @@
+-verbose
+-dontoptimize
+-dontobfuscate
+-dontpreverify
+
+-dontwarn junit.**
+-dontnote junit.**
+
+-keep public class com.android.dx.dex.file.DexFile {
+ public <init>();
+ public void add(...);
+ public void writeTo(...);
+}
+
+-keep public class com.android.dx.dex.cf.CfOptions
+
+-keep public class com.android.dx.dex.cf.CfTranslator {
+ public static *** translate(...);
+}
View
4 local.properties.example
@@ -0,0 +1,4 @@
+android.enabled=true
+android.version=7
+android.sdk.dir=/opt/android-sdk-update-manager
+#proguard.jar=/path/to//proguard.jar
Please sign in to comment.
Something went wrong with that request. Please try again.