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