changeset 59:8b707fa0a4fc

Convert to new-style mac app.
author David Barts <n5jrn@me.com>
date Sun, 03 Apr 2022 15:37:42 -0700
parents 88056f373a94
children 066f05ebcc00
files ClipMan.icns ClipMan.iconset/icon_128x128.png ClipMan.iconset/icon_128x128@2x.png ClipMan.iconset/icon_16x16.png ClipMan.iconset/icon_16x16@2x.png ClipMan.iconset/icon_256x256.png ClipMan.iconset/icon_256x256@2x.png ClipMan.iconset/icon_32x32.png ClipMan.iconset/icon_32x32@2x.png ClipMan.iconset/icon_512x512.png ClipMan.iconset/icon_512x512@2x.png build.xml
diffstat 12 files changed, 86 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
Binary file ClipMan.icns has changed
Binary file ClipMan.iconset/icon_128x128.png has changed
Binary file ClipMan.iconset/icon_128x128@2x.png has changed
Binary file ClipMan.iconset/icon_16x16.png has changed
Binary file ClipMan.iconset/icon_16x16@2x.png has changed
Binary file ClipMan.iconset/icon_256x256.png has changed
Binary file ClipMan.iconset/icon_256x256@2x.png has changed
Binary file ClipMan.iconset/icon_32x32.png has changed
Binary file ClipMan.iconset/icon_32x32@2x.png has changed
Binary file ClipMan.iconset/icon_512x512.png has changed
Binary file ClipMan.iconset/icon_512x512@2x.png has changed
--- a/build.xml	Sat Mar 26 23:45:34 2022 -0700
+++ b/build.xml	Sun Apr 03 15:37:42 2022 -0700
@@ -30,12 +30,16 @@
   <!-- Define the properties used by the build -->
   <property name="app.name"      value="${ant.project.name}"/>
   <property name="app.entry"     value="name.blackcap.clipman.MainKt"/>
+  <property name="app.version"   value="1.10"/>
   <property name="lc.app.name"   value="clipman"/>
   <property name="jar.name"      value="${basedir}/${lc.app.name}.jar"/>
   <property name="work.jar"      value="${basedir}/work.jar"/>
   <property name="lib.home"      value="${basedir}/lib"/>
   <property name="src.home"      value="${basedir}/src"/>
   <property name="work.home"      value="${basedir}/work"/>
+  <property name="dist.home"     value="${basedir}/dist"/>
+  <property name="pf.home"       value="${basedir}/package-files"/>
+  <property name="jvm.version"   value="1.8"/>
 
   <!-- help message -->
   <target name="help">
@@ -68,6 +72,18 @@
     </path>
   </target>
 
+  <!-- make needed directories -->
+  <target name="mkdirs">
+    <mkdir dir="${dist.home}"/>
+  </target>
+
+  <!-- remove old cruft -->
+  <target name="clean">
+    <delete includeEmptyDirs="true" failonerror="false">
+      <fileset dir="${dist.home}" includes="**/*"/>
+    </delete>
+  </target>
+
   <!-- do everything but install -->
   <target name="all" depends="jar"
           description="Clean work dirs, compile, make JAR."/>
@@ -78,7 +94,7 @@
     <kotlinc src="${src.home}" output="${work.jar}"
              noStdlib="false" includeRuntime="true"
              classpathref="compile.classpath">
-      <compilerarg line="-jvm-target 1.8"/>
+      <compilerarg line="-jvm-target ${jvm.version}"/>
     </kotlinc>
   </target>
 
@@ -115,12 +131,75 @@
       </sequential>
   </macrodef>
 
-  <target name="macapp" depends="jar" description="Create MacOS app bundle.">
-    <bundle type="image">
-      <args>
-        <fx:bundleArgument arg="jvmOptions" value="-Xdock:name=${app.name}"/>
-      </args>
-    </bundle>
+  <target name="macapp" depends="mkdirs,jar" description="Create MacOS app bundle.">
+    <fail message="Macintosh packages can only be built on a Mac.">
+      <condition>
+        <not><os family="mac"/></not>
+      </condition>
+    </fail>
+    <sequential>
+      <property name="mac.disk.image.filename"
+                value="${lc.app.name}_${app.version}.dmg"/>
+      <property name="app.bundle" value="${dist.home}/${app.name}.app"/>
+      <mkdir dir="${app.bundle}/Contents"/>
+      <copy todir="${app.bundle}/Contents" encoding="UTF-8" overwrite="true">
+        <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}"/>
+          <filter token="app.version" value="${app.version}"/>
+          <filter token="jar.filename" value="${lc.app.name}.jar"/>
+          <filter token="jvm.version" value="${jvm.version}"/>
+          <filter token="lc.app.name" value="${lc.app.name}"/>
+        </filterset>
+      </copy>
+      <mkdir dir="${app.bundle}/Contents/MacOS"/>
+      <copy todir="${app.bundle}/Contents/MacOS" encoding="UTF-8"
+            overwrite="true">
+        <fileset file="${pf.home}/osx/JavaApplicationStub"/>
+        <filterset>
+          <filter token="app.domain" value="${app.domain}"/>
+          <filter token="app.name" value="${app.name}"/>
+        </filterset>
+      </copy>
+      <chmod file="${app.bundle}/Contents/MacOS/JavaApplicationStub"
+             perm="755"/>
+      <mkdir dir="${app.bundle}/Contents/Resources"/>
+      <copy file="${basedir}/${app.name}.icns"
+            todir="${app.bundle}/Contents/Resources"/>
+      <mkdir dir="${app.bundle}/Contents/Java"/>
+      <copy file="${jar.name}" todir="${app.bundle}/Contents/Java"/>
+      <echo file="${app.bundle}/Contents/PkgInfo" message="APPL????"/>
+      <exec executable="hdiutil" failonerror="true">
+        <arg value="create"/>
+        <arg value="-volname"/>
+        <arg value="${app.name}"/>
+        <arg value="-srcfolder"/>
+        <arg file="${app.bundle}"/>
+        <arg file="${dist.home}/orig-${mac.disk.image.filename}"/>
+      </exec>
+      <exec executable="hdiutil" failonerror="true">
+        <arg value="convert"/>
+        <arg file="${dist.home}/orig-${mac.disk.image.filename}"/>
+        <arg value="-format"/>
+        <arg value="UDRW"/>
+        <arg value="-o"/>
+        <arg file="${dist.home}/udrw-${mac.disk.image.filename}"/>
+      </exec>
+      <exec executable="hdiutil" failonerror="true">
+        <arg value="convert"/>
+        <arg file="${dist.home}/udrw-${mac.disk.image.filename}"/>
+        <arg value="-format"/>
+        <arg value="UDZO"/>
+        <arg value="-imagekey"/>
+        <arg value="zlib-level=9"/>
+        <arg value="-o"/>
+        <arg file="${dist.home}/${mac.disk.image.filename}"/>
+      </exec>
+    </sequential>
   </target>
 
   <target name="dummywork" description="dummy dir to make javapackager happy">