changeset 22:829769cb1c13

Add some support for making bundled apps to build.xml.
author David Barts <n5jrn@me.com>
date Thu, 23 Jan 2020 10:11:16 -0800
parents c10a447b9e1b
children 14049bc97a7c
files build.xml
diffstat 1 files changed, 39 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/build.xml	Thu Jan 23 00:02:07 2020 -0800
+++ b/build.xml	Thu Jan 23 10:11:16 2020 -0800
@@ -33,9 +33,10 @@
 
   <!-- Define the properties used by the build -->
   <property name="app.name"      value="${ant.project.name}"/>
+  <property name="app.entry"     value="name.blackcap.clipman.MainKt"/>
   <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"/>
+  <property name="work.jar"      value="${basedir}/work.jar"/>
   <property name="lib.home"      value="${basedir}/lib"/>
   <property name="src.home"      value="${basedir}/src"/>
 
@@ -85,11 +86,47 @@
   <target name="jar" depends="compile" description="Create JAR file.">
     <jar destfile="${jar.name}">
       <manifest>
-        <attribute name="Main-Class" value="name.blackcap.clipman.MainKt"/>
+        <attribute name="Main-Class" value="${app.entry}"/>
       </manifest>
       <zipgroupfileset dir="${lib.home}" includes="*.jar"/>
       <zipfileset src="${work.jar}"/>
     </jar>
   </target>
 
+  <!-- for making bundled apps -->
+  <macrodef name="bundle">
+    <attribute name="type"/>
+    <sequential>
+      <exec executable="${env.JRE_HOME}/bin/javapackager" dir="${basedir}">
+        <arg value="-deploy"/>
+        <arg value="-Bruntime=${env.JRE_HOME}"/>
+        <arg value="-native"/> <arg value="@{type}"/>
+        <arg value="-srcfiles"/> <arg value="${jar.name}"/>
+        <arg value="-outdir"/> <arg value="${basedir}"/>
+        <arg value="-outfile"/> <arg value="${app.name}.@{type}"/>
+        <arg value="-appclass"/> <arg value="${app.entry}"/>
+        <arg value="-name"/> <arg value="${app.name}"/>
+        <arg value="-title"/> <arg value="${app.name}"/>
+        <arg value="-vendor"/> <arg value="David Barts &lt;n5jrn@me.com&gt;"/>
+        <arg value="-nosign"/>
+      </exec>
+    </sequential>
+  </macrodef>
+
+  <target name="dmg" depends="jar" description="Create MacOS app bundle.">
+    <bundle type="dmg"/>
+  </target>
+
+  <target name="pkg" depends="jar" description="Create MacOS app bundle.">
+    <bundle type="dmg"/>
+  </target>
+
+  <target name="rpm" depends="jar" description="Create MacOS app bundle.">
+    <bundle type="rpm"/>
+  </target>
+
+  <target name="deb" depends="jar" description="Create MacOS app bundle.">
+    <bundle type="deb"/>
+  </target>
+
 </project>