comparison build.xml @ 42:4076f1bbf21d

Got ant winapp working!
author davidb
date Sat, 02 May 2020 10:38:33 -0700
parents 89d7f4d91f67
children 8aada13933c6
comparison
equal deleted inserted replaced
41:4903ac32a287 42:4076f1bbf21d
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"
4 xmlns:launch4j="antlib:net.sf.launch4j.ant"> 3 xmlns:launch4j="antlib:net.sf.launch4j.ant">
5 <!-- import all environment variables as env.* --> 4 <!-- import all environment variables as env.* -->
6 <property environment="env"/> 5 <property environment="env"/>
7 6
8 <!-- ensure required environment variables are set --> 7 <!-- ensure required environment variables are set -->
28 project.setProperty( attributes.get( "target" ), 27 project.setProperty( attributes.get( "target" ),
29 attributes.get( "value" ).toLowerCase() ); 28 attributes.get( "value" ).toLowerCase() );
30 ]]> 29 ]]>
31 </scriptdef> 30 </scriptdef>
32 31
32 <!-- estimate disk usage -->
33 <scriptdef language="javascript" name="du"> 33 <scriptdef language="javascript" name="du">
34 <attribute name="path" /> 34 <attribute name="path" />
35 <attribute name="target" /> 35 <attribute name="target" />
36 <![CDATA[ 36 <![CDATA[
37 "use strict"; 37 "use strict";
52 project.setProperty(attributes.get("target"), 52 project.setProperty(attributes.get("target"),
53 Math.round(du(path) / 1024) + ""); 53 Math.round(du(path) / 1024) + "");
54 ]]> 54 ]]>
55 </scriptdef> 55 </scriptdef>
56 56
57 <!-- launch4j demands 4-part version numbers, grumble... -->
58 <scriptdef language="javascript" name="l4jversion">
59 <attribute name="value" />
60 <attribute name="target" />
61 <![CDATA[
62 "use strict";
63 var IllegalArgumentException = Java.type('java.lang.IllegalArgumentException');
64 var value = attributes.get("value");
65 var ret = null;
66 if (value.match(/\d+\.\d+\.\d+\.\d+/))
67 ret = value;
68 else if(value.match(/\d+\.\d+\.\d+/))
69 ret = value + ".0";
70 else if(value.match(/\d+\.\d+/))
71 ret = value + ".0.0";
72 else
73 throw new IllegalArgumentException("invalid version: " + value);
74 project.setProperty(attributes.get("target"), ret);
75 ]]>
76 </scriptdef>
77
57 <!-- Define the properties used by the build --> 78 <!-- Define the properties used by the build -->
58 <property name="app.name" value="${ant.project.name}"/> 79 <property name="app.name" value="${ant.project.name}"/>
59 <property name="app.version" value="1.03"/> 80 <property name="app.version" value="1.03"/>
60 <property name="app.domain" value="name.blackcap.exifwasher"/> 81 <property name="app.domain" value="name.blackcap.exifwasher"/>
61 <property name="app.entry" value="${app.domain}.MainKt"/> 82 <property name="app.entry" value="${app.domain}.MainKt"/>
83 <property name="app.copyright" value="Copyright © 2020, David W. Barts."/>
62 <toLowerCase target="lc.app.name" value="${app.name}"/> 84 <toLowerCase target="lc.app.name" value="${app.name}"/>
63 <property name="jar.name" value="${basedir}/${lc.app.name}.jar"/> 85 <property name="jar.name" value="${basedir}/${lc.app.name}.jar"/>
64 <property name="work.jar" value="${basedir}/work.jar"/> 86 <property name="work.jar" value="${basedir}/work.jar"/>
65 <property name="lib.home" value="${basedir}/lib"/> 87 <property name="lib.home" value="${basedir}/lib"/>
66 <property name="src.home" value="${basedir}/src"/> 88 <property name="src.home" value="${basedir}/src"/>
67 <property name="dist.home" value="${basedir}/dist"/> 89 <property name="dist.home" value="${basedir}/dist"/>
68 <property name="pf.home" value="${basedir}/package-files"/> 90 <property name="pf.home" value="${basedir}/package-files"/>
69 <property name="nat.dir" value="${src.home}/name/blackcap/exifwasher/exiv2"/> 91 <property name="nat.dir" value="${src.home}/name/blackcap/exifwasher/exiv2"/>
70 <property name="bin.dir" value="${src.home}/name/blackcap/exifwasher/binaries"/> 92 <property name="bin.dir" value="${src.home}/name/blackcap/exifwasher/binaries"/>
71 <property name="jvm.version" value="1.8"/> 93 <property name="jvm.version" value="1.8"/>
72
73 <!-- load the ant-contrib tasks -->
74 <!-- TODO: see if we need this, remove if not (also see xmlns above) -->
75 <taskdef resource="net/sf/antcontrib/antlib.xml"
76 uri="antlib:net.sf.antcontrib">
77 <classpath>
78 <fileset dir="${lib.home}/ant-contrib" includes="*.jar"/>
79 </classpath>
80 </taskdef>
81
82 <!-- load launch4j (Windows app bundler) tasks -->
83 <contrib:if>
84 <os family="windows"/>
85 <contrib:then>
86 <taskdef name="create"
87 classname="net.sf.launch4j.ant.Launch4jTask"
88 uri="antlib:net.sf.launch4j.ant">
89 <classpath>
90 <fileset dir="${lib.home}/launch4j" includes="*.jar"/>
91 </classpath>
92 </taskdef>
93 </contrib:then>
94 </contrib:if>
95 94
96 <!-- define the kotlin task --> 95 <!-- define the kotlin task -->
97 <property name="kotlin.lib" value="${env.KOTLIN_HOME}/lib"/> 96 <property name="kotlin.lib" value="${env.KOTLIN_HOME}/lib"/>
98 <typedef resource="org/jetbrains/kotlin/ant/antlib.xml" 97 <typedef resource="org/jetbrains/kotlin/ant/antlib.xml"
99 classpath="${kotlin.lib}/kotlin-ant.jar"/> 98 classpath="${kotlin.lib}/kotlin-ant.jar"/>
198 <mkdir dir="${app.bundle}/Contents"/> 197 <mkdir dir="${app.bundle}/Contents"/>
199 <copy todir="${app.bundle}/Contents" encoding="UTF-8" overwrite="true"> 198 <copy todir="${app.bundle}/Contents" encoding="UTF-8" overwrite="true">
200 <fileset file="${pf.home}/osx/Info.plist"/> 199 <fileset file="${pf.home}/osx/Info.plist"/>
201 <!-- XXX will break if any tokens contain <, >, or & --> 200 <!-- XXX will break if any tokens contain <, >, or & -->
202 <filterset> 201 <filterset>
202 <filter token="app.copyright" value="${app.copyright}"/>
203 <filter token="app.domain" value="${app.domain}"/> 203 <filter token="app.domain" value="${app.domain}"/>
204 <filter token="app.entry" value="${app.entry}"/> 204 <filter token="app.entry" value="${app.entry}"/>
205 <filter token="app.name" value="${app.name}"/> 205 <filter token="app.name" value="${app.name}"/>
206 <filter token="app.version" value="${app.version}"/> 206 <filter token="app.version" value="${app.version}"/>
207 <filter token="jar.filename" value="${lc.app.name}.jar"/> 207 <filter token="jar.filename" value="${lc.app.name}.jar"/>
254 </exec> 254 </exec>
255 </sequential> 255 </sequential>
256 </target> 256 </target>
257 257
258 <target name="winapp" depends="jar" description="Create app bundle."> 258 <target name="winapp" depends="jar" description="Create app bundle.">
259 <!-- not finished --> 259 <fail message="The Windows application can only be built on Windows.">
260 <condition>
261 <not><os family="windows"/></not>
262 </condition>
263 </fail>
264 <sequential>
265 <env-require name="LAUNCH4J_HOME"/>
266 <taskdef name="create"
267 classname="net.sf.launch4j.ant.Launch4jTask"
268 uri="antlib:net.sf.launch4j.ant">
269 <classpath>
270 <fileset dir="${env.LAUNCH4J_HOME}" includes="launch4j.jar"/>
271 </classpath>
272 </taskdef>
273 <l4jversion value="${app.version}" target="l4j.version"/>
274 <copy todir="${dist.home}/" encoding="UTF-8" overwrite="true">
275 <fileset file="${pf.home}/windows/exifwasher_l4j.xml"/>
276 <filterset>
277 <filter token="app.copyright" value="${app.copyright}"/>
278 <filter token="app.entry" value="${app.entry}"/>
279 <filter token="app.name" value="${app.name}"/>
280 <filter token="app.version" value="${app.version}"/>
281 <filter token="base.dir" value="${basedir}"/>
282 <filter token="dist.home" value="${dist.home}"/>
283 <filter token="jar.filename" value="${jar.name}"/>
284 <filter token="l4j.version" value="${l4j.version}"/>
285 <filter token="target.java.version" value="${jvm.version}"/>
286 </filterset>
287 </copy>
288 <launch4j:create configFile="${dist.home}/exifwasher_l4j.xml"/>
289 </sequential>
260 </target> 290 </target>
261 291
262 <target name="deb" depends="jar" description="Create Debian package."> 292 <target name="deb" depends="jar" description="Create Debian package.">
263 <fail message="Linux packages can only be built on Linux."> 293 <fail message="Linux packages can only be built on Linux.">
264 <condition> 294 <condition>
275 <mkdir dir="${dist.home}/data/usr/share/jpegwasher"/> 305 <mkdir dir="${dist.home}/data/usr/share/jpegwasher"/>
276 <copy file="${jar.name}" todir="${dist.home}/data/usr/share/jpegwasher"/> 306 <copy file="${jar.name}" todir="${dist.home}/data/usr/share/jpegwasher"/>
277 <mkdir dir="${dist.home}/data/usr/share/doc/jpegwasher"/> 307 <mkdir dir="${dist.home}/data/usr/share/doc/jpegwasher"/>
278 <copy todir="${dist.home}/data/usr/share/doc/jpegwasher"> 308 <copy todir="${dist.home}/data/usr/share/doc/jpegwasher">
279 <filelist dir="${basedir}" files="Readme.html,Readme.rst"/> 309 <filelist dir="${basedir}" files="Readme.html,Readme.rst"/>
310 </copy>
311 <copy todir="${dist.home}/data/usr/share/doc/jpegwasher" encoding="UTF-8" overwrite="true">
280 <fileset file="${pf.home}/linux/deb/copyright"/> 312 <fileset file="${pf.home}/linux/deb/copyright"/>
313 <filterset>
314 <filter token="app.copyright" value="${app.copyright}"/>
315 </filterset>
281 </copy> 316 </copy>
282 <gzip src="${pf.home}/linux/deb/changelog" 317 <gzip src="${pf.home}/linux/deb/changelog"
283 destfile="${dist.home}/data/usr/share/doc/jpegwasher/changelog.gz"/> 318 destfile="${dist.home}/data/usr/share/doc/jpegwasher/changelog.gz"/>
284 <mkdir dir="${dist.home}/data/usr/share/man/man1"/> 319 <mkdir dir="${dist.home}/data/usr/share/man/man1"/>
285 <gzip src="${pf.home}/linux/jpegwasher.1" 320 <gzip src="${pf.home}/linux/jpegwasher.1"