|
30 | 30 | <not><equals arg1="${scala.files.count}" arg2="0" /></not> |
31 | 31 | </condition> |
32 | 32 |
|
33 | | - <target name="-compile-scala" depends="-compile" |
34 | | - if="contains.scala.sources" unless="do.not.compile" |
| 33 | + <target name="-compile-scala" depends="-compile" if="contains.scala.sources" |
35 | 34 | description="Compiles project's .scala files into .class files"> |
36 | | - <condition property="logging" value="verbose" else="none"> |
37 | | - <istrue value="${verbose}" /> |
38 | | - </condition> |
39 | | - <echo message="${scalac.banner}" level="info" taskname="scalac" /> |
40 | | - <scalac |
41 | | - destdir="${out.classes.absolute.dir}" |
42 | | - bootclasspathref="android.target.classpath" |
43 | | - logging="${logging}" addparams="${scala.compilerargs}" |
44 | | - classpath="${extensible.classpath}" |
45 | | - classpathref="jar.libs.ref"> |
46 | | - <src path="${source.absolute.dir}" /> |
47 | | - <src path="${gen.absolute.dir}" /> |
48 | | - <classpath> |
49 | | - <pathelement location="${scala-library.jar}" /> |
50 | | - <!-- include compiled resources --> |
51 | | - <pathelement location="${out.classes.absolute.dir}" /> |
52 | | - <fileset dir="${extensible.libs.classpath}" includes="*.jar" /> |
53 | | - </classpath> |
54 | | - </scalac> |
| 35 | + <do-only-if-manifest-hasCode elseText="hasCode = false. Skipping..."> |
| 36 | + <condition property="logging" value="verbose" else="none"> |
| 37 | + <istrue value="${verbose}" /> |
| 38 | + </condition> |
| 39 | + <echo message="${scalac.banner}" level="info" taskname="scalac" /> |
| 40 | + <scalac |
| 41 | + destdir="${out.classes.absolute.dir}" |
| 42 | + bootclasspathref="android.target.classpath" |
| 43 | + logging="${logging}" addparams="${scala.compilerargs}" |
| 44 | + classpath="${extensible.classpath}" |
| 45 | + classpathref="jar.libs.ref"> |
| 46 | + <src path="${source.absolute.dir}" /> |
| 47 | + <src path="${gen.absolute.dir}" /> |
| 48 | + <classpath> |
| 49 | + <pathelement location="${scala-library.jar}" /> |
| 50 | + <!-- include compiled resources --> |
| 51 | + <pathelement location="${out.classes.absolute.dir}" /> |
| 52 | + <fileset dir="${extensible.libs.classpath}" includes="*.jar" /> |
| 53 | + </classpath> |
| 54 | + </scalac> |
| 55 | + <!-- if the project is a library then we generate a jar file --> |
| 56 | + <if condition="${project.is.library}"> |
| 57 | + <then> |
| 58 | + <echo>Updating library output jar file...</echo> |
| 59 | + <jar destfile="${out.library.jar.file}" update="true"> |
| 60 | + <fileset dir="${out.classes.absolute.dir}" excludes="**/R.class **/R$*.class"/> |
| 61 | + <fileset dir="${source.absolute.dir}" excludes="**/*.scala" /> |
| 62 | + </jar> |
| 63 | + </then> |
| 64 | + </if> |
| 65 | + |
| 66 | + <!-- if the project is instrumented, intrument the classes --> |
| 67 | + <if condition="${build.is.instrumented}"> |
| 68 | + <then> |
| 69 | + <echo>Instrumenting classes from ${out.absolute.dir}/classes...</echo> |
| 70 | + <!-- It only instruments class files, not any external libs --> |
| 71 | + <emma enabled="true"> |
| 72 | + <instr verbosity="${verbosity}" |
| 73 | + mode="overwrite" |
| 74 | + instrpath="${out.absolute.dir}/classes" |
| 75 | + outdir="${out.absolute.dir}/classes"> |
| 76 | + </instr> |
| 77 | + <!-- TODO: exclusion filters on R*.class and allowing custom exclusion from |
| 78 | + user defined file --> |
| 79 | + </emma> |
| 80 | + </then> |
| 81 | + </if> |
| 82 | + </do-only-if-manifest-hasCode> |
55 | 83 | </target> |
56 | 84 |
|
57 | | - <target name="-post-compile-scala" depends="-compile-scala" unless="do.not.compile" |
| 85 | + <target name="-post-compile-scala" depends="-compile-scala" |
58 | 86 | description="Shrink project class files and Scala library into one .jar file"> |
59 | 87 | <condition property="debug.mode" value="" else="#DEBUG#"> |
60 | 88 | <equals arg1="${build.target}" arg2="debug" /> |
61 | 89 | </condition> |
62 | 90 | <condition property="release.mode" value="" else="#RELEASE#"> |
63 | 91 | <equals arg1="${build.target}" arg2="release" /> |
64 | 92 | </condition> |
65 | | - <!-- priority is given to local ProGuard configuration if present --> |
66 | | - <condition property="template.cfg" value="${basedir}/local-proguard-template.cfg"> |
67 | | - <available file="${basedir}/local-proguard-template.cfg" /> |
68 | | - </condition> |
69 | 93 | <condition property="template.cfg" value="${basedir}/proguard-template.cfg"> |
70 | 94 | <available file="${basedir}/proguard-template.cfg" /> |
71 | 95 | </condition> |
|
81 | 105 | <path id="project.libraries.jars"> |
82 | 106 | <pathelement location="${scala-library.jar}" /> |
83 | 107 | </path> |
84 | | - <!-- we use properties defined in main_rules.xml --> |
| 108 | + <!-- we use properties defined in tools/ant/build.xml --> |
85 | 109 | <property name="injars" value="" /> |
86 | 110 | <property name="outjars" value="" /> |
87 | 111 | <property name="libraryjars" value="" /> |
88 | 112 | </then><else> |
89 | 113 | <property name="shrinked.jar" location="${out.absolute.dir}/shrinked.jar" /> |
| 114 | + <!-- Secondary dx input (jar files) is empty since all the jar |
| 115 | + files will be in the shrinked jar (see tools/ant/build.xml) --> |
| 116 | + <path id="out.dex.jar.input.ref" /> |
90 | 117 | <condition property="shrink.required"><not> |
91 | 118 | <uptodate targetfile="${shrinked.jar}"> |
92 | 119 | <srcfiles dir="${source.absolute.dir}" includes="**/*.scala" /> |
|
95 | 122 | <!-- input for dex will be proguard's output --> |
96 | 123 | <property name="out.dex.input.absolute.dir" value="${shrinked.jar}" /> |
97 | 124 | <!-- set the compiled project files and Scala library into a single property. --> |
98 | | - <pathconvert property="project.injars"> |
99 | | - <path location="${out.classes.absolute.dir}" /> |
100 | | - <path location="${scala-library.jar}(!META-INF/MANIFEST.MF,!library.properties)" /> |
101 | | - </pathconvert> |
| 125 | + <if condition="${uses.ramdisk}"><then> |
| 126 | + <pathconvert property="project.injars"> |
| 127 | + <path location="${out.classes.absolute.dir}" /> |
| 128 | + <path refid="project.libraries.jars" /> |
| 129 | + </pathconvert> |
| 130 | + </then><else> |
| 131 | + <pathconvert property="project.injars"> |
| 132 | + <path location="${out.classes.absolute.dir}" /> |
| 133 | + <fileset dir="${jar.libs.dir}" includes="*.jar" /> |
| 134 | + <path refid="project.libraries.jars" /> |
| 135 | + <path location="${scala-library.jar}(!META-INF/MANIFEST.MF,!library.properties)" /> |
| 136 | + </pathconvert> |
| 137 | + </else></if> |
102 | 138 | <split-path property="injars" prefix="-injars" path="${project.injars}" /> |
103 | 139 | <split-path property="outjars" prefix="-outjars" path="${shrinked.jar}" /> |
104 | 140 | <!-- set the android classpath object into a single property. --> |
105 | | - <pathconvert property="project.libraryjars"> |
106 | | - <fileset dir="${jar.libs.dir}" includes="*.jar" /> |
107 | | - <path refid="android.target.classpath" /> |
108 | | - </pathconvert> |
| 141 | + <if condition="${uses.ramdisk}"><then> |
| 142 | + <pathconvert property="project.libraryjars"> |
| 143 | + <path location="${scala-library.jar}(!META-INF/MANIFEST.MF,!library.properties)" /> |
| 144 | + <path refid="android.target.classpath" /> |
| 145 | + </pathconvert> |
| 146 | + </then><else> |
| 147 | + <pathconvert property="project.libraryjars"> |
| 148 | + <path refid="android.target.classpath" /> |
| 149 | + </pathconvert> |
| 150 | + </else></if> |
109 | 151 | <split-path property="libraryjars" prefix="-libraryjars" path="${project.libraryjars}" /> |
110 | 152 | </else></if> |
111 | 153 | <!-- Name of the application package extracted from manifest file --> |
112 | 154 | <xpath input="AndroidManifest.xml" expression="/manifest/@package" |
113 | | - output="manifest.package" /> |
| 155 | + output="manifest.package" /> |
| 156 | + <!-- we include local configuration if present --> |
| 157 | + <if> |
| 158 | + <condition> |
| 159 | + <available file="${basedir}/proguard-local.cfg" /> |
| 160 | + </condition> |
| 161 | + <then> |
| 162 | + <loadfile |
| 163 | + property="includes" srcfile="${basedir}/proguard-local.cfg" |
| 164 | + failonerror="false" quiet="true" /> |
| 165 | + </then> |
| 166 | + <else> |
| 167 | + <property name="includes" value="" /> |
| 168 | + </else> |
| 169 | + </if> |
114 | 170 | <copy file="${template.cfg}" tofile="${proguard.cfg}"> |
115 | 171 | <filterchain> |
116 | 172 | <replacetokens> |
|
121 | 177 | <token key="PACKAGENAME" value="${manifest.package}" /> |
122 | 178 | <token key="DEBUG" value="${debug.mode}" /> |
123 | 179 | <token key="RELEASE" value="${release.mode}" /> |
| 180 | + <token key="INCLUDES" value="${includes}" /> |
124 | 181 | </replacetokens> |
125 | 182 | </filterchain> |
126 | 183 | </copy> |
|
129 | 186 | </then></if> |
130 | 187 | </target> |
131 | 188 |
|
132 | | - <target name="install-release" depends="release" |
133 | | - description="Installs/reinstalls the release package onto a running |
134 | | - emulator or device. If the application was previously |
135 | | - installed, the signatures must match." > |
136 | | - <install-release-helper /> |
137 | | - </target> |
138 | | - |
139 | 189 | <!-- Macros --> |
140 | 190 |
|
141 | | - <macrodef name="install-release-helper"> |
142 | | - <sequential> |
143 | | - <echo>Installing ${out.release.file} onto default emulator or device...</echo> |
144 | | - <exec executable="${adb}" failonerror="true"> |
145 | | - <arg line="${adb.device.arg}" /> |
146 | | - <arg value="install" /> |
147 | | - <arg value="-r" /> |
148 | | - <arg path="${out.release.file}" /> |
149 | | - </exec> |
150 | | - </sequential> |
151 | | - </macrodef> |
152 | | - |
153 | 191 | <macrodef name="generate-header"> |
154 | 192 | <attribute name="property" /> |
155 | 193 | <sequential> |
|
0 commit comments