comparison build.xml @ 39:89d7f4d91f67

Got a working, non-bloated Apple Mac bundle!
author David Barts <n5jrn@me.com>
date Fri, 01 May 2020 23:06:04 -0700
parents 4fdd2f7e2cec
children 4076f1bbf21d
comparison
equal deleted inserted replaced
38:d794ef80f9b0 39:89d7f4d91f67
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <project name="JpegWasher" default="help" basedir="." 2 <project name="JpegWasher" default="help" basedir="."
3 xmlns:contrib="antlib:net.sf.antcontrib" 3 xmlns:contrib="antlib:net.sf.antcontrib"
4 xmlns:jarbundler="antlib:com.ultramixer.jarbundler"
5 xmlns:launch4j="antlib:net.sf.launch4j.ant"> 4 xmlns:launch4j="antlib:net.sf.launch4j.ant">
6 <!-- import all environment variables as env.* --> 5 <!-- import all environment variables as env.* -->
7 <property environment="env"/> 6 <property environment="env"/>
8 7
9 <!-- ensure required environment variables are set --> 8 <!-- ensure required environment variables are set -->
56 </scriptdef> 55 </scriptdef>
57 56
58 <!-- Define the properties used by the build --> 57 <!-- Define the properties used by the build -->
59 <property name="app.name" value="${ant.project.name}"/> 58 <property name="app.name" value="${ant.project.name}"/>
60 <property name="app.version" value="1.03"/> 59 <property name="app.version" value="1.03"/>
61 <property name="app.entry" value="name.blackcap.exifwasher.MainKt"/> 60 <property name="app.domain" value="name.blackcap.exifwasher"/>
61 <property name="app.entry" value="${app.domain}.MainKt"/>
62 <toLowerCase target="lc.app.name" value="${app.name}"/> 62 <toLowerCase target="lc.app.name" value="${app.name}"/>
63 <property name="jar.name" value="${basedir}/${lc.app.name}.jar"/> 63 <property name="jar.name" value="${basedir}/${lc.app.name}.jar"/>
64 <property name="work.jar" value="${basedir}/work.jar"/> 64 <property name="work.jar" value="${basedir}/work.jar"/>
65 <property name="lib.home" value="${basedir}/lib"/> 65 <property name="lib.home" value="${basedir}/lib"/>
66 <property name="src.home" value="${basedir}/src"/> 66 <property name="src.home" value="${basedir}/src"/>
67 <property name="dist.home" value="${basedir}/dist"/> 67 <property name="dist.home" value="${basedir}/dist"/>
68 <property name="pf.home" value="${basedir}/package-files"/> 68 <property name="pf.home" value="${basedir}/package-files"/>
69 <property name="nat.dir" value="${src.home}/name/blackcap/exifwasher/exiv2"/> 69 <property name="nat.dir" value="${src.home}/name/blackcap/exifwasher/exiv2"/>
70 <property name="bin.dir" value="${src.home}/name/blackcap/exifwasher/binaries"/> 70 <property name="bin.dir" value="${src.home}/name/blackcap/exifwasher/binaries"/>
71 <property name="jvm.version" value="1.8"/>
71 72
72 <!-- load the ant-contrib tasks --> 73 <!-- load the ant-contrib tasks -->
74 <!-- TODO: see if we need this, remove if not (also see xmlns above) -->
73 <taskdef resource="net/sf/antcontrib/antlib.xml" 75 <taskdef resource="net/sf/antcontrib/antlib.xml"
74 uri="antlib:net.sf.antcontrib"> 76 uri="antlib:net.sf.antcontrib">
75 <classpath> 77 <classpath>
76 <fileset dir="${lib.home}/ant-contrib" includes="*.jar"/> 78 <fileset dir="${lib.home}/ant-contrib" includes="*.jar"/>
77 </classpath> 79 </classpath>
78 </taskdef> 80 </taskdef>
79
80 <!-- load jarbundler (Mac app bundler) tasks -->
81 <contrib:if>
82 <os family="mac"/>
83 <contrib:then>
84 <taskdef name="create"
85 classname="com.ultramixer.jarbundler.JarBundler"
86 classpath="${lib.home}/jarbundler-core-3.3.0.jar"
87 uri="antlib:com.ultramixer.jarbundler">
88 </taskdef>
89 </contrib:then>
90 </contrib:if>
91 81
92 <!-- load launch4j (Windows app bundler) tasks --> 82 <!-- load launch4j (Windows app bundler) tasks -->
93 <contrib:if> 83 <contrib:if>
94 <os family="windows"/> 84 <os family="windows"/>
95 <contrib:then> 85 <contrib:then>
149 <mkdir dir="${dist.home}"/> 139 <mkdir dir="${dist.home}"/>
150 </target> 140 </target>
151 141
152 <!-- remove old cruft --> 142 <!-- remove old cruft -->
153 <target name="clean"> 143 <target name="clean">
154 <delete includeEmptyDirs="true"> 144 <delete includeEmptyDirs="true" failonerror="false">
155 <fileset dir="${dist.home}" includes="**/*"/> 145 <fileset dir="${dist.home}" includes="**/*"/>
156 <fileset dir="${bin.dir}"/> 146 <fileset dir="${bin.dir}"/>
157 </delete> 147 </delete>
158 </target> 148 </target>
159 149
160 <!-- rename files containing OS-dependant code --> 150 <!-- rename files containing OS-dependant code -->
161 <target name="osdep"> 151 <target name="osdep">
162 <exec executable="${env.JRE_HOME}/bin/java"> 152 <exec executable="${env.JRE_HOME}/bin/java" failonerror="true">
163 <arg value="-jar"/> 153 <arg value="-jar"/>
164 <arg value="../Osdep/osdep.jar"/> 154 <arg value="../Osdep/osdep.jar"/>
165 <arg value="${src.home}"/> 155 <arg value="${src.home}"/>
166 </exec> 156 </exec>
167 </target> 157 </target>
173 <!-- compile *.kt to *.class --> 163 <!-- compile *.kt to *.class -->
174 <target name="compile" depends="mkdirs,osdep,classpath" 164 <target name="compile" depends="mkdirs,osdep,classpath"
175 description="Compile Java sources to ${work.home}"> 165 description="Compile Java sources to ${work.home}">
176 <kotlinc src="${src.home}" output="${work.jar}" 166 <kotlinc src="${src.home}" output="${work.jar}"
177 classpathref="compile.classpath"> 167 classpathref="compile.classpath">
178 <compilerarg line="-jvm-target 1.8"/> 168 <compilerarg line="-jvm-target ${jvm.version}"/>
179 </kotlinc> 169 </kotlinc>
180 </target> 170 </target>
181 171
182 <!-- make .jar file --> 172 <!-- make .jar file -->
183 <target name="jar" depends="compile" description="Create JAR file."> 173 <target name="jar" depends="compile" description="Create JAR file.">
194 </target> 184 </target>
195 185
196 <!-- the packaging logic here is cribbed from what jEdit does --> 186 <!-- the packaging logic here is cribbed from what jEdit does -->
197 187
198 <target name="macapp" depends="jar" description="Create MacOS app bundle."> 188 <target name="macapp" depends="jar" description="Create MacOS app bundle.">
199 <!-- not finished --> 189 <fail message="Macintosh packages can only be built on a Mac.">
190 <condition>
191 <not><os family="mac"/></not>
192 </condition>
193 </fail>
194 <sequential>
195 <property name="mac.disk.image.filename"
196 value="${lc.app.name}_${app.version}.dmg"/>
197 <property name="app.bundle" value="${dist.home}/${app.name}.app"/>
198 <mkdir dir="${app.bundle}/Contents"/>
199 <copy todir="${app.bundle}/Contents" encoding="UTF-8" overwrite="true">
200 <fileset file="${pf.home}/osx/Info.plist"/>
201 <!-- XXX will break if any tokens contain <, >, or & -->
202 <filterset>
203 <filter token="app.domain" value="${app.domain}"/>
204 <filter token="app.entry" value="${app.entry}"/>
205 <filter token="app.name" value="${app.name}"/>
206 <filter token="app.version" value="${app.version}"/>
207 <filter token="jar.filename" value="${lc.app.name}.jar"/>
208 <filter token="jvm.version" value="${jvm.version}"/>
209 <filter token="lc.app.name" value="${lc.app.name}"/>
210 </filterset>
211 </copy>
212 <mkdir dir="${app.bundle}/Contents/MacOS"/>
213 <copy todir="${app.bundle}/Contents/MacOS" encoding="UTF-8"
214 overwrite="true">
215 <fileset file="${pf.home}/osx/JavaApplicationStub"/>
216 <filterset>
217 <filter token="app.domain" value="${app.domain}"/>
218 <filter token="app.name" value="${app.name}"/>
219 </filterset>
220 </copy>
221 <chmod file="${app.bundle}/Contents/MacOS/JavaApplicationStub"
222 perm="755"/>
223 <mkdir dir="${app.bundle}/Contents/Resources"/>
224 <copy file="${basedir}/${app.name}.icns"
225 todir="${app.bundle}/Contents/Resources"/>
226 <mkdir dir="${app.bundle}/Contents/Java"/>
227 <copy file="${jar.name}" todir="${app.bundle}/Contents/Java"/>
228 <echo file="${app.bundle}/Contents/PkgInfo" message="APPL????"/>
229 <exec executable="hdiutil" failonerror="true">
230 <arg value="create"/>
231 <arg value="-volname"/>
232 <arg value="${app.name}"/>
233 <arg value="-srcfolder"/>
234 <arg file="${app.bundle}"/>
235 <arg file="${dist.home}/orig-${mac.disk.image.filename}"/>
236 </exec>
237 <exec executable="hdiutil" failonerror="true">
238 <arg value="convert"/>
239 <arg file="${dist.home}/orig-${mac.disk.image.filename}"/>
240 <arg value="-format"/>
241 <arg value="UDRW"/>
242 <arg value="-o"/>
243 <arg file="${dist.home}/udrw-${mac.disk.image.filename}"/>
244 </exec>
245 <exec executable="hdiutil" failonerror="true">
246 <arg value="convert"/>
247 <arg file="${dist.home}/udrw-${mac.disk.image.filename}"/>
248 <arg value="-format"/>
249 <arg value="UDZO"/>
250 <arg value="-imagekey"/>
251 <arg value="zlib-level=9"/>
252 <arg value="-o"/>
253 <arg file="${dist.home}/${mac.disk.image.filename}"/>
254 </exec>
255 </sequential>
200 </target> 256 </target>
201 257
202 <target name="winapp" depends="jar" description="Create app bundle."> 258 <target name="winapp" depends="jar" description="Create app bundle.">
203 <!-- not finished --> 259 <!-- not finished -->
204 </target> 260 </target>
205 261
206 <target name="deb" depends="jar" description="Create Debian package."> 262 <target name="deb" depends="jar" description="Create Debian package.">
263 <fail message="Linux packages can only be built on Linux.">
264 <condition>
265 <not><os family="unix"/></not>
266 </condition>
267 </fail>
207 <sequential> 268 <sequential>
208 <mkdir dir="${dist.home}/data/usr/share/applications"/> 269 <mkdir dir="${dist.home}/data/usr/share/applications"/>
209 <copy file="${pf.home}/linux/deb/jpegwasher.desktop" 270 <copy file="${pf.home}/linux/deb/jpegwasher.desktop"
210 tofile="${dist.home}/data/usr/share/applications/jpegwasher.desktop"/> 271 tofile="${dist.home}/data/usr/share/applications/jpegwasher.desktop"/>
211 <mkdir dir="${dist.home}/data/usr/share/icons/hicolor/48x48/apps"/> 272 <mkdir dir="${dist.home}/data/usr/share/icons/hicolor/48x48/apps"/>
244 <filelist dir="${pf.home}/linux/deb" files="postinst,postrm"/> 305 <filelist dir="${pf.home}/linux/deb" files="postinst,postrm"/>
245 </copy> 306 </copy>
246 <chmod perm="755"> 307 <chmod perm="755">
247 <filelist dir="${dist.home}/control" files="postinst,postrm"/> 308 <filelist dir="${dist.home}/control" files="postinst,postrm"/>
248 </chmod> 309 </chmod>
249 <exec executable="${basedir}/make-debian-package"> 310 <exec executable="${basedir}/make-debian-package" failonerror="true">
250 <arg value="${dist.home}"/> 311 <arg value="${dist.home}"/>
251 <arg value="${lc.app.name}_${app.version}.deb"/> 312 <arg value="${lc.app.name}_${app.version}.deb"/>
252 </exec> 313 </exec>
253 </sequential> 314 </sequential>
254 </target> 315 </target>