Subversion Repositories Projects

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
84 ligi 1
<?xml version="1.0" ?>
2
<project name="DUBwise" default="package">
3
    <property name="sdk-folder" value="/home/ligi/bin/android" />
4
    <property name="android-tools" value="/home/ligi/bin/android/tools" />
5
    <property name="android-framework" value="${android-tools}/lib/framework.aidl" />
6
 
7
    <!-- The intermediates directory -->
8
    <!-- Eclipse uses "bin" for its own output, so we do the same. -->
9
    <property name="outdir" value="bin" />
10
 
11
    <!-- No user servicable parts below. -->
12
 
13
    <!-- Input directories -->
14
    <property name="resource-dir" value="res" />
15
    <property name="asset-dir" value="assets" />
16
    <property name="srcdir" value="src" />
17
 
18
    <!-- Output directories -->
19
    <property name="outdir-classes" value="${outdir}/classes" />
20
 
21
    <!-- Create R.java in the source directory -->
22
    <property name="outdir-r" value="src" />
23
 
24
    <!-- Intermediate files -->
25
    <property name="dex-file" value="classes.dex" />
26
    <property name="intermediate-dex" value="${outdir}/${dex-file}" />
27
 
28
    <!-- The final package file to generate -->
29
    <property name="out-package" value="${outdir}/${ant.project.name}.apk" />
30
 
31
    <!-- Tools -->
32
    <property name="aapt"        value="${android-tools}/aapt" />
33
    <property name="aidl"        value="${android-tools}/aidl" />
34
    <property name="dx"          value="${android-tools}/dx" />
35
    <property name="adb"         value="${android-tools}/adb" />
36
    <property name="android-jar" value="${sdk-folder}/android.jar" />
37
    <property name="zip"         value="zip" />
38
 
39
    <!-- Rules -->
40
 
41
    <!-- Create the output directories if they don't exist yet. -->
42
    <target name="dirs">
43
        <mkdir dir="${outdir}" />
44
        <mkdir dir="${outdir-classes}" />
45
    </target>
46
 
47
    <!-- Generate the R.java file for this project's resources. -->
48
    <target name="resource-src" depends="dirs">
49
        <echo>Generating R.java...</echo>
50
        <exec executable="${aapt}" failonerror="true">
51
            <arg value="compile" />
52
            <arg value="-m" />
53
            <arg value="-J" />
54
            <arg value="${outdir-r}" />
55
            <arg value="-M" />
56
            <arg value="AndroidManifest.xml" />
57
            <arg value="-S" />
58
            <arg value="${resource-dir}" />
59
            <arg value="-I" />
60
            <arg value="${android-jar}" />
61
        </exec>
62
    </target>
63
 
64
    <!-- Generate java classes from .aidl files. -->
65
    <target name="aidl" depends="dirs">
66
        <apply executable="${aidl}" failonerror="true">
67
            <arg value="-p${android-framework}" />
68
            <arg value="-I${srcdir}" />
69
            <fileset dir="${srcdir}">
70
                <include name="**/*.aidl"/>
71
            </fileset>
72
        </apply>
73
    </target>
74
 
75
    <!-- Compile this project's .java files into .class files. -->
76
    <target name="compile" depends="dirs, resource-src, aidl">
77
        <javac encoding="ascii" target="1.5" debug="true" extdirs=""
78
                srcdir="."
79
                destdir="${outdir-classes}"
80
                bootclasspath="${android-jar}" />
81
    </target>
82
 
83
    <!-- Convert this project's .class files into .dex files. -->
84
    <target name="dex" depends="compile">
85
        <exec executable="${dx}" failonerror="true">
86
            <arg value="-JXmx384M" />
87
            <arg value="--dex" />
88
            <arg value="--output=${basedir}/${intermediate-dex}" />
89
            <arg value="--locals=full" />
90
            <arg value="--positions=lines" />
91
            <arg path="${basedir}/${outdir-classes}" />
92
        </exec>
93
    </target>
94
 
95
    <!-- Put the project's resources into the output package file. -->
96
    <target name="package-res-and-assets">
97
        <echo>Packaging resources and assets...</echo>
98
        <exec executable="${aapt}" failonerror="true">
99
            <arg value="package" />
100
            <arg value="-f" />
101
            <arg value="-c" />
102
            <arg value="-M" />
103
            <arg value="AndroidManifest.xml" />
104
            <arg value="-S" />
105
            <arg value="${resource-dir}" />
106
            <arg value="-A" />
107
            <arg value="${asset-dir}" />
108
            <arg value="-I" />
109
            <arg value="${android-jar}" />
110
            <arg value="${out-package}" />
111
        </exec>
112
    </target>
113
 
114
    <!-- Same as package-res-and-assets, but without "-A ${asset-dir}" -->
115
    <target name="package-res-no-assets">
116
        <echo>Packaging resources...</echo>
117
        <exec executable="${aapt}" failonerror="true">
118
            <arg value="package" />
119
            <arg value="-f" />
120
            <arg value="-c" />
121
            <arg value="-M" />
122
            <arg value="AndroidManifest.xml" />
123
            <arg value="-S" />
124
            <arg value="${resource-dir}" />
125
            <!-- No assets directory -->
126
            <arg value="-I" />
127
            <arg value="${android-jar}" />
128
            <arg value="${out-package}" />
129
        </exec>
130
    </target>
131
 
132
    <!-- Invoke the proper target depending on whether or not
133
         an assets directory is present. -->
134
    <!-- TODO: find a nicer way to include the "-A ${asset-dir}" argument
135
         only when the assets dir exists. -->
136
    <target name="package-res">
137
        <available file="${asset-dir}" type="dir"
138
                property="res-target" value="and-assets" />
139
        <property name="res-target" value="no-assets" />
140
        <antcall target="package-res-${res-target}" />
141
    </target>
142
 
143
    <!-- Put the project's .class files into the output package file. -->
144
    <target name="package-java" depends="compile, package-res">
145
        <echo>Packaging java...</echo>
146
        <jar destfile="${out-package}"
147
                basedir="${outdir-classes}"
148
                update="true" />
149
    </target>
150
 
151
    <!-- Put the project's .dex files into the output package file.
152
         Use the "zip" command, available on most un*x/Linux/MacOS systems,
153
         to create the new package (Ant 1.7 has an internal 'zip' command,
154
         however Ant 1.6.5 lacks it and is still widely installed.)
155
    -->
156
    <target name="package-dex" depends="dex, package-res">
157
        <echo>Packaging dex...</echo>
158
        <exec executable="${zip}" failonerror="true">
159
            <arg value="-qj" />
160
            <arg value="${out-package}" />
161
            <arg value="${intermediate-dex}" />
162
        </exec>
163
    </target>
164
 
165
    <!-- Create the package file for this project from the sources. -->
166
    <target name="package" depends="package-dex" />
167
 
168
    <!-- Create the package and install package on the default emulator -->
169
    <target name="install" depends="package">
170
        <echo>Sending package to default emulator...</echo>
171
        <exec executable="${adb}" failonerror="true">
172
            <arg value="install" />
173
            <arg value="${out-package}" />
174
        </exec>
175
    </target>
176
 
177
</project>