diff 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
line wrap: on
line diff
--- a/build.xml	Fri Apr 24 14:01:03 2020 -0700
+++ b/build.xml	Fri Apr 24 19:45:57 2020 -0700
@@ -1,5 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<project name="JpegWasher" default="help" basedir="." xmlns:fx="javafx:com.sun.javafx.tools.ant">
+<project name="JpegWasher" default="help" basedir="."
+  xmlns:contrib="antlib:net.sf.antcontrib"
+  xmlns:jarbundler="antlib:com.ultramixer.jarbundler"
+  xmlns:launch4j="antlib:net.sf.launch4j.ant"
+  xmlns:mod="antlib:de.masters_of_disaster.ant.tasks">
   <!-- import all environment variables as env.* -->
   <property environment="env"/>
 
@@ -17,15 +21,8 @@
   <env-require name="JRE_HOME"/>
   <env-require name="KOTLIN_HOME"/>
 
-  <!-- define the kotlin task -->
-  <property name="kotlin.lib" value="${env.KOTLIN_HOME}/lib"/>
-  <typedef resource="org/jetbrains/kotlin/ant/antlib.xml"
-           classpath="${kotlin.lib}/kotlin-ant.jar"/>
-
-  <!-- define the package-building tasks -->
-  <taskdef resource="com/sun/javafx/tools/ant/antlib.xml"
-           uri="javafx:com.sun.javafx.tools.ant"
-           classpath="${env.JRE_HOME}/lib/ant-javafx.jar"/>
+  <!-- load launch4j (Windows app builder) -->
+  <!-- load m-o-d (Linux Gnome app builder) -->
 
   <!-- cribbed from https://stackoverflow.com/questions/7129672/uppercase-lowercase-capitalize-an-ant-property -->
   <scriptdef language="javascript" name="toLowerCase">
@@ -49,6 +46,66 @@
   <property name="nat.dir"       value="${src.home}/name/blackcap/exifwasher/exiv2"/>
   <property name="bin.dir"       value="${src.home}/name/blackcap/exifwasher/binaries"/>
 
+  <!-- load the ant-contrib tasks -->
+  <taskdef resource="net/sf/antcontrib/antlib.xml"
+           uri="antlib:net.sf.antcontrib">
+    <classpath>
+      <fileset dir="${lib.home}/ant-contrib" includes="*.jar"/>
+    </classpath>
+  </taskdef>
+
+  <!-- load jarbundler (Mac app bundler) tasks -->
+  <contrib:if>
+    <os family="mac"/>
+    <contrib:then>
+      <taskdef name="create"
+               classname="com.ultramixer.jarbundler.JarBundler"
+               classpath="${lib.home}/jarbundler-core-3.3.0.jar"
+               uri="antlib:com.ultramixer.jarbundler">
+      </taskdef>
+    </contrib:then>
+  </contrib:if>
+
+  <!-- load launch4j (Windows app bundler) tasks -->
+  <contrib:if>
+    <os family="windows"/>
+    <contrib:then>
+      <taskdef name="create"
+               classname="net.sf.launch4j.ant.Launch4jTask"
+               uri="antlib:net.sf.launch4j.ant">
+        <classpath>
+          <fileset dir="${lib.dir}/launch4j" includes="*.jar"/>
+        </classpath>
+      </taskdef>
+    </contrib:then>
+  </contrib:if>
+
+  <!-- load mod (Gnome app bundler) tasks -->
+  <contrib:if>
+    <os family="unix"/>
+    <contrib:then>
+      <taskdef name="calculatesize"
+               classname="de.masters_of_disaster.ant.tasks.calculatesize.CalculateSize"
+               uri="antlib:de.masters_of_disaster.ant.tasks">
+        <classpath>
+          <fileset dir="${lib.dir}/mod" includes="*.jar"/>
+        </classpath>
+      </taskdef>
+      <taskdef name="deb"
+               classname="de.masters_of_disaster.ant.tasks.deb.Deb"
+               uri="antlib:de.masters_of_disaster.ant.tasks"/>
+        <classpath>
+          <fileset dir="${lib.dir}/mod" includes="*.jar"/>
+        </classpath>
+      </taskdef>
+    </contrib:then>
+  </contrib:if>
+
+  <!-- define the kotlin task -->
+  <property name="kotlin.lib" value="${env.KOTLIN_HOME}/lib"/>
+  <typedef resource="org/jetbrains/kotlin/ant/antlib.xml"
+           classpath="${kotlin.lib}/kotlin-ant.jar"/>
+
   <!-- help message -->
   <target name="help">
     <echo>You can use the following targets:</echo>
@@ -63,26 +120,40 @@
     <echo>prompt> ant all </echo>
   </target>
 
+  <!-- Determine OS type -->
+  <condition property="os.type" value="mac">
+    <os family="mac"/>
+  </condition>
+  <condition property="os.type" value="windows">
+    <os family="windows"/>
+  </condition>
+  <condition property="os.type" value="linux">
+    <!-- notes: 1) XXX not all non-mac UNIX systems are Linux, but this assumes
+         so; 2) this clause MUST appear AFTER the "mac" one -->
+    <os family="unix"/>
+  </condition>
+  <property name="os.type" value="unknown"/>
+
   <!-- Define the CLASSPATH -->
   <target name="classpath">
-    <path id="std.classpath">
-      <fileset dir="${lib.home}">
-        <include name="*.jar"/>
-      </fileset>
-    </path>
     <path id="compile.classpath">
-      <path refid="std.classpath"/>
       <pathelement location="${src.home}"/>
     </path>
-    <path id="test.classpath">
-      <path refid="std.classpath"/>
-      <pathelement location="${work.home}"/>
-    </path>
   </target>
 
   <!-- make needed directories -->
   <target name="mkdirs">
     <mkdir dir="${lib.home}"/>
+    <mkdir dir="${src.home}/name/blackcap/exifwasher/binaries/${os.type}"/>
+  </target>
+
+  <!-- rename files containing OS-dependant code -->
+  <target name="osdep">
+    <exec executable="${env.JRE_HOME}/bin/java">
+      <arg value="-jar"/>
+      <arg value="../Osdep/osdep.jar"/>
+      <arg value="${src.home}"/>
+    </exec>
   </target>
 
   <!-- do everything but install -->
@@ -90,7 +161,7 @@
           description="Clean work dirs, compile, make JAR."/>
 
   <!-- compile *.kt to *.class -->
-  <target name="compile" depends="mkdirs,classpath"
+  <target name="compile" depends="mkdirs,osdep,classpath"
           description="Compile Java sources to ${work.home}">
     <kotlinc src="${src.home}" output="${work.jar}"
              classpathref="compile.classpath">