comparison build.xml @ 29:e90d290a9a8d

Remove dependence on Nashorn.
author David Barts <n5jrn@me.com>
date Mon, 13 Jun 2022 09:21:24 -0700
parents c310ec097194
children
comparison
equal deleted inserted replaced
28:c310ec097194 29:e90d290a9a8d
16 </macrodef> 16 </macrodef>
17 <env-require name="JRE_HOME"/> 17 <env-require name="JRE_HOME"/>
18 <env-require name="KOTLIN_HOME"/> 18 <env-require name="KOTLIN_HOME"/>
19 <env-require name="OSDEP_HOME"/> 19 <env-require name="OSDEP_HOME"/>
20 20
21 <!-- cribbed from https://stackoverflow.com/questions/7129672/uppercase-lowercase-capitalize-an-ant-property --> 21 <!-- du and toLowerCase need this -->
22 <scriptdef language="javascript" name="toLowerCase"> 22 <property name="antlib.jar" value="${basedir}/antlib/antlib.jar"/>
23 <attribute name="value" /> 23
24 <attribute name="target" /> 24 <!-- turn a string to lower case -->
25 <![CDATA[ 25 <taskdef name="toLowerCase" classname="ToLowerCase">
26 "use strict"; 26 <classpath>
27 project.setProperty( attributes.get( "target" ), 27 <pathelement location="${antlib.jar}"/>
28 attributes.get( "value" ).toLowerCase() ); 28 </classpath>
29 ]]> 29 </taskdef>
30 </scriptdef> 30
31 31 <!-- calculate disk usage in kbytes -->
32 <!-- estimate disk usage --> 32 <taskdef name="du" classname="Du">
33 <scriptdef language="javascript" name="du"> 33 <classpath>
34 <attribute name="path" /> 34 <pathelement location="${antlib.jar}"/>
35 <attribute name="target" /> 35 </classpath>
36 <![CDATA[ 36 </taskdef>
37 "use strict";
38 var File = Java.type('java.io.File');
39 function du(fp) {
40 if (fp.isDirectory()) {
41 var files = fp.listFiles();
42 if (!files) return 0;
43 var total = 0;
44 for (var i=0; i<files.length; i++)
45 total += du(files[i]);
46 return total;
47 } else {
48 return fp.length();
49 }
50 }
51 var path = new File(attributes.get("path"));
52 project.setProperty(attributes.get("target"),
53 Math.round(du(path) / 1024) + "");
54 ]]>
55 </scriptdef>
56 37
57 <!-- Define the properties used by the build --> 38 <!-- Define the properties used by the build -->
58 <property name="app.name" value="${ant.project.name}"/> 39 <property name="app.name" value="${ant.project.name}"/>
59 <toLowerCase target="lc.app.name" value="${app.name}"/> 40 <toLowerCase output="lc.app.name" value="${app.name}"/>
60 <property name="app.version" value="1.01"/> 41 <property name="app.version" value="1.02"/>
61 <property name="app.domain" value="name.blackcap.${lc.app.name}"/> 42 <property name="app.domain" value="name.blackcap.${lc.app.name}"/>
62 <property name="app.entry" value="${app.domain}.MainKt"/> 43 <property name="app.entry" value="${app.domain}.MainKt"/>
63 <property name="app.copyright" value="Copyright © 2020, David W. Barts."/> 44 <property name="app.copyright" value="Copyright © 2020–2022, David W. Barts."/>
64 <property name="jar.name" value="${basedir}/${lc.app.name}.jar"/> 45 <property name="jar.name" value="${basedir}/${lc.app.name}.jar"/>
65 <property name="work.jar" value="${basedir}/work.jar"/> 46 <property name="work.jar" value="${basedir}/work.jar"/>
66 <property name="lib.home" value="${basedir}/lib"/> 47 <property name="lib.home" value="${basedir}/lib"/>
67 <property name="src.home" value="${basedir}/src"/> 48 <property name="src.home" value="${basedir}/src"/>
68 <property name="dist.home" value="${basedir}/dist"/> 49 <property name="dist.home" value="${basedir}/dist"/>
72 <!-- define the kotlin task --> 53 <!-- define the kotlin task -->
73 <property name="kotlin.lib" value="${env.KOTLIN_HOME}/lib"/> 54 <property name="kotlin.lib" value="${env.KOTLIN_HOME}/lib"/>
74 <typedef resource="org/jetbrains/kotlin/ant/antlib.xml" 55 <typedef resource="org/jetbrains/kotlin/ant/antlib.xml"
75 classpath="${kotlin.lib}/kotlin-ant.jar"/> 56 classpath="${kotlin.lib}/kotlin-ant.jar"/>
76 57
58 <target name="testIt">
59 <jshellTest message="This is a test." />
60 </target>
61
77 <!-- help message --> 62 <!-- help message -->
78 <target name="help"> 63 <target name="help">
79 <echo>You can use the following targets:</echo> 64 <echo>You can use the following targets:</echo>
65 <echo>lc.app.name is ${lc.app.name}</echo>
80 <echo> </echo> 66 <echo> </echo>
81 <echo> help : (default) Prints this message </echo> 67 <echo> help : (default) Prints this message </echo>
82 <echo> all : Cleans, compiles, and stages application</echo> 68 <echo> all : Cleans, compiles, and stages application</echo>
83 <echo> clean : Deletes work directories</echo> 69 <echo> clean : Deletes work directories</echo>
84 <echo> compile : Compiles servlets into class files</echo> 70 <echo> compile : Compiles servlets into class files</echo>
105 91
106 <!-- remove old cruft --> 92 <!-- remove old cruft -->
107 <target name="clean"> 93 <target name="clean">
108 <delete includeEmptyDirs="true" failonerror="false"> 94 <delete includeEmptyDirs="true" failonerror="false">
109 <fileset dir="${dist.home}" includes="**/*"/> 95 <fileset dir="${dist.home}" includes="**/*"/>
96 <fileset file="${work.jar}"/>
97 <fileset file="${jar.name}"/>
110 </delete> 98 </delete>
111 </target> 99 </target>
112 100
113 <!-- rename files containing OS-dependant code --> 101 <!-- rename files containing OS-dependant code -->
114 <target name="osdep"> 102 <target name="osdep">
125 113
126 <!-- compile *.kt to *.class --> 114 <!-- compile *.kt to *.class -->
127 <target name="compile" depends="mkdirs,osdep,classpath" 115 <target name="compile" depends="mkdirs,osdep,classpath"
128 description="Compile Java sources to ${work.home}"> 116 description="Compile Java sources to ${work.home}">
129 <kotlinc src="${src.home}" output="${work.jar}" 117 <kotlinc src="${src.home}" output="${work.jar}"
118 noStdlib="false" includeRuntime="true"
130 classpathref="compile.classpath"> 119 classpathref="compile.classpath">
131 <compilerarg line="-jvm-target ${jvm.version}"/> 120 <compilerarg line="-jvm-target ${jvm.version}"/>
132 </kotlinc> 121 </kotlinc>
133 </target> 122 </target>
134 123
252 <filterset> 241 <filterset>
253 <filter token="jar.filename" value="${lc.app.name}.jar"/> 242 <filter token="jar.filename" value="${lc.app.name}.jar"/>
254 </filterset> 243 </filterset>
255 </copy> 244 </copy>
256 <chmod file="${dist.home}/data/usr/bin/imageprep" perm="755"/> 245 <chmod file="${dist.home}/data/usr/bin/imageprep" perm="755"/>
257 <du path="${dist.home}/data" target="deb.installed.size"/> 246 <du path="${dist.home}/data" output="deb.installed.size"/>
258 <mkdir dir="${dist.home}/control"/> 247 <mkdir dir="${dist.home}/control"/>
259 <copy todir="${dist.home}/control" encoding="UTF-8" overwrite="true"> 248 <copy todir="${dist.home}/control" encoding="UTF-8" overwrite="true">
260 <fileset file="${pf.home}/linux/deb/control"/> 249 <fileset file="${pf.home}/linux/deb/control"/>
261 <filterset> 250 <filterset>
262 <filter token="app.version" value="${app.version}"/> 251 <filter token="app.version" value="${app.version}"/>