forked from harvard-lts/FITSservlet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
161 lines (140 loc) · 7.5 KB
/
build.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<?xml version="1.0" ?>
<project name="FITServlet" default="war">
<!--
Compile classpath depends on external fits.jar from FITS project.
Set value for property "fits.jar.location" accordingly in this properties file.
-->
<property file="build.properties" />
<property environment="env"/> <!-- access to environment properties -->
<!--
Access to FITS classes in fits.jar is necessary for compile resolution.
The environment variable "fits_jar_location" can be set to point to the
location containing fits.jar.
-->
<property name="fits.jar.environment.location" location="${env.fits_jar_location}" />
<!-- ===================== Version properties file =========================== -->
<property name="build.version.file" value="version.properties"/>
<property file="${build.version.file}" />
<!-- ==================== File and Directory Names ======================== -->
<property name="app.name" value="fits" />
<property name="app.longName" value="File Information Toolset Web Service" />
<property name="war.name" value="${app.name}-${build.version}.war" />
<property name="manifest.name" value="MANIFEST.MF" />
<property name="manifest.dir" location="WebContent/META-INF" />
<property name="src.dirs" location="src" />
<property name="test.dirs" location="test" />
<property name="classes.dir" location="WebContent/WEB-INF/classes" />
<property name="dist.dir" location="dist" />
<target name="init" depends="clean">
<!-- Set property if environment path to fits.jar exists -->
<available property="fits.jar.environment.location.exists" file="${fits.jar.environment.location}/fits.jar" />
<!-- Set property if fall-back path to fits.jar exists -->
<available property="fits.jar.fallback.location.exists" file="${fits.jar.fallback.location}/fits.jar" />
<!-- uncomment for property debugging information
<echo>fits.jar.environment.location: ${env.fits_jar_location}</echo>
<echo>fits.jar.fallback.location: ${fits.jar.fallback.location}</echo>
<echo>fits.jar.environment.location: ${fits.jar.environment.location}</echo>
<echo>fits.jar.environment.location.exists: ${fits.jar.environment.location.exists}</echo>
<echo>fits.jar.fallback.location.exists: ${fits.jar.fallback.location.exists}</echo>
-->
<!-- Ensure at least one of two possible locations point to fits.jar for compilation -->
<fail message="fits.jar is missing from 2 possible locations -- cannot build.">
<condition>
<and>
<not>
<isset property="fits.jar.environment.location.exists"/>
</not>
<not>
<isset property="fits.jar.fallback.location.exists"/>
</not>
</and>
</condition>
</fail>
<!-- Set property for fits.jar based on environment property first, then internal fall-back if it doesn't exist. -->
<available property="fits.jar.location" file="${fits.jar.environment.location}/fits.jar" value="${fits.jar.environment.location}/fits.jar" />
<!-- (only set property if previous one doesn't exist) -->
<property name="fits.jar.fallback" value="${basedir}/${fits.jar.fallback.location}/fits.jar" />
<condition property="fits.jar.location" value="${fits.jar.fallback}">
<not>
<isset property="fits.jar.environment.location.exists" />
</not>
</condition>
<echo message="Using fit.jar located here: ${fits.jar.location}" />
<!-- Verify existance of version properties file containing the expected property. -->
<fail message="Cannot find file: ${build.version.file}">
<condition>
<not>
<resourcecount count="1">
<fileset dir="." includes="${build.version.file}" />
</resourcecount>
</not>
</condition>
</fail>
<fail message="Property 'build.version' not found in file ${build.version.file}">
<condition>
<not>
<isset property="build.version" />
</not>
</condition>
</fail>
<mkdir dir="${classes.dir}" />
<mkdir dir="${dist.dir}" />
</target>
<target name="compile" depends="init" description="Compile all source code">
<javac destdir="${classes.dir}" debug="true" srcdir="${src.dirs}:${test.dirs}" includeantruntime="false" source="1.8" target="1.8">
<classpath>
<fileset dir="WebContent/WEB-INF/lib">
<include name="*.jar" />
</fileset>
<!-- need the following to compile test classes -->
<fileset dir="lib">
<include name="*.jar" />
</fileset>
<pathelement location="${fits.jar.location}" />
</classpath>
</javac>
</target>
<target name="war" depends="compile" description="Build the WAR file">
<antcall target="create-manifest" />
<!-- Put logging configuration file into the classes directory -->
<copy file="WebContent/WEB-INF/log4j.properties" todir="${classes.dir}" />
<war destfile="${dist.dir}/${war.name}" webxml="WebContent/WEB-INF/web.xml"
manifest="${manifest.dir}/${manifest.name}">
<fileset dir="WebContent" />
<lib dir="WebContent/WEB-INF/lib" />
</war>
</target>
<!-- Must set environment variable CATALINA_HOME for location to deploy WAR file. -->
<!-- For Eclipse set an environment variable from any task's "Ant build..." -->
<target name="deploy-to-tomcat" description="Deploy the WAR file to Tomcat at (configured) server location.">
<fail unless="env.CATALINA_HOME" message="CATALINA_HOME not set. Cannot deploy ${war.name}."/>
<copy file="${dist.dir}/${war.name}"
todir="${env.CATALINA_HOME}/webapps"></copy>
<echo message="${war.name} deployed to ${env.CATALINA_HOME}/webapps" />
</target>
<target name="undeploy-from-tomcat" description="Undeploy the WAR file from Tomcat at (configured) server location.">
<fail unless="env.CATALINA_HOME" message="CATALINA_HOME not set. Cannot undeploy ${war.name}."/>
<available file="${env.CATALINA_HOME}/webapps/${war.name}" property="war.file.found"/>
<fail unless="war.file.found" message="${env.CATALINA_HOME}/webapps/${war.name} does not exist." />
<delete file="${env.CATALINA_HOME}/webapps/${war.name}" />
</target>
<target name="clean" description="Clean the project">
<delete dir="${dist.dir}" />
<delete dir="${classes.dir}" />
<delete file="${manifest.dir}/${manifest.name}" failonerror="false" />
</target>
<target name="create-manifest">
<tstamp>
<format property="timestamp.isoformat" pattern="yyyy-MM-dd'T'HH:mm:ss" />
</tstamp>
<property name="build.timestamp" value="${timestamp.isoformat}" />
<property name="build.date" value="${TODAY}" />
<manifest file="${manifest.dir}/${manifest.name}">
<attribute name="Application-Name" value="${app.longName}" />
<attribute name="Specification-Version" value="${build.version}" />
<attribute name="Implementation-Vendor" value="OIS Harvard University Library" />
<attribute name="Build-Date" value="${build.date}" />
<attribute name="Build-Timestamp" value="${build.timestamp}" />
</manifest>
</target>
</project>