forked from rachit-mtl/mViewer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.xml
269 lines (226 loc) · 9.78 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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
<project name="mViewer" default="dist" xmlns:jsl="antlib:com.googlecode.jslint4java">
<property name="app.name" value="mViewer" />
<property name="app.version" value="0.9.2" />
<property name="app.war" value="${app.name}.war" />
<property name="app.jar" value="${app.name}.jar" />
<property name="src.dir" value="${basedir}/src" />
<property name="java.src.dir" value="${src.dir}/main/java" />
<property name="js.src.dir" value="${src.dir}/main/webapp/js" />
<property name="src.resources.dir" value="${src.dir}/resources" />
<property name="main.resources.dir" value="${src.dir}/main/resources" />
<property name="lib.dir" value="${src.resources.dir}" />
<property name="scripts.dir" value="${basedir}/scripts" />
<property name="staging.dir" value="${basedir}/staging" />
<property name="docs.dir" value="${staging.dir}/docs" />
<property name="java.docs.dir" value="${docs.dir}/java" />
<property name="js.docs.dir" value="${docs.dir}/js" />
<property name="release.dir" value="${basedir}/release" />
<property name="release.app.dir" value="${release.dir}/mViewer" />
<property name="classes.dir" value="${staging.dir}/classes" />
<property name="app.dir" value="${staging.dir}/${app.name}" />
<!-- Test Properties -->
<property name="test.dir" value="${src.dir}/test" />
<property name="java.test.dir" value="${src.dir}/test/java" />
<property name="test.reports.dir" value="${staging.dir}/testreports" />
<property name="test.classes.dir" value="${staging.dir}/testclasses" />
<property file="${basedir}/mViewer.properties" />
<taskdef uri="antlib:net.sf.antcontrib" resource="net/sf/antcontrib/antlib.xml" classpath=" ${src.dir}/tools/ant-contrib.jar" />
<taskdef uri="antlib:com.googlecode.jslint4java" resource="com/googlecode/jslint4java/antlib.xml" classpath="${src.dir}/tools/jslint4java.jar" />
<taskdef name="jsdoctoolkit" classname="uk.co.darrenhurley.ant.tasks.JsDocToolkit" classpath="${src.dir}/tools/jsdoc-toolkit-ant-task-1.1.2.jar;${src.dir}/tools/jsdoc-toolkit/jsrun.jar" />
<target name="init">
<mkdir dir="${staging.dir}" />
<mkdir dir="${app.dir}" />
<mkdir dir="${test.reports.dir}" />
<mkdir dir="${test.classes.dir}" />
<path id="compile.class.path">
<fileset dir="${main.resources.dir}">
<include name="**/log4j.properties" />
</fileset>
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
</path>
</target>
<target name="test-init">
<!-- Class path of .jar and .class required during test files compiling -->
<path id="test.class.path">
<path refid="compile.class.path" />
<fileset dir="${main.resources.dir}">
<include name="**/log4j.properties" />
</fileset>
<fileset dir="${classes.dir}">
<include name="**/**" />
</fileset>
<pathelement path="${test.classes.dir}" />
<pathelement path="${classes.dir}" />
</path>
</target>
<!-- compile -->
<target name="compile" depends="init">
<mkdir dir="${classes.dir}" />
<javac srcdir="${java.src.dir}" destdir="${classes.dir}" classpathref="compile.class.path" nowarn="yes" debug="yes" includeantruntime="false">
<!-- <compiler arg value="-Xlint:unchecked"/> -->
</javac>
</target>
<!-- compile test-->
<target name="compile-test" depends="test-init, compile">
<javac srcdir="${test.dir}" destdir="${test.classes.dir}" classpathref="test.class.path" nowarn="yes" debug="yes" includeantruntime="false">
</javac>
</target>
<!-- jar -->
<target name="jar">
<jar jarfile="${staging.dir}/${app.jar}">
<fileset dir="${classes.dir}">
<include name="**/*.class" />
</fileset>
</jar>
</target>
<!-- war staging -->
<target name="war-staging">
<echo>${app.dir}</echo>
<copy toDir="${app.dir}">
<fileset dir="${src.dir}/main/webapp">
<exclude name="web.xml" />
</fileset>
<fileset dir="${src.dir}/test/js">
</fileset>
</copy>
<mkdir dir="${app.dir}/js" />
<copy toDir="${app.dir}/js">
<fileset dir="${js.src.dir}">
</fileset>
</copy>
<mkdir dir="${app.dir}/WEB-INF" />
<mkdir dir="${app.dir}/WEB-INF/lib" />
<copy toDir="${app.dir}/WEB-INF/lib">
<fileset dir="${lib.dir}">
<exclude name="**/*spec*.jar" />
</fileset>
<fileset dir="${staging.dir}">
<include name="*.jar" />
</fileset>
</copy>
<copy toDir="${app.dir}/WEB-INF">
<fileset dir="${src.dir}/main/webapp">
<include name="web.xml" />
</fileset>
</copy>
<!-- copy log4j properties file -->
<!-- classes folder for properties file. mViewer.jar contains the src classes-->
<mkdir dir="${app.dir}/WEB-INF/classes" />
<copy todir="${app.dir}/WEB-INF/classes">
<fileset dir="${main.resources.dir}">
<include name="log4j.properties" />
</fileset>
</copy>
</target>
<!-- make war -->
<target name="war" depends="war-staging">
<war warfile="${staging.dir}/${app.war}" needxmlfile="false">
<fileset dir="${app.dir}">
</fileset>
</war>
</target>
<!-- docs -->
<target name="doc" depends="init, doc-init,jdoc, jsdoc" />
<target name="doc-init">
<mkdir dir="${staging.dir}" />
<mkdir dir="${docs.dir}" />
<mkdir dir="${java.docs.dir}" />
<mkdir dir="${js.docs.dir}" />
</target>
<target name="jdoc" depends="compile">
<javadoc access="public" author="false" doctitle="Imagine mViewer" destdir="${java.docs.dir}" nodeprecated="false" nodeprecatedlist="false" noindex="false" nonavbar="false" notree="false" overview="${java.src.dir}/overview.html" excludepackagenames="*" sourcepath="${java.src.dir}" splitindex="true" use="true" version="false">
<fileset dir="${java.src.dir}">
<include name="**/*.java" />
</fileset>
<classpath>
<path refid="compile.class.path" />
</classpath>
</javadoc>
<echo> Java Docs generated at ${java.docs.dir} </echo>
</target>
<target name="jsdoc">
<jsdoctoolkit jsdochome="${src.dir}/tools/jsdoc-toolkit/" includeundocumented="true" template="jsdoc" outputdir="${js.docs.dir}" inputdir="${js.src.dir}" />
<echo> JS Docs generated at ${js.docs.dir} </echo>
</target>
<!-- Run test-->
<target name="test" depends="jslint,integration-test" />
<target name="integration-test" depends="jtest" />
<target name="jtest" depends="compile-test">
<echo> Please Check if Mongo is Running at configurations given in your file src/test/ressources/mongo.config for test cases to pass </echo>
<junit printsummary="yes" haltonfailure="yes">
<classpath refid="test.class.path" />
<formatter type="plain" />
<batchtest todir="${test.reports.dir}">
<fileset dir="${java.test.dir}">
<include name="**/*Test.java" />
</fileset>
</batchtest>
</junit>
</target>
<target name="jslint">
<jsl:jslint haltOnFailure="true" options="es5,evil,fragment,forin,continue">
<formatter type="plain" />
<fileset dir="${js.src.dir}" includes="*.js">
<exclude name="**/*-min.js" />
<exclude name="**/jQuery*.js" />
</fileset>
</jsl:jslint>
</target>
<target name="dist" description="Prepares a dist, is not incremental" depends="clean, compile, jar,jdoc,war,dev">
<echo> Deploy the war ${staging.dir}/${app.war} to your app-server. For detailed instructions please use the README</echo>
</target>
<target name="release" description="Prepares a deployable release." depends="clean, compile, jar,jdoc,war,dev">
<echo> Deploy the war ${staging.dir}/${app.war} to your app-server. For detailed instructions please use the README</echo>
<mkdir dir="${release.dir}" />
<mkdir dir="${release.app.dir}" />
<copy file="${staging.dir}/${app.war}" toDir="${release.app.dir}"/>
<copy file="${src.dir}/tools/winstone-0.9.10.jar" toDir="${release.app.dir}" />
<copy file="${basedir}/mViewer.properties" toDir="${release.app.dir}" />
<copy toDir="${release.app.dir}">
<fileset dir="${scripts.dir}" />
</copy>
<chmod file="${release.app.dir}/start_mViewer.sh" perm="ugo+rx"/>
<zip destfile="${release.dir}/mViewer-v${app.version}.zip"
basedir="${release.app.dir}"
/>
<tar destfile="${release.dir}/mViewer-v${app.version}.tar"
basedir="${release.app.dir}"
/>
<gzip destfile="${release.dir}/mViewer-v${app.version}.tar.gz"
src="${release.dir}/mViewer-v${app.version}.tar"/>
<delete file="${release.dir}/mViewer-v${app.version}.tar"/>
<delete dir="${release.app.dir}" />
</target>
<target name="dev" description="prepares a dev build, is incremental" depends="compile, jar, war-staging">
<echo>Building the war in dev-mode</echo>
</target>
<target name="clean" description="Cleans up all the staging resources and log files">
<delete dir="${staging.dir}" />
<delete dir="${test.reports.dir}" />
<delete file="${basedir}/mViewer.log" />
</target>
<target name="start" depends="compile, jar, war-staging, war" description="Starts the winstone server with the war deployed.">
<echo>----------------------------------------------------------</echo>
<echo>On server start goto localhost:${WINSTONE_PORT}/index.html</echo>
<echo>----------------------------------------------------------</echo>
<java jar="${src.dir}/tools/winstone-0.9.10.jar" fork="true">
<arg value="--httpPort=${WINSTONE_PORT}"/>
<arg value="--ajp13Port=-1" />
<arg value="--warfile=${staging.dir}/${app.war}" />
</java>
</target>
<target name="debug" depends="compile, jar, war-staging, war" description="Starts the winstone server with the war deployed.">
<echo>----------------------------------------------------------</echo>
<echo>On server start goto localhost:${WINSTONE_PORT}/index.html</echo>
<echo>----------------------------------------------------------</echo>
<java jar="${src.dir}/tools/winstone-0.9.10.jar" fork="true">
<jvmarg value="-Xdebug" />
<jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005" />
<arg value="--httpPort=${WINSTONE_PORT}"/>
<arg value="--ajp13Port=-1" />
<arg value="--warfile=${staging.dir}/${app.war}" />
</java>
</target>
</project>