changeset 42:4076f1bbf21d

Got ant winapp working!
author davidb
date Sat, 02 May 2020 10:38:33 -0700
parents 4903ac32a287
children 8aada13933c6
files Makefile.win build.xml lib/jarbundler-core-3.3.0.jar package-files/linux/deb/copyright package-files/osx/Info.plist package-files/windows/exifwasher_l4j.xml package-files/windows/jedit.launch4j.xml setup.cmd
diffstat 8 files changed, 95 insertions(+), 80 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.win	Fri May 01 23:12:35 2020 -0700
+++ b/Makefile.win	Sat May 02 10:38:33 2020 -0700
@@ -8,7 +8,10 @@
 
 .PHONY: all checkenv
 
-all: checkenv $(BDIR)\jni.dll $(BDIR)\exiv2.dll
+all: mkdirs checkenv $(BDIR)\jni.dll $(BDIR)\exiv2.dll
+
+mkdirs:
+	@if not exist "$(BDIR)" md "$(BDIR)"
 
 checkenv:
 	@checkenv JRE_HOME EXIV2_HOME
@@ -17,7 +20,6 @@
 	$(CXX) $(CXXFLAGS) /c /Fo:"$@" "$?"
 
 $(BDIR)\jni.dll: $(NDIR)\native.obj
-	if not exist "$(BDIR)" md "$(BDIR)"
 	$(LD) $(LDFLAGS) /OUT:"$@" "$?"
 
 $(BDIR)\exiv2.dll: "$(EXIV2_HOME)\bin\exiv2.dll"
--- a/build.xml	Fri May 01 23:12:35 2020 -0700
+++ b/build.xml	Sat May 02 10:38:33 2020 -0700
@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project name="JpegWasher" default="help" basedir="."
-  xmlns:contrib="antlib:net.sf.antcontrib"
   xmlns:launch4j="antlib:net.sf.launch4j.ant">
   <!-- import all environment variables as env.* -->
   <property environment="env"/>
@@ -30,6 +29,7 @@
     ]]>
   </scriptdef>
 
+  <!-- estimate disk usage -->
   <scriptdef language="javascript" name="du">
     <attribute name="path" />
     <attribute name="target" />
@@ -54,11 +54,33 @@
     ]]>
   </scriptdef>
 
+  <!-- launch4j demands 4-part version numbers, grumble... -->
+  <scriptdef language="javascript" name="l4jversion">
+    <attribute name="value" />
+    <attribute name="target" />
+    <![CDATA[
+      "use strict";
+      var IllegalArgumentException = Java.type('java.lang.IllegalArgumentException');
+      var value = attributes.get("value");
+      var ret = null;
+      if (value.match(/\d+\.\d+\.\d+\.\d+/))
+        ret = value;
+      else if(value.match(/\d+\.\d+\.\d+/))
+        ret = value + ".0";
+      else if(value.match(/\d+\.\d+/))
+        ret = value + ".0.0";
+      else
+        throw new IllegalArgumentException("invalid version: " + value);
+      project.setProperty(attributes.get("target"), ret);
+    ]]>
+  </scriptdef>
+
   <!-- Define the properties used by the build -->
   <property name="app.name"      value="${ant.project.name}"/>
   <property name="app.version"   value="1.03"/>
   <property name="app.domain"    value="name.blackcap.exifwasher"/>
   <property name="app.entry"     value="${app.domain}.MainKt"/>
+  <property name="app.copyright" value="Copyright © 2020, David W. Barts."/>
   <toLowerCase target="lc.app.name" value="${app.name}"/>
   <property name="jar.name"      value="${basedir}/${lc.app.name}.jar"/>
   <property name="work.jar"      value="${basedir}/work.jar"/>
@@ -70,29 +92,6 @@
   <property name="bin.dir"       value="${src.home}/name/blackcap/exifwasher/binaries"/>
   <property name="jvm.version"   value="1.8"/>
 
-  <!-- load the ant-contrib tasks -->
-  <!-- TODO: see if we need this, remove if not (also see xmlns above) -->
-  <taskdef resource="net/sf/antcontrib/antlib.xml"
-           uri="antlib:net.sf.antcontrib">
-    <classpath>
-      <fileset dir="${lib.home}/ant-contrib" includes="*.jar"/>
-    </classpath>
-  </taskdef>
-
-  <!-- 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.home}/launch4j" 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"
@@ -200,6 +199,7 @@
         <fileset file="${pf.home}/osx/Info.plist"/>
         <!-- XXX will break if any tokens contain <, >, or & -->
         <filterset>
+          <filter token="app.copyright" value="${app.copyright}"/>
           <filter token="app.domain" value="${app.domain}"/>
           <filter token="app.entry" value="${app.entry}"/>
           <filter token="app.name" value="${app.name}"/>
@@ -256,7 +256,37 @@
   </target>
 
   <target name="winapp" depends="jar" description="Create app bundle.">
-    <!-- not finished -->
+    <fail message="The Windows application can only be built on Windows.">
+      <condition>
+        <not><os family="windows"/></not>
+      </condition>
+    </fail>
+    <sequential>
+      <env-require name="LAUNCH4J_HOME"/>
+      <taskdef name="create"
+               classname="net.sf.launch4j.ant.Launch4jTask"
+               uri="antlib:net.sf.launch4j.ant">
+        <classpath>
+          <fileset dir="${env.LAUNCH4J_HOME}" includes="launch4j.jar"/>
+        </classpath>
+      </taskdef>
+      <l4jversion value="${app.version}" target="l4j.version"/>
+      <copy todir="${dist.home}/" encoding="UTF-8" overwrite="true">
+        <fileset file="${pf.home}/windows/exifwasher_l4j.xml"/>
+        <filterset>
+          <filter token="app.copyright" value="${app.copyright}"/>
+          <filter token="app.entry" value="${app.entry}"/>
+          <filter token="app.name" value="${app.name}"/>
+          <filter token="app.version" value="${app.version}"/>
+          <filter token="base.dir" value="${basedir}"/>
+          <filter token="dist.home" value="${dist.home}"/>
+          <filter token="jar.filename" value="${jar.name}"/>
+          <filter token="l4j.version" value="${l4j.version}"/>
+          <filter token="target.java.version" value="${jvm.version}"/>
+        </filterset>
+      </copy>
+      <launch4j:create configFile="${dist.home}/exifwasher_l4j.xml"/>
+    </sequential>
   </target>
 
   <target name="deb" depends="jar" description="Create Debian package.">
@@ -277,7 +307,12 @@
       <mkdir dir="${dist.home}/data/usr/share/doc/jpegwasher"/>
       <copy todir="${dist.home}/data/usr/share/doc/jpegwasher">
         <filelist dir="${basedir}" files="Readme.html,Readme.rst"/>
+      </copy>
+      <copy todir="${dist.home}/data/usr/share/doc/jpegwasher" encoding="UTF-8" overwrite="true">
         <fileset file="${pf.home}/linux/deb/copyright"/>
+        <filterset>
+          <filter token="app.copyright" value="${app.copyright}"/>
+        </filterset>
       </copy>
       <gzip src="${pf.home}/linux/deb/changelog"
         destfile="${dist.home}/data/usr/share/doc/jpegwasher/changelog.gz"/>
Binary file lib/jarbundler-core-3.3.0.jar has changed
--- a/package-files/linux/deb/copyright	Fri May 01 23:12:35 2020 -0700
+++ b/package-files/linux/deb/copyright	Sat May 02 10:38:33 2020 -0700
@@ -1,4 +1,4 @@
-    Copyright © 2020, David W. Barts.
+    @app.copyright@
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
--- a/package-files/osx/Info.plist	Fri May 01 23:12:35 2020 -0700
+++ b/package-files/osx/Info.plist	Sat May 02 10:38:33 2020 -0700
@@ -24,7 +24,7 @@
     <key>CFBundleVersion</key>
     <string>@app.version@</string>
     <key>NSHumanReadableCopyright</key>
-    <string>Copyright © 2020, David Barts</string>
+    <string>@app.copyright@</string>
     <!-- most package builders throw the following in -->
     <key>CFBundleAllowMixedLocalizations</key>
     <string>false</string>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/package-files/windows/exifwasher_l4j.xml	Sat May 02 10:38:33 2020 -0700
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<launch4jConfig>
+  <headerType>gui</headerType>
+  <outfile>@dist.home@/@app.name@.exe</outfile>
+  <jar>@jar.filename@</jar>
+  <errTitle>@app.name@</errTitle>
+  <stayAlive>true</stayAlive>
+  <icon>@base.dir@/@app.name@.ico</icon>
+  <classPath>
+    <mainClass>@app.entry@</mainClass>
+  </classPath>
+  <jre>
+    <minVersion>@target.java.version@.0</minVersion>
+    <jdkPreference>preferJdk</jdkPreference>
+  </jre>
+  <versionInfo>
+    <copyright>@app.copyright@</copyright>
+    <fileDescription>JpegWasher&#8212;Privacy for your photos.</fileDescription>
+    <fileVersion>@l4j.version@</fileVersion>
+    <internalName>@app.name@</internalName>
+    <language>ENGLISH_US</language>
+    <originalFilename>@app.name@.exe</originalFilename>
+    <productName>@app.name@</productName>
+    <productVersion>@l4j.version@</productVersion>
+    <txtFileVersion>@app.version@</txtFileVersion>
+    <txtProductVersion>@app.version@</txtProductVersion>
+  </versionInfo>
+</launch4jConfig>
--- a/package-files/windows/jedit.launch4j.xml	Fri May 01 23:12:35 2020 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ jEdit - Programmer's Text Editor
-  ~ :tabSize=8:indentSize=8:noTabs=false:
-  ~ :folding=explicit:collapseFolds=1:
-  ~
-  ~ Copyright © 2014 jEdit contributors
-  ~
-  ~ This program is free software; you can redistribute it and/or
-  ~ modify it under the terms of the GNU General Public License
-  ~ as published by the Free Software Foundation; either version 2
-  ~ of the License, or any later version.
-  ~ This program is distributed in the hope that it will be useful,
-  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
-  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  ~ GNU General Public License for more details.
-  ~
-  ~ You should have received a copy of the GNU General Public License
-  ~ along with this program; if not, write to the Free Software
-  ~ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-  -->
-
-<launch4jConfig>
-	<headerType>gui</headerType>
-	<outfile>jedit.exe</outfile>
-	<jar>@jar.filename@</jar>
-	<dontWrapJar>true</dontWrapJar>
-	<errTitle>jEdit</errTitle>
-	<downloadUrl>http://www.java.com/download</downloadUrl>
-	<supportUrl>http://www.jEdit.org</supportUrl>
-	<cmdLine>-reuseview</cmdLine>
-	<stayAlive>true</stayAlive>
-	<icon>@base.dir@/icons/jedit.ico</icon>
-	<jre>
-		<minVersion>@target.java.version@.0</minVersion>
-		<!-- Prefer JDK to make tools.jar available if possible. -->
-		<jdkPreference>preferJdk</jdkPreference>
-	</jre>
-	<versionInfo>
-		<fileVersion>@jedit.build.number@</fileVersion>
-		<txtFileVersion>@jedit.version@</txtFileVersion>
-		<fileDescription>jEdit - Programmer&apos;s Text Editor</fileDescription>
-		<copyright>Copyright © 1998-@current.year@ Contributors</copyright>
-		<productVersion>@jedit.build.number@</productVersion>
-		<txtProductVersion>@jedit.version@</txtProductVersion>
-		<productName>jEdit</productName>
-		<companyName>Contributors</companyName>
-		<internalName>jEdit</internalName>
-		<originalFilename>jedit.exe</originalFilename>
-	</versionInfo>
-</launch4jConfig>
--- a/setup.cmd	Fri May 01 23:12:35 2020 -0700
+++ b/setup.cmd	Sat May 02 10:38:33 2020 -0700
@@ -7,6 +7,7 @@
 set KOTLIN_HOME=C:\Users\David Barts\java\kotlin-compiler-1.3.71\kotlinc
 set ANT_HOME=C:\Users\David Barts\java\apache-ant-1.10.7
 set EXIV2_HOME=C:\Users\David Barts\Downloads\exiv2-0.27.2-2017msvc64\exiv2-0.27.2-2017msvc64
+set LAUNCH4J_HOME=C:\Program Files (x86)\Launch4j
 
 rem For each directory, fix PATH if needed.
 call :fixpath "%JRE_HOME%"