Mercurial > cgi-bin > hgweb.cgi > ImagePrep
annotate build.xml @ 28:c310ec097194
Add Linux support.
author | David Barts <n5jrn@me.com> |
---|---|
date | Fri, 25 Dec 2020 19:07:47 -0800 |
parents | 9bf3d8de6904 |
children | e90d290a9a8d |
rev | line source |
---|---|
0 | 1 <?xml version="1.0" encoding="UTF-8"?> |
2 <project name="ImagePrep" default="help" basedir="."> | |
3 <!-- import all environment variables as env.* --> | |
4 <property environment="env"/> | |
5 | |
6 <!-- ensure required environment variables are set --> | |
7 <macrodef name="env-require"> | |
8 <attribute name="name"/> | |
9 <sequential> | |
10 <fail message="Environment variable @{name} not set!"> | |
11 <condition> | |
12 <not><isset property="env.@{name}"/></not> | |
13 </condition> | |
14 </fail> | |
15 </sequential> | |
16 </macrodef> | |
17 <env-require name="JRE_HOME"/> | |
18 <env-require name="KOTLIN_HOME"/> | |
19 <env-require name="OSDEP_HOME"/> | |
20 | |
21 <!-- cribbed from https://stackoverflow.com/questions/7129672/uppercase-lowercase-capitalize-an-ant-property --> | |
22 <scriptdef language="javascript" name="toLowerCase"> | |
23 <attribute name="value" /> | |
24 <attribute name="target" /> | |
25 <![CDATA[ | |
26 "use strict"; | |
27 project.setProperty( attributes.get( "target" ), | |
28 attributes.get( "value" ).toLowerCase() ); | |
29 ]]> | |
30 </scriptdef> | |
31 | |
28 | 32 <!-- estimate disk usage --> |
33 <scriptdef language="javascript" name="du"> | |
34 <attribute name="path" /> | |
35 <attribute name="target" /> | |
36 <![CDATA[ | |
37 "use strict"; | |
38 var File = Java.type('java.io.File'); | |
39 function du(fp) { | |
40 if (fp.isDirectory()) { | |
41 var files = fp.listFiles(); | |
42 if (!files) return 0; | |
43 var total = 0; | |
44 for (var i=0; i<files.length; i++) | |
45 total += du(files[i]); | |
46 return total; | |
47 } else { | |
48 return fp.length(); | |
49 } | |
50 } | |
51 var path = new File(attributes.get("path")); | |
52 project.setProperty(attributes.get("target"), | |
53 Math.round(du(path) / 1024) + ""); | |
54 ]]> | |
55 </scriptdef> | |
56 | |
0 | 57 <!-- Define the properties used by the build --> |
58 <property name="app.name" value="${ant.project.name}"/> | |
2 | 59 <toLowerCase target="lc.app.name" value="${app.name}"/> |
26
9bf3d8de6904
Fix Preferences bug, bump version number.
David Barts <n5jrn@me.com>
parents:
23
diff
changeset
|
60 <property name="app.version" value="1.01"/> |
2 | 61 <property name="app.domain" value="name.blackcap.${lc.app.name}"/> |
0 | 62 <property name="app.entry" value="${app.domain}.MainKt"/> |
63 <property name="app.copyright" value="Copyright © 2020, David W. Barts."/> | |
64 <property name="jar.name" value="${basedir}/${lc.app.name}.jar"/> | |
65 <property name="work.jar" value="${basedir}/work.jar"/> | |
66 <property name="lib.home" value="${basedir}/lib"/> | |
67 <property name="src.home" value="${basedir}/src"/> | |
68 <property name="dist.home" value="${basedir}/dist"/> | |
23 | 69 <property name="pf.home" value="${basedir}/package-files"/> |
0 | 70 <property name="jvm.version" value="1.8"/> |
71 | |
72 <!-- define the kotlin task --> | |
73 <property name="kotlin.lib" value="${env.KOTLIN_HOME}/lib"/> | |
74 <typedef resource="org/jetbrains/kotlin/ant/antlib.xml" | |
75 classpath="${kotlin.lib}/kotlin-ant.jar"/> | |
76 | |
77 <!-- help message --> | |
78 <target name="help"> | |
79 <echo>You can use the following targets:</echo> | |
80 <echo> </echo> | |
81 <echo> help : (default) Prints this message </echo> | |
82 <echo> all : Cleans, compiles, and stages application</echo> | |
83 <echo> clean : Deletes work directories</echo> | |
84 <echo> compile : Compiles servlets into class files</echo> | |
85 <echo> jar : Make JAR file.</echo> | |
86 <echo> </echo> | |
87 <echo>For example, to clean, compile, and package all at once, run:</echo> | |
88 <echo>prompt> ant all </echo> | |
89 </target> | |
90 | |
91 <!-- Define the CLASSPATH --> | |
92 <target name="classpath"> | |
93 <path id="compile.classpath"> | |
94 <pathelement location="${src.home}"/> | |
4
5234e4500d45
Command-line arguments (only partially tested).
David Barts <n5jrn@me.com>
parents:
2
diff
changeset
|
95 <fileset dir="${lib.home}"> |
5234e4500d45
Command-line arguments (only partially tested).
David Barts <n5jrn@me.com>
parents:
2
diff
changeset
|
96 <include name="*.jar"/> |
5234e4500d45
Command-line arguments (only partially tested).
David Barts <n5jrn@me.com>
parents:
2
diff
changeset
|
97 </fileset> |
0 | 98 </path> |
99 </target> | |
100 | |
101 <!-- make needed directories --> | |
102 <target name="mkdirs"> | |
103 <mkdir dir="${dist.home}"/> | |
104 </target> | |
105 | |
106 <!-- remove old cruft --> | |
107 <target name="clean"> | |
108 <delete includeEmptyDirs="true" failonerror="false"> | |
109 <fileset dir="${dist.home}" includes="**/*"/> | |
110 </delete> | |
111 </target> | |
112 | |
113 <!-- rename files containing OS-dependant code --> | |
114 <target name="osdep"> | |
115 <exec executable="${env.JRE_HOME}/bin/java" failonerror="true"> | |
116 <arg value="-jar"/> | |
117 <arg file="${env.OSDEP_HOME}/osdep.jar"/> | |
118 <arg value="${src.home}"/> | |
119 </exec> | |
120 </target> | |
121 | |
122 <!-- do everything but install --> | |
123 <target name="all" depends="jar" | |
124 description="Clean work dirs, compile, make JAR."/> | |
125 | |
126 <!-- compile *.kt to *.class --> | |
127 <target name="compile" depends="mkdirs,osdep,classpath" | |
128 description="Compile Java sources to ${work.home}"> | |
129 <kotlinc src="${src.home}" output="${work.jar}" | |
130 classpathref="compile.classpath"> | |
131 <compilerarg line="-jvm-target ${jvm.version}"/> | |
132 </kotlinc> | |
133 </target> | |
134 | |
135 <!-- make .jar file --> | |
136 <target name="jar" depends="compile" description="Create JAR file."> | |
137 <jar destfile="${jar.name}"> | |
138 <manifest> | |
139 <attribute name="Main-Class" value="${app.entry}"/> | |
140 </manifest> | |
141 <!-- <zipgroupfileset dir="${lib.home}" includes="*.jar"/> --> | |
4
5234e4500d45
Command-line arguments (only partially tested).
David Barts <n5jrn@me.com>
parents:
2
diff
changeset
|
142 <zipgroupfileset dir="${lib.home}" includes="*.jar"/> |
0 | 143 <zipfileset src="${work.jar}"/> |
2 | 144 <zipfileset dir="${src.home}" includes="**/*.properties,**/*.html"/> |
0 | 145 </jar> |
146 </target> | |
147 | |
23 | 148 <target name="macapp" depends="jar" description="Create MacOS app bundle."> |
149 <fail message="Macintosh packages can only be built on a Mac."> | |
150 <condition> | |
151 <not><os family="mac"/></not> | |
152 </condition> | |
153 </fail> | |
154 <sequential> | |
155 <property name="mac.disk.image.filename" | |
156 value="${lc.app.name}_${app.version}.dmg"/> | |
157 <property name="app.bundle" value="${dist.home}/${app.name}.app"/> | |
158 <mkdir dir="${app.bundle}/Contents"/> | |
159 <copy todir="${app.bundle}/Contents" encoding="UTF-8" overwrite="true"> | |
160 <fileset file="${pf.home}/osx/Info.plist"/> | |
161 <!-- XXX will break if any tokens contain <, >, or & --> | |
162 <filterset> | |
163 <filter token="app.copyright" value="${app.copyright}"/> | |
164 <filter token="app.domain" value="${app.domain}"/> | |
165 <filter token="app.entry" value="${app.entry}"/> | |
166 <filter token="app.name" value="${app.name}"/> | |
167 <filter token="app.version" value="${app.version}"/> | |
168 <filter token="jar.filename" value="${lc.app.name}.jar"/> | |
169 <filter token="jvm.version" value="${jvm.version}"/> | |
170 <filter token="lc.app.name" value="${lc.app.name}"/> | |
171 </filterset> | |
172 </copy> | |
173 <mkdir dir="${app.bundle}/Contents/MacOS"/> | |
174 <copy todir="${app.bundle}/Contents/MacOS" encoding="UTF-8" | |
175 overwrite="true"> | |
176 <fileset file="${pf.home}/osx/JavaApplicationStub"/> | |
177 <filterset> | |
178 <filter token="app.domain" value="${app.domain}"/> | |
179 <filter token="app.name" value="${app.name}"/> | |
180 </filterset> | |
181 </copy> | |
182 <chmod file="${app.bundle}/Contents/MacOS/JavaApplicationStub" | |
183 perm="755"/> | |
184 <mkdir dir="${app.bundle}/Contents/Resources"/> | |
185 <copy file="${basedir}/${app.name}.icns" | |
186 todir="${app.bundle}/Contents/Resources"/> | |
187 <mkdir dir="${app.bundle}/Contents/Java"/> | |
188 <copy file="${jar.name}" todir="${app.bundle}/Contents/Java"/> | |
189 <echo file="${app.bundle}/Contents/PkgInfo" message="APPL????"/> | |
190 <exec executable="hdiutil" failonerror="true"> | |
191 <arg value="create"/> | |
192 <arg value="-volname"/> | |
193 <arg value="${app.name}"/> | |
194 <arg value="-srcfolder"/> | |
195 <arg file="${app.bundle}"/> | |
196 <arg file="${dist.home}/orig-${mac.disk.image.filename}"/> | |
197 </exec> | |
198 <exec executable="hdiutil" failonerror="true"> | |
199 <arg value="convert"/> | |
200 <arg file="${dist.home}/orig-${mac.disk.image.filename}"/> | |
201 <arg value="-format"/> | |
202 <arg value="UDRW"/> | |
203 <arg value="-o"/> | |
204 <arg file="${dist.home}/udrw-${mac.disk.image.filename}"/> | |
205 </exec> | |
206 <exec executable="hdiutil" failonerror="true"> | |
207 <arg value="convert"/> | |
208 <arg file="${dist.home}/udrw-${mac.disk.image.filename}"/> | |
209 <arg value="-format"/> | |
210 <arg value="UDZO"/> | |
211 <arg value="-imagekey"/> | |
212 <arg value="zlib-level=9"/> | |
213 <arg value="-o"/> | |
214 <arg file="${dist.home}/${mac.disk.image.filename}"/> | |
215 </exec> | |
216 </sequential> | |
217 </target> | |
218 | |
28 | 219 <target name="deb" depends="jar" description="Create Debian package."> |
220 <fail message="Linux packages can only be built on Linux."> | |
221 <condition> | |
222 <not><os family="unix"/></not> | |
223 </condition> | |
224 </fail> | |
225 <sequential> | |
226 <mkdir dir="${dist.home}/data/usr/share/applications"/> | |
227 <copy file="${pf.home}/linux/deb/imageprep.desktop" | |
228 tofile="${dist.home}/data/usr/share/applications/imageprep.desktop"/> | |
229 <mkdir dir="${dist.home}/data/usr/share/icons/hicolor/48x48/apps"/> | |
230 <copy file="${pf.home}/linux/icon_48x48.png" | |
231 tofile="${dist.home}/data/usr/share/icons/hicolor/48x48/apps/imageprep.png"/> | |
232 <mkdir dir="${dist.home}/data/usr/share/imageprep"/> | |
233 <copy file="${jar.name}" todir="${dist.home}/data/usr/share/imageprep"/> | |
234 <mkdir dir="${dist.home}/data/usr/share/doc/imageprep"/> | |
235 <copy todir="${dist.home}/data/usr/share/doc/imageprep"> | |
236 <filelist dir="${basedir}" files="Readme.html,Readme.rst"/> | |
237 </copy> | |
238 <copy todir="${dist.home}/data/usr/share/doc/imageprep" encoding="UTF-8" overwrite="true"> | |
239 <fileset file="${pf.home}/linux/deb/copyright"/> | |
240 <filterset> | |
241 <filter token="app.copyright" value="${app.copyright}"/> | |
242 </filterset> | |
243 </copy> | |
244 <gzip src="${pf.home}/linux/deb/changelog" | |
245 destfile="${dist.home}/data/usr/share/doc/imageprep/changelog.gz"/> | |
246 <mkdir dir="${dist.home}/data/usr/share/man/man1"/> | |
247 <gzip src="${pf.home}/linux/imageprep.1" | |
248 destfile="${dist.home}/data/usr/share/man/man1/imageprep.1.gz"/> | |
249 <mkdir dir="${dist.home}/data/usr/bin"/> | |
250 <copy todir="${dist.home}/data/usr/bin" encoding="UTF-8" overwrite="true"> | |
251 <fileset file="${pf.home}/linux/imageprep"/> | |
252 <filterset> | |
253 <filter token="jar.filename" value="${lc.app.name}.jar"/> | |
254 </filterset> | |
255 </copy> | |
256 <chmod file="${dist.home}/data/usr/bin/imageprep" perm="755"/> | |
257 <du path="${dist.home}/data" target="deb.installed.size"/> | |
258 <mkdir dir="${dist.home}/control"/> | |
259 <copy todir="${dist.home}/control" encoding="UTF-8" overwrite="true"> | |
260 <fileset file="${pf.home}/linux/deb/control"/> | |
261 <filterset> | |
262 <filter token="app.version" value="${app.version}"/> | |
263 <filter token="deb.installed.size" value="${deb.installed.size}"/> | |
264 </filterset> | |
265 </copy> | |
266 <copy todir="${dist.home}/control"> | |
267 <filelist dir="${pf.home}/linux/deb" files="postinst,postrm"/> | |
268 </copy> | |
269 <chmod perm="755"> | |
270 <filelist dir="${dist.home}/control" files="postinst,postrm"/> | |
271 </chmod> | |
272 <exec executable="${basedir}/make-debian-package" failonerror="true"> | |
273 <arg value="${dist.home}"/> | |
274 <arg value="${lc.app.name}_${app.version}.deb"/> | |
275 </exec> | |
276 </sequential> | |
277 </target> | |
278 | |
0 | 279 </project> |