minor fix (Android examples)
git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@22423 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
parent
823d658f2f
commit
20620bc28d
|
@ -9,6 +9,8 @@
|
|||
<!-- ProGuard (www.proguard.com) -->
|
||||
<property name="proguard.jar" value="${proguard.dir}/lib/proguard.jar" />
|
||||
|
||||
<property name="myapp.jar" value="${out.absolute.dir}/${ant.project.name}.jar" />
|
||||
|
||||
<path id="scala.path">
|
||||
<pathelement path="${scala-compiler.jar}" />
|
||||
<pathelement path="${scala-library.jar}" />
|
||||
|
@ -24,14 +26,14 @@
|
|||
<not><equals arg1="${scala.files.count}" arg2="0" /></not>
|
||||
</condition>
|
||||
|
||||
<uptodate property="myapp.isUpToDate" targetfile="${out.dir}/classes.complete">
|
||||
<uptodate property="myapp.isuptodate" targetfile="${out.dir}/myapp.complete">
|
||||
<srcfiles dir="${source.dir}" includes="**/*.scala,**/*.java" />
|
||||
<srcfiles dir="${resource.dir}" />
|
||||
</uptodate>
|
||||
|
||||
<target name="scala-compile" depends="compile"
|
||||
description="Compiles project's .scala files into .class files"
|
||||
if="myapp.containsScala" unless="myapp.isUpToDate">
|
||||
if="myapp.containsScala" unless="myapp.isuptodate">
|
||||
<condition property="logging" value="verbose" else="none">
|
||||
<istrue value="${verbose}" />
|
||||
</condition>
|
||||
|
@ -44,67 +46,121 @@
|
|||
<scalac
|
||||
srcdir="${source.dir}" includes="**/*.scala"
|
||||
destdir="${out.classes.dir}"
|
||||
bootclasspathref="android.target.classpath"
|
||||
logging="${logging}" addparams="${scalac.addparams}">
|
||||
<classpath>
|
||||
<path refid="android.target.classpath" />
|
||||
<pathelement location="${scala-library.jar}" />
|
||||
<pathelement location="${out.classes.dir}" />
|
||||
<fileset dir="${external.libs.absolute.dir}" includes="*.jar" />
|
||||
</classpath>
|
||||
</scalac>
|
||||
<touch file="${out.dir}/classes.complete" verbose="no"/>
|
||||
<touch file="${out.dir}/myapp.complete" verbose="no"/>
|
||||
</target>
|
||||
|
||||
<target name="-adb-test" unless="myapp.isuptodate">
|
||||
<target name="-shrink-if-test">
|
||||
<echo
|
||||
message="Checking if Scala libraries are installed on emulator or device..." />
|
||||
<exec executable="${adb}" failonerror="false" outputproperty="adb.out">
|
||||
<arg line="${adb.device.arg}" />
|
||||
<arg line="shell /bin/ls -s /data/framework/scala-*.jar" />
|
||||
</exec>
|
||||
<condition property="do.not.shrink"><or>
|
||||
<condition property="framework.isavailable">
|
||||
<contains string="${adb.out}" substring="/data/framework/scala-" />
|
||||
</condition>
|
||||
<condition property="do.not.shrink"><or>
|
||||
<isset property="framework.isavailable" />
|
||||
<isset property="myapp.isuptodate" />
|
||||
</or></condition>
|
||||
<echo message="${adb.out}" taskname="adb" />
|
||||
</target>
|
||||
|
||||
<target name="scala-shrink" depends="scala-compile, -adb-test"
|
||||
description="Shrink code size of Scala library"
|
||||
if="myapp.containsScala" unless="do.not.shrink">
|
||||
<target name="scala-shrink" depends="-shrink-if-test" unless="do.not.shrink">
|
||||
<taskdef resource="proguard/ant/task.properties"
|
||||
classpath="${proguard.jar}" />
|
||||
<property
|
||||
name="myapp.jar"
|
||||
value="${out.absolute.dir}/${ant.project.name}.jar" />
|
||||
<property
|
||||
name="myapp.pkg"
|
||||
value="${out.dir}/${ant.project.name}.pkg" />
|
||||
<property
|
||||
name="proguard.conf"
|
||||
value="${out.dir}/proguard.conf" />
|
||||
<echo message="Creating configuration file ${proguard.conf}" />
|
||||
<xmlproperty file="{basedir}/AndroidManifest.xml" />
|
||||
<echo message="${manifest.package}" file="${myapp.pkg}" />
|
||||
<loadfile srcfile="${myapp.pkg}" property="myapp.package">
|
||||
<filterchain>
|
||||
<tokenfilter>
|
||||
<stringtokenizer/>
|
||||
<replaceregex pattern="([^.]+\.[^.]+).*" replace="\1"/>
|
||||
</tokenfilter>
|
||||
</filterchain>
|
||||
</loadfile>
|
||||
<echo message="Generating configuration file ${proguard.conf}" />
|
||||
<package-prefix property="myapp.package" />
|
||||
<proguard-helper property="injars" prefix="-injars"
|
||||
path="${out.classes.dir}${path.separator}${scala-library.jar}(!META-INF/MANIFEST.MF,!library.properties)" />
|
||||
<proguard-helper property="outjars" prefix="-outjars"
|
||||
path="${myapp.jar}" />
|
||||
<pathconvert property="libraryjars.path" refid="android.target.classpath" />
|
||||
<proguard-helper property="libraryjars" prefix="-libraryjars"
|
||||
path="${libraryjars.path}" />
|
||||
<copy file="${basedir}/proguard.conf" todir="${out.dir}">
|
||||
<filterchain>
|
||||
<replacetokens>
|
||||
<token key="OUT_CLASSES_DIR" value="${out.classes.dir}"/>
|
||||
<token key="SCALA_LIBRARY_JAR" value="${scala-library.jar}"/>
|
||||
<token key="MYAPP_JAR" value="${myapp.jar}"/>
|
||||
<token key="ANDROID_JAR" value="${android.jar}"/>
|
||||
<token key="INJARS" value="${injars}"/>
|
||||
<token key="OUTJARS" value="${outjars}"/>
|
||||
<token key="LIBRARYJARS" value="${libraryjars}"/>
|
||||
<token key="MYAPP_PACKAGE" value="${myapp.package}"/>
|
||||
</replacetokens>
|
||||
</filterchain>
|
||||
</copy>
|
||||
<proguard configuration="${proguard.conf}"/>
|
||||
<unjar src="${myapp.jar}" dest="${out.classes.dir}" />
|
||||
<touch file="${out.dir}/myapp.complete" verbose="no"/>
|
||||
</target>
|
||||
|
||||
<macrodef name="scala-dex-helper">
|
||||
<element name="external-libs" optional="yes" />
|
||||
<element name="extra-parameters" optional="yes" />
|
||||
<sequential>
|
||||
<condition property="dex.input" value="${myapp.jar}"
|
||||
else="${out.classes.absolute.dir}"><and>
|
||||
<available file="${myapp.jar}" />
|
||||
<not><isset property="framework.isavailable" /></not>
|
||||
</and></condition>
|
||||
<echo>Converting compiled files and external libraries into ${intermediate.dex.file}...</echo>
|
||||
<apply executable="${dx}" failonerror="true" parallel="true">
|
||||
<arg value="--dex" />
|
||||
<arg value="--output=${intermediate.dex.file}" />
|
||||
<extra-parameters />
|
||||
<arg line="${verbose.option}" />
|
||||
<arg path="${dex.input}" />
|
||||
<fileset dir="${external.libs.absolute.dir}" includes="*.jar" />
|
||||
<path refid="android.libraries.jars" />
|
||||
<external-libs />
|
||||
</apply>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<!-- extract the first two package names (Android naming convention) -->
|
||||
<macrodef name="package-prefix">
|
||||
<attribute name="property" />
|
||||
<sequential>
|
||||
<tempfile property="temp.file" destdir="${out.dir}"
|
||||
deleteonexit="true" />
|
||||
<xmlproperty file="{basedir}/AndroidManifest.xml" />
|
||||
<echo message="${manifest.package}" file="${temp.file}" />
|
||||
<loadfile srcfile="${temp.file}" property="@{property}">
|
||||
<filterchain>
|
||||
<tokenfilter>
|
||||
<stringtokenizer/>
|
||||
<replaceregex pattern="([^.]+\.[^.]+\.).*" replace="\1**"/>
|
||||
</tokenfilter>
|
||||
</filterchain>
|
||||
</loadfile>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<macrodef name="proguard-helper">
|
||||
<attribute name="property" />
|
||||
<attribute name="prefix" />
|
||||
<attribute name="path" />
|
||||
<sequential>
|
||||
<tempfile property="temp.file" destdir="${out.dir}"
|
||||
deleteonexit="true" />
|
||||
<echo message="@{path}" file="${temp.file}" />
|
||||
<loadfile srcfile="${temp.file}" property="@{property}.list">
|
||||
<filterchain>
|
||||
<replacestring from="${path.separator}" to="${line.separator}"/>
|
||||
<replaceregex pattern="(.*)" replace="@{prefix} \1" />
|
||||
</filterchain>
|
||||
</loadfile>
|
||||
<property name="@{property}" value="${@{property}.list}" />
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
<not><equals arg1="${scala.files.count}" arg2="0" /></not>
|
||||
</condition>
|
||||
|
||||
<uptodate property="myapp.isuptodate" targetfile="${out.dir}/classes.complete">
|
||||
<uptodate property="myapp.isuptodate" targetfile="${out.dir}/myapp.complete">
|
||||
<srcfiles dir="${source.dir}" includes="**/*.scala,**/*.java" />
|
||||
<srcfiles dir="${resource.dir}" />
|
||||
</uptodate>
|
||||
|
@ -46,17 +46,18 @@
|
|||
<scalac
|
||||
srcdir="${source.dir}" includes="**/*.scala"
|
||||
destdir="${out.classes.dir}"
|
||||
bootclasspathref="android.target.classpath"
|
||||
logging="${logging}" addparams="${scalac.addparams}">
|
||||
<classpath>
|
||||
<path refid="android.target.classpath" />
|
||||
<pathelement location="${scala-library.jar}" />
|
||||
<pathelement location="${out.classes.dir}" />
|
||||
<fileset dir="${external.libs.absolute.dir}" includes="*.jar" />
|
||||
</classpath>
|
||||
</scalac>
|
||||
<touch file="${out.dir}/classes.complete" verbose="no"/>
|
||||
<touch file="${out.dir}/myapp.complete" verbose="no"/>
|
||||
</target>
|
||||
|
||||
<target name="-adb-test" unless="myapp.isuptodate">
|
||||
<target name="-shrink-if-test">
|
||||
<echo
|
||||
message="Checking if Scala libraries are installed on emulator or device..." />
|
||||
<exec executable="${adb}" failonerror="false" outputproperty="adb.out">
|
||||
|
@ -66,17 +67,14 @@
|
|||
<condition property="framework.isavailable">
|
||||
<contains string="${adb.out}" substring="/data/framework/scala-" />
|
||||
</condition>
|
||||
<echo message="${adb.out}" taskname="adb" />
|
||||
</target>
|
||||
|
||||
<target name="-shrink-if-test" depends="-adb-test">
|
||||
<condition property="do.not.shrink"><or>
|
||||
<isset property="framework.isavailable" />
|
||||
<isset property="myapp.isuptodate" />
|
||||
</or></condition>
|
||||
<echo message="${adb.out}" taskname="adb" />
|
||||
</target>
|
||||
|
||||
<target name="-shrink" depends="-shrink-if-test" unless="do.not.shrink">
|
||||
<target name="scala-shrink" depends="-shrink-if-test" unless="do.not.shrink">
|
||||
<taskdef resource="proguard/ant/task.properties"
|
||||
classpath="${proguard.jar}" />
|
||||
<property
|
||||
|
@ -88,9 +86,9 @@
|
|||
path="${out.classes.dir}${path.separator}${scala-library.jar}(!META-INF/MANIFEST.MF,!library.properties)" />
|
||||
<proguard-helper property="outjars" prefix="-outjars"
|
||||
path="${myapp.jar}" />
|
||||
<pathconvert property="target.path" refid="android.target.classpath" />
|
||||
<pathconvert property="libraryjars.path" refid="android.target.classpath" />
|
||||
<proguard-helper property="libraryjars" prefix="-libraryjars"
|
||||
path="${target.path}" />
|
||||
path="${libraryjars.path}" />
|
||||
<copy file="${basedir}/proguard.conf" todir="${out.dir}">
|
||||
<filterchain>
|
||||
<replacetokens>
|
||||
|
@ -102,13 +100,31 @@
|
|||
</filterchain>
|
||||
</copy>
|
||||
<proguard configuration="${proguard.conf}"/>
|
||||
<zip destfile="${out.dir}/classes.zip" basedir="${out.classes.dir}" />
|
||||
<touch file="${out.dir}/myapp.complete" verbose="no"/>
|
||||
</target>
|
||||
|
||||
<target name="scala-shrink" depends="scala-compile, -shrink"
|
||||
description="Shrink the Scala library code">
|
||||
<unjar src="${myapp.jar}" dest="${out.classes.dir}" />
|
||||
</target>
|
||||
<macrodef name="scala-dex-helper">
|
||||
<element name="external-libs" optional="yes" />
|
||||
<element name="extra-parameters" optional="yes" />
|
||||
<sequential>
|
||||
<condition property="dex.input" value="${myapp.jar}"
|
||||
else="${out.classes.absolute.dir}"><and>
|
||||
<available file="${myapp.jar}" />
|
||||
<not><isset property="framework.isavailable" /></not>
|
||||
</and></condition>
|
||||
<echo>Converting compiled files and external libraries into ${intermediate.dex.file}...</echo>
|
||||
<apply executable="${dx}" failonerror="true" parallel="true">
|
||||
<arg value="--dex" />
|
||||
<arg value="--output=${intermediate.dex.file}" />
|
||||
<extra-parameters />
|
||||
<arg line="${verbose.option}" />
|
||||
<arg path="${dex.input}" />
|
||||
<fileset dir="${external.libs.absolute.dir}" includes="*.jar" />
|
||||
<path refid="android.libraries.jars" />
|
||||
<external-libs />
|
||||
</apply>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<!-- extract the first two package names (Android naming convention) -->
|
||||
<macrodef name="package-prefix">
|
||||
|
@ -147,17 +163,4 @@
|
|||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<!-- restore original state of the 'classes' directory -->
|
||||
<macrodef name="scala-helper">
|
||||
<sequential>
|
||||
<delete includeemptydirs="true" quiet="true">
|
||||
<fileset dir="${out.classes.dir}" includes="**/*"/>
|
||||
</delete>
|
||||
<unzip dest="${out.classes.dir}">
|
||||
<fileset file="${out.dir}/classes.zip"/>
|
||||
</unzip>
|
||||
<delete file="${out.dir}/classes.zip" quiet="true" />
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
</project>
|
||||
|
|
Loading…
Reference in New Issue