comparison build.xml @ 0:e0efe7848130

Initial commit. Untested!
author David Barts <davidb@stashtea.com>
date Thu, 16 Jul 2020 19:57:23 -0700
parents
children a6f9b51d5e8d
comparison
equal deleted inserted replaced
-1:000000000000 0:e0efe7848130
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}"/>
34 <property name="app.version" value="1.00"/>
35 <property name="app.domain" value="name.blackcap.exifwasher"/>
36 <property name="app.entry" value="${app.domain}.MainKt"/>
37 <property name="app.copyright" value="Copyright © 2020, David W. Barts."/>
38 <toLowerCase target="lc.app.name" value="${app.name}"/>
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="pf.home" value="${basedir}/package-files"/>
45 <property name="nat.dir" value="${src.home}/name/blackcap/exifwasher/exiv2"/>
46 <property name="bin.dir" value="${src.home}/name/blackcap/exifwasher/binaries"/>
47 <property name="jvm.version" value="1.8"/>
48
49 <!-- define the kotlin task -->
50 <property name="kotlin.lib" value="${env.KOTLIN_HOME}/lib"/>
51 <typedef resource="org/jetbrains/kotlin/ant/antlib.xml"
52 classpath="${kotlin.lib}/kotlin-ant.jar"/>
53
54 <!-- help message -->
55 <target name="help">
56 <echo>You can use the following targets:</echo>
57 <echo> </echo>
58 <echo> help : (default) Prints this message </echo>
59 <echo> all : Cleans, compiles, and stages application</echo>
60 <echo> clean : Deletes work directories</echo>
61 <echo> compile : Compiles servlets into class files</echo>
62 <echo> jar : Make JAR file.</echo>
63 <echo> </echo>
64 <echo>For example, to clean, compile, and package all at once, run:</echo>
65 <echo>prompt> ant all </echo>
66 </target>
67
68 <!-- Define the CLASSPATH -->
69 <target name="classpath">
70 <path id="compile.classpath">
71 <pathelement location="${src.home}"/>
72 </path>
73 </target>
74
75 <!-- make needed directories -->
76 <target name="mkdirs">
77 <mkdir dir="${bin.dir}/${os.type}"/>
78 <mkdir dir="${dist.home}"/>
79 </target>
80
81 <!-- remove old cruft -->
82 <target name="clean">
83 <delete includeEmptyDirs="true" failonerror="false">
84 <fileset dir="${dist.home}" includes="**/*"/>
85 <fileset dir="${bin.dir}"/>
86 </delete>
87 </target>
88
89 <!-- rename files containing OS-dependant code -->
90 <target name="osdep">
91 <exec executable="${env.JRE_HOME}/bin/java" failonerror="true">
92 <arg value="-jar"/>
93 <arg file="${env.OSDEP_HOME}/osdep.jar"/>
94 <arg value="${src.home}"/>
95 </exec>
96 </target>
97
98 <!-- do everything but install -->
99 <target name="all" depends="jar"
100 description="Clean work dirs, compile, make JAR."/>
101
102 <!-- compile *.kt to *.class -->
103 <target name="compile" depends="mkdirs,osdep,classpath"
104 description="Compile Java sources to ${work.home}">
105 <kotlinc src="${src.home}" output="${work.jar}"
106 classpathref="compile.classpath">
107 <compilerarg line="-jvm-target ${jvm.version}"/>
108 </kotlinc>
109 </target>
110
111 <!-- make .jar file -->
112 <target name="jar" depends="compile" description="Create JAR file.">
113 <jar destfile="${jar.name}">
114 <manifest>
115 <attribute name="Main-Class" value="${app.entry}"/>
116 </manifest>
117 <!-- <zipgroupfileset dir="${lib.home}" includes="*.jar"/> -->
118 <zipfileset src="${work.jar}"/>
119 <zipfileset dir="${src.home}" includes="**/*.properties,**/*.html,**/*.dll,**/*.so,**/*.dylib"/>
120 <zipfileset file="${pf.home}/linux/icon_48x48.png"
121 fullpath="name/blackcap/exifwasher/icon_48x48.png"/>
122 </jar>
123 </target>
124
125 </project>