comparison build.xml @ 33:3d86f0391168

Work on improving the build system.
author David Barts <davidb@stashtea.com>
date Fri, 24 Apr 2020 19:45:57 -0700
parents 985d5b82a882
children d175593317a8
comparison
equal deleted inserted replaced
32:c06edc56669b 33:3d86f0391168
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <project name="JpegWasher" default="help" basedir="." xmlns:fx="javafx:com.sun.javafx.tools.ant"> 2 <project name="JpegWasher" default="help" basedir="."
3 xmlns:contrib="antlib:net.sf.antcontrib"
4 xmlns:jarbundler="antlib:com.ultramixer.jarbundler"
5 xmlns:launch4j="antlib:net.sf.launch4j.ant"
6 xmlns:mod="antlib:de.masters_of_disaster.ant.tasks">
3 <!-- import all environment variables as env.* --> 7 <!-- import all environment variables as env.* -->
4 <property environment="env"/> 8 <property environment="env"/>
5 9
6 <!-- ensure required environment variables are set --> 10 <!-- ensure required environment variables are set -->
7 <macrodef name="env-require"> 11 <macrodef name="env-require">
15 </sequential> 19 </sequential>
16 </macrodef> 20 </macrodef>
17 <env-require name="JRE_HOME"/> 21 <env-require name="JRE_HOME"/>
18 <env-require name="KOTLIN_HOME"/> 22 <env-require name="KOTLIN_HOME"/>
19 23
20 <!-- define the kotlin task --> 24 <!-- load launch4j (Windows app builder) -->
21 <property name="kotlin.lib" value="${env.KOTLIN_HOME}/lib"/> 25 <!-- load m-o-d (Linux Gnome app builder) -->
22 <typedef resource="org/jetbrains/kotlin/ant/antlib.xml"
23 classpath="${kotlin.lib}/kotlin-ant.jar"/>
24
25 <!-- define the package-building tasks -->
26 <taskdef resource="com/sun/javafx/tools/ant/antlib.xml"
27 uri="javafx:com.sun.javafx.tools.ant"
28 classpath="${env.JRE_HOME}/lib/ant-javafx.jar"/>
29 26
30 <!-- cribbed from https://stackoverflow.com/questions/7129672/uppercase-lowercase-capitalize-an-ant-property --> 27 <!-- cribbed from https://stackoverflow.com/questions/7129672/uppercase-lowercase-capitalize-an-ant-property -->
31 <scriptdef language="javascript" name="toLowerCase"> 28 <scriptdef language="javascript" name="toLowerCase">
32 <attribute name="value" /> 29 <attribute name="value" />
33 <attribute name="target" /> 30 <attribute name="target" />
46 <property name="work.jar" value="${basedir}/work.jar"/> 43 <property name="work.jar" value="${basedir}/work.jar"/>
47 <property name="lib.home" value="${basedir}/lib"/> 44 <property name="lib.home" value="${basedir}/lib"/>
48 <property name="src.home" value="${basedir}/src"/> 45 <property name="src.home" value="${basedir}/src"/>
49 <property name="nat.dir" value="${src.home}/name/blackcap/exifwasher/exiv2"/> 46 <property name="nat.dir" value="${src.home}/name/blackcap/exifwasher/exiv2"/>
50 <property name="bin.dir" value="${src.home}/name/blackcap/exifwasher/binaries"/> 47 <property name="bin.dir" value="${src.home}/name/blackcap/exifwasher/binaries"/>
48
49 <!-- load the ant-contrib tasks -->
50 <taskdef resource="net/sf/antcontrib/antlib.xml"
51 uri="antlib:net.sf.antcontrib">
52 <classpath>
53 <fileset dir="${lib.home}/ant-contrib" includes="*.jar"/>
54 </classpath>
55 </taskdef>
56
57 <!-- load jarbundler (Mac app bundler) tasks -->
58 <contrib:if>
59 <os family="mac"/>
60 <contrib:then>
61 <taskdef name="create"
62 classname="com.ultramixer.jarbundler.JarBundler"
63 classpath="${lib.home}/jarbundler-core-3.3.0.jar"
64 uri="antlib:com.ultramixer.jarbundler">
65 </taskdef>
66 </contrib:then>
67 </contrib:if>
68
69 <!-- load launch4j (Windows app bundler) tasks -->
70 <contrib:if>
71 <os family="windows"/>
72 <contrib:then>
73 <taskdef name="create"
74 classname="net.sf.launch4j.ant.Launch4jTask"
75 uri="antlib:net.sf.launch4j.ant">
76 <classpath>
77 <fileset dir="${lib.dir}/launch4j" includes="*.jar"/>
78 </classpath>
79 </taskdef>
80 </contrib:then>
81 </contrib:if>
82
83 <!-- load mod (Gnome app bundler) tasks -->
84 <contrib:if>
85 <os family="unix"/>
86 <contrib:then>
87 <taskdef name="calculatesize"
88 classname="de.masters_of_disaster.ant.tasks.calculatesize.CalculateSize"
89 uri="antlib:de.masters_of_disaster.ant.tasks">
90 <classpath>
91 <fileset dir="${lib.dir}/mod" includes="*.jar"/>
92 </classpath>
93 </taskdef>
94 <taskdef name="deb"
95 classname="de.masters_of_disaster.ant.tasks.deb.Deb"
96 uri="antlib:de.masters_of_disaster.ant.tasks"/>
97 <classpath>
98 <fileset dir="${lib.dir}/mod" includes="*.jar"/>
99 </classpath>
100 </taskdef>
101 </contrib:then>
102 </contrib:if>
103
104 <!-- define the kotlin task -->
105 <property name="kotlin.lib" value="${env.KOTLIN_HOME}/lib"/>
106 <typedef resource="org/jetbrains/kotlin/ant/antlib.xml"
107 classpath="${kotlin.lib}/kotlin-ant.jar"/>
51 108
52 <!-- help message --> 109 <!-- help message -->
53 <target name="help"> 110 <target name="help">
54 <echo>You can use the following targets:</echo> 111 <echo>You can use the following targets:</echo>
55 <echo> </echo> 112 <echo> </echo>
61 <echo> </echo> 118 <echo> </echo>
62 <echo>For example, to clean, compile, and package all at once, run:</echo> 119 <echo>For example, to clean, compile, and package all at once, run:</echo>
63 <echo>prompt> ant all </echo> 120 <echo>prompt> ant all </echo>
64 </target> 121 </target>
65 122
123 <!-- Determine OS type -->
124 <condition property="os.type" value="mac">
125 <os family="mac"/>
126 </condition>
127 <condition property="os.type" value="windows">
128 <os family="windows"/>
129 </condition>
130 <condition property="os.type" value="linux">
131 <!-- notes: 1) XXX not all non-mac UNIX systems are Linux, but this assumes
132 so; 2) this clause MUST appear AFTER the "mac" one -->
133 <os family="unix"/>
134 </condition>
135 <property name="os.type" value="unknown"/>
136
66 <!-- Define the CLASSPATH --> 137 <!-- Define the CLASSPATH -->
67 <target name="classpath"> 138 <target name="classpath">
68 <path id="std.classpath">
69 <fileset dir="${lib.home}">
70 <include name="*.jar"/>
71 </fileset>
72 </path>
73 <path id="compile.classpath"> 139 <path id="compile.classpath">
74 <path refid="std.classpath"/>
75 <pathelement location="${src.home}"/> 140 <pathelement location="${src.home}"/>
76 </path>
77 <path id="test.classpath">
78 <path refid="std.classpath"/>
79 <pathelement location="${work.home}"/>
80 </path> 141 </path>
81 </target> 142 </target>
82 143
83 <!-- make needed directories --> 144 <!-- make needed directories -->
84 <target name="mkdirs"> 145 <target name="mkdirs">
85 <mkdir dir="${lib.home}"/> 146 <mkdir dir="${lib.home}"/>
147 <mkdir dir="${src.home}/name/blackcap/exifwasher/binaries/${os.type}"/>
148 </target>
149
150 <!-- rename files containing OS-dependant code -->
151 <target name="osdep">
152 <exec executable="${env.JRE_HOME}/bin/java">
153 <arg value="-jar"/>
154 <arg value="../Osdep/osdep.jar"/>
155 <arg value="${src.home}"/>
156 </exec>
86 </target> 157 </target>
87 158
88 <!-- do everything but install --> 159 <!-- do everything but install -->
89 <target name="all" depends="jar" 160 <target name="all" depends="jar"
90 description="Clean work dirs, compile, make JAR."/> 161 description="Clean work dirs, compile, make JAR."/>
91 162
92 <!-- compile *.kt to *.class --> 163 <!-- compile *.kt to *.class -->
93 <target name="compile" depends="mkdirs,classpath" 164 <target name="compile" depends="mkdirs,osdep,classpath"
94 description="Compile Java sources to ${work.home}"> 165 description="Compile Java sources to ${work.home}">
95 <kotlinc src="${src.home}" output="${work.jar}" 166 <kotlinc src="${src.home}" output="${work.jar}"
96 classpathref="compile.classpath"> 167 classpathref="compile.classpath">
97 <compilerarg line="-jvm-target 1.8"/> 168 <compilerarg line="-jvm-target 1.8"/>
98 </kotlinc> 169 </kotlinc>