-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
237 lines (216 loc) · 9.39 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<?xml version="1.0" encoding="utf-8"?>
<project name="sparkour" default="compile" basedir=".">
<!-- Prerequisites:
A Tomcat instance should be installed at output/tomcat (targeting Tomcat 10.1.17).
-->
<!-- Source Properties -->
<property name="sparkour.version" value="1.0.0" />
<property name="conf.dir" value="conf" />
<property name="data.dir" value="data" />
<property name="src.main.dir" value="src/main/java" />
<property name="src.test.dir" value="src/test/java" />
<property name="lib.main.dir" value="lib" />
<property name="lib.test.dir" value="${lib.main.dir}/test" />
<!-- Build Properties -->
<property name="output.dir" value="out" />
<property name="compile.main.dir" value="${output.dir}/production/" />
<property name="compile.test.dir" value="${output.dir}/test/" />
<property name="staging.dir" value="${output.dir}/staging" />
<property name="staging.jars.dir" value="${staging.dir}/jars" />
<property name="staging.test.dir" value="${staging.dir}/test" />
<property name="staging.webapp.dir" value="${staging.dir}/webapp" />
<!-- Deploy Properties -->
<property name="deploy.dir" value="${output.dir}/deploy" />
<property name="deploy.content.dir" value="/workspace/aws-stage/urizone-content/sparkour" />
<property name="deploy.webapp.home" value="out/tomcat" />
<property name="deploy.webapp.dir" value="${deploy.webapp.home}/webapps" />
<!-- Classpaths -->
<path id="classpath.main">
<fileset dir="${lib.main.dir}/jakarta" includes="*.jar" />
<fileset dir="${lib.main.dir}/logback" includes="*.jar" />
<fileset dir="${lib.main.dir}/spring" includes="*.jar" />
<fileset dir="${lib.main.dir}/tomcat" includes="*.jar" />
</path>
<path id="classpath.test">
<path refid="classpath.main" />
<pathelement location="${compile.main.dir}" />
<pathelement location="${compile.test.dir}" />
<fileset dir="${lib.test.dir}" includes="*.jar" />
</path>
<!-- Property Filesets -->
<!-- These files need to be present in the classpath to run unit tests -->
<fileset dir="${conf.dir}/webapp" id="files.test.properties">
<include name="sparkour-context.xml" />
<include name="logback.xml" />
<include name="sparkour-servlet.xml" />
</fileset>
<!-- These files end up in the WEB-INF/classes directory of the webapp -->
<fileset dir="${conf.dir}/webapp" id="files.webapp.classes.properties">
<include name="sparkour-context.xml" />
<include name="logback.xml" />
</fileset>
<!-- These files end up in the WEB-INF directory of the webapp -->
<fileset dir="${conf.dir}/webapp" id="files.webapp.properties">
<include name="sparkour-servlet.xml" />
<include name="sparkour.tld" />
<include name="web.xml" />
</fileset>
<!-- Data Filesets -->
<!-- These files are pushed to Amazon S3 for the live site -->
<fileset dir="${data.dir}/content" id="files.content">
<include name="**/**" />
</fileset>
<!-- These files are used by AWS CodeDeploy to deploy the live site -->
<fileset dir="${data.dir}/deploy" id="files.deploy">
<include name="*" />
</fileset>
<!-- These files are the zipped up examples -->
<fileset dir="${data.dir}/examples/zip" id="files.examples">
<include name="*" />
</fileset>
<!-- These files are bundled in the webapp WAR file -->
<fileset dir="${data.dir}/webapp" id="files.webapp">
<include name="**/**" />
</fileset>
<!-- Definitions -->
<presetdef name="compile">
<javac includeantruntime="false" debug="true" deprecation="false" optimize="true" />
</presetdef>
<presetdef name="deleteQuiet">
<delete includeemptydirs="true" failonerror="false" quiet="true" />
</presetdef>
<macrodef name="buildWar" description="Creates a WAR file from a staged exploded WAR directory">
<attribute name="distDir" />
<attribute name="stagingDir" />
<attribute name="warName" />
<sequential>
<war destfile="${staging.dist.dir}/@{distDir}-${sparkour.version}/@{warName}.war"
webxml="${staging.dir}/@{stagingDir}/WEB-INF/web.xml">
<classes dir="${staging.dir}/@{stagingDir}/WEB-INF/classes" />
<lib dir="${staging.dir}/@{stagingDir}/WEB-INF/lib" />
<fileset dir="${staging.dir}/@{stagingDir}">
<exclude name="WEB-INF/classes/**" />
<exclude name="WEB-INF/lib/**" />
</fileset>
</war>
</sequential>
</macrodef>
<!-- Public Targets -->
<target name="clean" description="Deletes the temporary build directories">
<deleteQuiet dir="${compile.main.dir}" />
<deleteQuiet dir="${compile.test.dir}" />
<deleteQuiet dir="${staging.dir}" />
<deleteQuiet dir="${deploy.dir}" />
<deleteQuiet dir="${deploy.webapp.dir}/ROOT" />
</target>
<target name="compile" description="Compiles, copies properties, and stages exploded WAR file">
<filter filtersfile="${conf.dir}/sparkour.tokens"/>
<mkdir dir="${compile.main.dir}" />
<mkdir dir="${compile.test.dir}" />
<!-- Compile main and test classes (in separate output directories) -->
<compile srcdir="${src.main.dir}" destdir="${compile.main.dir}" classpathref="classpath.main" />
<compile srcdir="${src.test.dir}" destdir="${compile.test.dir}" classpathref="classpath.test" />
<!-- Copy properties for Eclipse operations -->
<copy todir="${compile.test.dir}" filtering="true" flatten="true">
<fileset refid="files.test.properties" />
</copy>
<!-- Build the JAR file -->
<jar destfile="${staging.jars.dir}/sparkour-${sparkour.version}.jar">
<fileset dir="${compile.main.dir}">
<include name="**/*.class" />
</fileset>
<manifest>
<attribute name="Specification-Title" value="sparkour"/>
<attribute name="Specification-Version" value="${sparkour.version}"/>
<attribute name="Specification-Vendor" value="Brian Uri!"/>
<attribute name="Implementation-Title" value="sparkour"/>
<attribute name="Implementation-Version" value="${sparkour.version}"/>
<attribute name="Implementation-Vendor" value="Brian Uri!"/>
</manifest>
</jar>
<!-- Stage the webapp as exploded WAR file -->
<copy todir="${staging.webapp.dir}">
<fileset refid="files.webapp" />
</copy>
<copy todir="${staging.webapp.dir}/WEB-INF/" filtering="true">
<fileset refid="files.webapp.properties" />
</copy>
<copy todir="${staging.webapp.dir}/WEB-INF/classes" filtering="true">
<fileset refid="files.webapp.classes.properties" />
</copy>
<copy todir="${staging.webapp.dir}/WEB-INF/lib">
<fileset dir="${staging.jars.dir}" includes="sparkour-${sparkour.version}.jar" />
<fileset dir="${lib.main.dir}/jakarta" includes="*.jar" />
<fileset dir="${lib.main.dir}/logback" includes="*.jar" />
<fileset dir="${lib.main.dir}/spring" includes="*.jar" />
</copy>
<!-- Stage the static content -->
<copy todir="${deploy.content.dir}">
<fileset refid="files.content" />
</copy>
<!-- Copy examples ZIPs to /files/ -->
<copy todir="${deploy.content.dir}/files">
<fileset refid="files.examples" />
</copy>
</target>
<target name="tests" depends="clean, compile" description="Runs unit tests">
<mkdir dir="${staging.test.dir}" />
<junit printsummary="false" haltonfailure="true" fork="true" forkmode="perBatch">
<classpath refid="classpath.test" />
<formatter type="brief" usefile="false" />
<formatter type="xml" />
<batchtest todir="${staging.test.dir}">
<fileset dir="${compile.test.dir}" includes="**/*Test.class" />
</batchtest>
</junit>
</target>
<target name="deploy" depends="compile" description="Deploys the webapp for testing">
<!-- Create CodeDeploy WAR bundle for live deploy -->
<war destfile="${deploy.dir}/ROOT.war" webxml="${staging.webapp.dir}/WEB-INF/web.xml">
<lib dir="${staging.webapp.dir}/WEB-INF/lib"/>
<fileset dir="${staging.webapp.dir}">
<exclude name="WEB-INF/lib/**"/>
</fileset>
</war>
<copy todir="${deploy.dir}">
<fileset refid="files.deploy" />
</copy>
<!-- Deploy to local Tomcat for testing -->
<delete quiet="true" dir="${deploy.webapp.dir}/ROOT" />
<mkdir dir="${deploy.webapp.dir}/ROOT" />
<copy todir="${deploy.webapp.dir}/ROOT">
<fileset dir="${staging.webapp.dir}" />
<fileset refid="files.content" />
</copy>
<!-- Copy examples ZIPs to /files/ -->
<copy todir="${deploy.webapp.dir}/ROOT/files">
<fileset refid="files.examples" />
</copy>
<delete quiet="true" dir="${staging.dir}/webapp" />
</target>
<target name="reloadViews" description="Copies only the view files, without restarting the web application">
<copy todir="${deploy.webapp.dir}/ROOT" preservelastmodified="true" includeemptydirs="false">
<fileset refid="files.webapp" />
<fileset refid="files.content" />
</copy>
</target>
<target name="startWebapp" description="Starts the webapp testing server">
<exec dir="${deploy.webapp.home}/bin" executable="cmd">
<arg value="/c"/>
<arg value="startup.bat"/>
</exec>
</target>
<target name="stopWebapp" description="Stops the webapp testing server">
<exec dir="${deploy.webapp.home}/bin" executable="cmd">
<arg value="/c"/>
<arg value="shutdown.bat"/>
</exec>
</target>
<target name="zBackupZip" description="Creates a backup ZIP of the entire project">
<tstamp>
<format property="backupStamp" pattern="yyMMdd-HHmm"/>
</tstamp>
<zip destfile="../${backupStamp}-sparkour-${sparkour.version}.zip" basedir=".."
includes="sparkour/**" excludes="sparkour/out/**" />
</target>
</project>