-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
151 lines (120 loc) · 4.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
<?xml version="1.0"?>
<project name="CSC1903" basedir="." default="help">
<property name="src" value="src"/>
<property name="build.dir" value="build"/>
<property name="dist.dir" value="dist"/>
<property name="test.dir" location="build/test"/>
<property name="lib.dir" value="lib"/>
<property name="compiler" value="${lib.dir}/google.closure/compiler.jar"/>
<property name="browser.exe" value="google-chrome"/>
<!-- Define google closure compiler task -->
<taskdef name="jscomp" classname="com.google.javascript.jscomp.ant.CompileTask"
classpath="${compiler}"/>
<!-- Prints the help message-->
<target name="help"
description="Prints this buildfiles help message">
<echo>You can use the following targets:</echo>
<echo></echo>
<echo> help : (default) Prints this message </echo>
<echo></echo>
<echo> all : Cleans, compiles, deploys, and runs the demo application</echo>
<echo> clean : Deletes work directories</echo>
<echo> compile : Compiles sources into the build directory</echo>
<echo> dist : Copy compiled sources and other assets into a deployable folder </echo>
<echo> run : Renders the demo html in browser</echo>
<echo></echo>
<echo> test-deloy : Compiles dependencies, and deploys the test folder with test files</echo>
<echo> test-run : Compiles and runs all tests in browser</echo>
<echo></echo>
<echo>For example, to clean, compile, and package all at once, run:</echo>
<echo>prompt> ant all</echo>
<echo></echo>
<echo>To run all tests included, run:</echo>
<echo>prompt> ant test-run</echo>
</target>
<!-- Cleans, compiles, and packages application -->
<target name="all"
depends="run"
description="Cleans, compiles, and packages application"/>
<!-- Deletes work directories -->
<target name="clean"
description="Deletes work directories">
<delete dir="${build.dir}"/>
<delete dir="${dist.dir}"/>
</target>
<!-- Creates work directories -->
<target name="create"
depends="clean"
description="Creates work directories">
<mkdir dir="${build.dir}"/>
</target>
<!-- Compiles source js with google closure compiler into build directory -->
<target name="compile"
depends="create"
description="Compiles sources into the build directory">
<jscomp compilationLevel="simple" warning="verbose"
debug="false" output="${build.dir}/CSC1903.min.js">
<sources dir="${src}/main/js">
<file name="CSC1903.js"/>
</sources>
</jscomp>
</target>
<!-- Creates the distribution package -->
<target name="dist"
depends="compile"
description="Creates the package ready for distribution">
<mkdir dir="${dist.dir}"/>
<!-- Copy all files into distribution folder -->
<copy todir="${dist.dir}">
<fileset dir="${src}/main">
<!-- do not copy source, copy compiled (minimized) version instead -->
<exclude name="js/CSC1903.js"/>
</fileset>
</copy>
<!-- Copy compiled js to dist folder -->
<copy todir="${dist.dir}/js">
<fileset dir="${build.dir}">
<exclude name="test"/>
</fileset>
</copy>
</target>
<!-- Runs the html in the browser -->
<target name="run"
depends="dist"
description="Runs the html in the browser">
<exec executable="${browser.exe}">
<arg value="${dist.dir}/Jsearch.html"/>
</exec>
</target>
<!-- Cleanup/create folders for test compile -->
<target name="test-init"
description="Create the folders for test compile">
<delete dir="${test.dir}"/>
<mkdir dir="${test.dir}"/>
<mkdir dir="${test.dir}/lib/jasmine-1.2.0"/>
</target>
<!-- Deploy test files into build/test folder -->
<target name="test-deploy"
depends="test-init"
description="Deploys the test folder with test files">
<copy todir="${test.dir}">
<fileset dir="${src}/test" />
</copy>
<copy todir="${test.dir}/lib">
<fileset dir="${src}/main/js">
<include name="jquery-1.6.2.min.js"/>
</fileset>
</copy>
<copy todir="${test.dir}/lib/jasmine-1.2.0">
<fileset dir="${lib.dir}/jasmine-1.2.0" />
</copy>
</target>
<!-- Run the test cases/classes -->
<target name="test-run"
depends="compile, test-deploy"
description="Run tests in the browser">
<exec executable="${browser.exe}">
<arg value="${test.dir}/SpecRunner.html"/>
</exec>
</target>
</project>