-
Notifications
You must be signed in to change notification settings - Fork 70
/
build.xml
219 lines (184 loc) · 7.54 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
<project name="mViewer" default="dist" xmlns:ac="antlib:net.sf.antcontrib" xmlns:jsl="antlib:com.googlecode.jslint4java" xmlns:ivy="antlib:org.apache.ivy.ant">
<property name="app.name" value="mViewer" />
<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/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="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="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" />
<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}/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}/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="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.">
<java jar="${src.dir}/tools/winstone-0.9.10.jar" fork="true">
<arg value="--httpPort=8080"/>
<arg value="--ajp13Port=-1" />
<arg value="--warfile=${staging.dir}/${app.war}" />
</java>
</target>
</project>