-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.xml
208 lines (184 loc) · 10.4 KB
/
build.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<?xml version="1.0"?>
<project name="KindleGoban" basedir="." default="build-unsigned-active-content">
<!-- ===================================================================== -->
<!-- | BUILD PROPERTIES | -->
<!-- ===================================================================== -->
<!-- Load properties specific to this Kindlet. -->
<property file="kindlet.properties" />
<!-- Define local properties -->
<property name="dir.kdk" location="/home/adrian/Code/KDK" />
<property name="simulator" location="${dir.kdk}/bin/KindleSimulator.jar" />
<property name="dir.keystore" location="${dir.kdk}/keys" />
<property name="dir.src" location="${basedir}/src" />
<property name="dir.build" location="${basedir}/build" />
<property name="dir.lib" location="${basedir}/lib" />
<!-- Set this to the location of the KWT JAR file on your system. -->
<property name="jar.kwt" location="${dir.lib}/kwt-0.1.jar" />
<property name="dir.sgf" location="${basedir}/sgf" />
<property name="dir.font" location="${basedir}/font" />
<property name="dir.build.classes" location="${dir.build}/classes" />
<property name="dir.build.kwt" location="${dir.build}/kwt" />
<property name="file.output" location="${dir.build}/${kindlet.title}.azw2" />
<!-- Load the password for the keystore -->
<import file="${dir.keystore}/dev-keys.xml" optional="false"/>
<import file="${dir.keystore}/dev-aliases.xml" optional="false"/>
<property name="pbp-1.1" location="${dir.kdk}/pbp-secop" />
<!-- Set the property 'pbp-1.1' to point to the unzipped contents of the PBP download. -->
<property name="btclasses.zip" value="${pbp-1.1}/Optimized_nosym/lib/btclasses.zip"/>
<property name="basis_security.jar" value="${pbp-1.1}/Optimized_nosym/lib/basis_security.jar"/>
<property name="jce.jar" value="${pbp-1.1}/Optimized_nosym/lib/jce.jar"/>
<property name="jsse-cdc.jar" value="${pbp-1.1}/Optimized_nosym/lib/jsse-cdc.jar"/>
<!-- If the user specifies a PBP to use, we check for the existence of jar/zip files from the PBP. -->
<available file="${btclasses.zip}" property="btclasses.zip.available"/>
<available file="${basis_security.jar}" property="basis_security.jar.available"/>
<available file="${jce.jar}" property="jce.jar.available"/>
<available file="${jsse-cdc.jar}" property="jsse-cdc.jar.available"/>
<!-- boot class path for PBP -->
<path id="pbp.bootclasspath">
<pathelement path="${btclasses.zip}"/>
<pathelement path="${basis_security.jar}"/>
<pathelement path="${jce.jar}"/>
<pathelement path="${jsse-cdc.jar}"/>
</path>
<!-- If pbp-1.1 is specified, check for the existence of the jar/zip files from the PBP -->
<target name="pbp-files" if="pbp-1.1">
<fail message="Unable to locate btclasses.zip in PBP directory" unless="btclasses.zip.available"/>
<fail message="Unable to locate basis_security.jar in PBP directory. Did you download the version without security support?" unless="basis_security.jar.available"/>
<fail message="Unable to locate jce.jar in PBP directory. Did you download the version without security support?" unless="jce.jar.available"/>
<fail message="Unable to locate jsse-cdc.jar in PBP directory. Did you download the version without security support?" unless="jsse-cdc.jar.available"/>
</target>
<!-- If pbp-1.1 is not specified, issue a nice message -->
<target name="check-pbp" unless="pbp-1.1" depends="pbp-files">
<echo message="Compiling using the default bootclasspath. It is advised to compile using the Personal Basis Profile. "/>
<echo message="The PBP libraries may be downloaded from http://java.sun.com/javame/downloads/index.jsp
by selecting 'Personal Basis Profile 1.1 Reference Implementation (JSR 217)'.
Download the 'Personal Basis Profile Reference Implementation'. Be sure to select the version with the Foundation Profile Security Optional Package. "/>
<echo message="Specify the location of the PBP with the property pbp-1.1. Eg. ant -Dpbp-1.1=PATH-TO-PBP"/>
</target>
<target name="extract-kwt">
<mkdir dir="${dir.build.kwt}" />
<unjar src="${jar.kwt}" dest="${dir.build.kwt}" />
</target>
<!-- ===================================================================== -->
<!-- | BUILD TARGETS | -->
<!-- ===================================================================== -->
<target name="compile" description="Compiles the Java source files" depends="check-pbp,extract-kwt">
<mkdir dir="${dir.build.classes}" />
<mkdir dir="${dir.build.classes}/img" />
<!--
Compile source files.
Note the target and source attributes are required to generate
bytecode compatible with the Kindle Development Kit (KDK).
-->
<javac target="1.4"
source="1.4"
listfiles="yes"
srcdir="${dir.src}"
destdir="${dir.build.classes}"
includeAntRuntime="no"
bootclasspathref="pbp.bootclasspath"
debug="true">
<classpath>
<!-- Include the Kindle Development Kit (KDK) APIs on the classpath -->
<fileset dir="${dir.kdk}/lib">
<include name="**/*.jar" />
</fileset>
<!-- Include the KWT library on the classpath -->
<pathelement location="${dir.build.kwt}" />
</classpath>
<include name="**/*.java" />
</javac>
<!--
Copy any non-source files, these may include images, property files, etc.
-->
<copy todir="${dir.build.classes}">
<fileset dir="${dir.src}">
<include name="**/*" />
<exclude name="**/*.java" />
</fileset>
</copy>
<copy todir="${dir.build.classes}/sgf">
<fileset dir="${dir.sgf}">
<include name="**/*.sgf" />
</fileset>
</copy>
</target>
<target name="build" depends="compile" description="Alias for compile target"/>
<target name="check-network-support" if="kindlet.networkSupport" description="Check that network support is supported">
<condition property="network-support-is-true">
<istrue value="${kindlet.networkSupport}"/>
</condition>
</target>
<target name="sign-for-network" if="network-support-is-true" depends="check-network-support" description="Adds network support to the Kindle App" >
<available file="${file.output}" property="file.available"/>
<fail message="Jar file cannot be found (${file.output}). File signing failed." unless="file.available"/>
<signjar jar="${file.output}"
alias="${dev.network.alias}"
keystore="${dir.keystore}/${kindlet.keystore}"
storepass="${developer.keystore.storepass}" />
</target>
<!-- Developer apps do not have Implementation-Id defined. -->
<target name="jar-for-developer" description="Jars a file for a developer application">
<jar destfile="${file.output}">
<fileset dir="${dir.build.classes}" />
<fileset dir="${dir.build.kwt}" />
<manifest>
<attribute name="Main-Class" value="${kindlet.mainClass}" />
<attribute name="Implementation-Vendor" value="${kindlet.vendor}" />
<attribute name="Implementation-Title" value="${kindlet.title}" />
<attribute name="Implementation-Version" value="${kindlet.version}" />
<attribute name="Implementation-URL" value="${kindlet.url}" />
<attribute name="Amazon-Cover-Image" value="${kindlet.image}" />
</manifest>
</jar>
</target>
<target name="jar-and-sign" description="Packages and signs the Kindle Active Content." depends="jar-for-developer">
<!--
Sign the jar file to permit running on the device.
-->
<available file="${file.output}" property="file.available"/>
<fail message="Jar file cannot be found (${file.output}). File signing failed." unless="file.available"/>
<signjar jar="${file.output}"
alias="${dev.kindlet.alias}"
keystore="${dir.keystore}/${kindlet.keystore}"
storepass="${developer.keystore.storepass}" />
<signjar jar="${file.output}"
alias="${dev.interaction.alias}"
keystore="${dir.keystore}/${kindlet.keystore}"
storepass="${developer.keystore.storepass}" />
</target>
<!-- Top level targets for building kindle applications. -->
<target name="clean" description="Cleans the build directory.">
<delete dir="${dir.build}" />
</target>
<target name="build-active-content" depends="build-unsigned-active-content" description="Build an unsigned active content which can be run on the Kindle Simulator" />
<target name="build-unsigned-active-content" description="Build an unsigned active content file (.azw2)"
depends="compile,jar-for-developer">
<echo message="WARNING: This Kindle active content will not run on the device, however it will run in the Kindle Simulator. Please run 'ant build-signed-active-content' if you would like to compile your active content to run on the device." />
</target>
<!-- Check that the keystore file is present. -->
<target name="check-keystore" description="Check that the keystore file is present.">
<available file="${dir.keystore}/${kindlet.keystore}" property="keystore.available"/>
<fail message="Unable to locate keystore file. Please ensure that your keystore is located in '${dir.keystore}' and that 'kindlet.keystore' is specified in your Kindlet properties file. Also, please check that 'kindlet.keystore' is set correctly in your kindlet.properties file. " unless="keystore.available"/>
</target>
<target name="build-signed-active-content" description="Build a signed active content file (.azw2)"
depends="check-keystore,compile,jar-and-sign,sign-for-network">
<echo message="This Kindle Active Content has been built to run on the device." />
</target>
<target name="run-simulator" description="Run the unsigned content in the Kindle Simulator">
<java jar="${simulator}"
fork="true"
spawn="true"
dir="${dir.build}">
<arg line="-f ${file.output} --device KindleDX" />
</java>
</target>
<target name="debug-simulator" description="Debug the unsigned content in the Kindle Simulator">
<java jar="${simulator}"
fork="true"
spawn="true"
dir="${dir.build}">
<arg line="-f ${file.output} --device KindleDX -d -w -p 8082 -s" />
</java>
</target>
</project>