Mercurial > cgi-bin > hgweb.cgi > ImagePrep
annotate build.xml @ 19:5fa5d15b4a7b
Attempt to make it a std. app. Builds, sorta runs, needs more work.
author | David Barts <n5jrn@me.com> |
---|---|
date | Fri, 20 Nov 2020 21:38:06 -0800 |
parents | 5234e4500d45 |
children | 92afaa27f40a |
rev | line source |
---|---|
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}"/> | |
4
5234e4500d45
Command-line arguments (only partially tested).
David Barts <n5jrn@me.com>
parents:
2
diff
changeset
|
69 <fileset dir="${lib.home}"> |
5234e4500d45
Command-line arguments (only partially tested).
David Barts <n5jrn@me.com>
parents:
2
diff
changeset
|
70 <include name="*.jar"/> |
5234e4500d45
Command-line arguments (only partially tested).
David Barts <n5jrn@me.com>
parents:
2
diff
changeset
|
71 </fileset> |
0 | 72 </path> |
73 </target> | |
74 | |
75 <!-- make needed directories --> | |
76 <target name="mkdirs"> | |
77 <mkdir dir="${dist.home}"/> | |
78 </target> | |
79 | |
80 <!-- remove old cruft --> | |
81 <target name="clean"> | |
82 <delete includeEmptyDirs="true" failonerror="false"> | |
83 <fileset dir="${dist.home}" includes="**/*"/> | |
84 </delete> | |
85 </target> | |
86 | |
87 <!-- rename files containing OS-dependant code --> | |
88 <target name="osdep"> | |
89 <exec executable="${env.JRE_HOME}/bin/java" failonerror="true"> | |
90 <arg value="-jar"/> | |
91 <arg file="${env.OSDEP_HOME}/osdep.jar"/> | |
92 <arg value="${src.home}"/> | |
93 </exec> | |
94 </target> | |
95 | |
96 <!-- do everything but install --> | |
97 <target name="all" depends="jar" | |
98 description="Clean work dirs, compile, make JAR."/> | |
99 | |
100 <!-- compile *.kt to *.class --> | |
101 <target name="compile" depends="mkdirs,osdep,classpath" | |
102 description="Compile Java sources to ${work.home}"> | |
103 <kotlinc src="${src.home}" output="${work.jar}" | |
104 classpathref="compile.classpath"> | |
105 <compilerarg line="-jvm-target ${jvm.version}"/> | |
106 </kotlinc> | |
107 </target> | |
108 | |
109 <!-- make .jar file --> | |
110 <target name="jar" depends="compile" description="Create JAR file."> | |
111 <jar destfile="${jar.name}"> | |
112 <manifest> | |
113 <attribute name="Main-Class" value="${app.entry}"/> | |
114 </manifest> | |
115 <!-- <zipgroupfileset dir="${lib.home}" includes="*.jar"/> --> | |
4
5234e4500d45
Command-line arguments (only partially tested).
David Barts <n5jrn@me.com>
parents:
2
diff
changeset
|
116 <zipgroupfileset dir="${lib.home}" includes="*.jar"/> |
0 | 117 <zipfileset src="${work.jar}"/> |
2 | 118 <zipfileset dir="${src.home}" includes="**/*.properties,**/*.html"/> |
0 | 119 </jar> |
120 </target> | |
121 | |
122 </project> |