0
|
1 <?xml version="1.0" encoding="UTF-8"?>
|
|
2 <project name="ImagePrep" default="help" basedir=".">
|
|
3 <!-- import all environment variables as env.* -->
|
|
4 <property environment="env"/>
|
|
5
|
|
6 <!-- ensure required environment variables are set -->
|
|
7 <macrodef name="env-require">
|
|
8 <attribute name="name"/>
|
|
9 <sequential>
|
|
10 <fail message="Environment variable @{name} not set!">
|
|
11 <condition>
|
|
12 <not><isset property="env.@{name}"/></not>
|
|
13 </condition>
|
|
14 </fail>
|
|
15 </sequential>
|
|
16 </macrodef>
|
|
17 <env-require name="JRE_HOME"/>
|
|
18 <env-require name="KOTLIN_HOME"/>
|
|
19 <env-require name="OSDEP_HOME"/>
|
|
20
|
|
21 <!-- cribbed from https://stackoverflow.com/questions/7129672/uppercase-lowercase-capitalize-an-ant-property -->
|
|
22 <scriptdef language="javascript" name="toLowerCase">
|
|
23 <attribute name="value" />
|
|
24 <attribute name="target" />
|
|
25 <![CDATA[
|
|
26 "use strict";
|
|
27 project.setProperty( attributes.get( "target" ),
|
|
28 attributes.get( "value" ).toLowerCase() );
|
|
29 ]]>
|
|
30 </scriptdef>
|
|
31
|
|
32 <!-- Define the properties used by the build -->
|
|
33 <property name="app.name" value="${ant.project.name}"/>
|
2
|
34 <toLowerCase target="lc.app.name" value="${app.name}"/>
|
0
|
35 <property name="app.version" value="1.00"/>
|
2
|
36 <property name="app.domain" value="name.blackcap.${lc.app.name}"/>
|
0
|
37 <property name="app.entry" value="${app.domain}.MainKt"/>
|
|
38 <property name="app.copyright" value="Copyright © 2020, David W. Barts."/>
|
|
39 <property name="jar.name" value="${basedir}/${lc.app.name}.jar"/>
|
|
40 <property name="work.jar" value="${basedir}/work.jar"/>
|
|
41 <property name="lib.home" value="${basedir}/lib"/>
|
|
42 <property name="src.home" value="${basedir}/src"/>
|
|
43 <property name="dist.home" value="${basedir}/dist"/>
|
|
44 <property name="jvm.version" value="1.8"/>
|
|
45
|
|
46 <!-- define the kotlin task -->
|
|
47 <property name="kotlin.lib" value="${env.KOTLIN_HOME}/lib"/>
|
|
48 <typedef resource="org/jetbrains/kotlin/ant/antlib.xml"
|
|
49 classpath="${kotlin.lib}/kotlin-ant.jar"/>
|
|
50
|
|
51 <!-- help message -->
|
|
52 <target name="help">
|
|
53 <echo>You can use the following targets:</echo>
|
|
54 <echo> </echo>
|
|
55 <echo> help : (default) Prints this message </echo>
|
|
56 <echo> all : Cleans, compiles, and stages application</echo>
|
|
57 <echo> clean : Deletes work directories</echo>
|
|
58 <echo> compile : Compiles servlets into class files</echo>
|
|
59 <echo> jar : Make JAR file.</echo>
|
|
60 <echo> </echo>
|
|
61 <echo>For example, to clean, compile, and package all at once, run:</echo>
|
|
62 <echo>prompt> ant all </echo>
|
|
63 </target>
|
|
64
|
|
65 <!-- Define the CLASSPATH -->
|
|
66 <target name="classpath">
|
|
67 <path id="compile.classpath">
|
|
68 <pathelement location="${src.home}"/>
|
|
69 </path>
|
|
70 </target>
|
|
71
|
|
72 <!-- make needed directories -->
|
|
73 <target name="mkdirs">
|
|
74 <mkdir dir="${dist.home}"/>
|
|
75 </target>
|
|
76
|
|
77 <!-- remove old cruft -->
|
|
78 <target name="clean">
|
|
79 <delete includeEmptyDirs="true" failonerror="false">
|
|
80 <fileset dir="${dist.home}" includes="**/*"/>
|
|
81 </delete>
|
|
82 </target>
|
|
83
|
|
84 <!-- rename files containing OS-dependant code -->
|
|
85 <target name="osdep">
|
|
86 <exec executable="${env.JRE_HOME}/bin/java" failonerror="true">
|
|
87 <arg value="-jar"/>
|
|
88 <arg file="${env.OSDEP_HOME}/osdep.jar"/>
|
|
89 <arg value="${src.home}"/>
|
|
90 </exec>
|
|
91 </target>
|
|
92
|
|
93 <!-- do everything but install -->
|
|
94 <target name="all" depends="jar"
|
|
95 description="Clean work dirs, compile, make JAR."/>
|
|
96
|
|
97 <!-- compile *.kt to *.class -->
|
|
98 <target name="compile" depends="mkdirs,osdep,classpath"
|
|
99 description="Compile Java sources to ${work.home}">
|
|
100 <kotlinc src="${src.home}" output="${work.jar}"
|
|
101 classpathref="compile.classpath">
|
|
102 <compilerarg line="-jvm-target ${jvm.version}"/>
|
|
103 </kotlinc>
|
|
104 </target>
|
|
105
|
|
106 <!-- make .jar file -->
|
|
107 <target name="jar" depends="compile" description="Create JAR file.">
|
|
108 <jar destfile="${jar.name}">
|
|
109 <manifest>
|
|
110 <attribute name="Main-Class" value="${app.entry}"/>
|
|
111 </manifest>
|
|
112 <!-- <zipgroupfileset dir="${lib.home}" includes="*.jar"/> -->
|
|
113 <zipfileset src="${work.jar}"/>
|
2
|
114 <zipfileset dir="${src.home}" includes="**/*.properties,**/*.html"/>
|
0
|
115 </jar>
|
|
116 </target>
|
|
117
|
|
118 </project>
|