forked from oaeproject/3akai-ux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
286 lines (230 loc) · 11.9 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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
<?xml version="1.0"?>
<project name="Sakai 3 UX" default="finish" basedir=".">
<description>Sakai 3 UX Build Script</description>
<!-- Target: Init -->
<target name="init">
<echo message="Sakai 3 UX Build: Initialising..." />
<!-- SETUP - Source and target paths -->
<property name="SRC_DIR" value="dev" description="Core source folder" />
<property name="INSTRUMENTED_DIR" value="${SRC_DIR}-i" description="Instrumented source folder" />
<property name="TARGET" value="target" description="Core target folder" />
<property name="TARGET_RESOURCES" value="${TARGET}/processed-resources" description="Top directory for JARs, archives" />
<property name="TARGET_DIR" value="${TARGET_RESOURCES}/dev" description="Core target folder" />
<property name="TARGET_COMPRESSED_DIR" value="${TARGET}/compressed" description="Core compressed folder" />
<property name="TARGET_DOCUMENTATION_DIR" value="${TARGET}/doc" description="Core documentation folder" />
<property name="TARGET_REPORTS_DIR" value="${TARGET}/reports" description="Core reports folder" />
<property name="SRC_DIR_W" value="devwidgets" description="Source folder for widgets" />
<property name="TARGET_DIR_W" value="${TARGET_RESOURCES}/devwidgets" description="Target folder for widgets" />
<property name="SRC_DIR_VAR" value="var" description="Source folder for content under /var that needs to be stored in JCR" />
<property name="TARGET_DIR_VAR" value="${TARGET_RESOURCES}/var" description="Target folder for content under /var that needs to be stored in JCR" />
<property name="SRC_DIR_APPS" value="apps" description="Source folder for content under /apps that needs to be stored in JCR" />
<property name="TARGET_DIR_APPS" value="${TARGET_RESOURCES}/apps" description="Target folder for content under /apps that needs to be stored in JCR" />
<property name="SRC_DIR_ROOT" value="root" description="Source folder for content under / that needs to be stored in JCR" />
<property name="TARGET_DIR_ROOT" value="${TARGET_RESOURCES}/root" description="Target folder for content under / that needs to be stored in JCR" />
<!-- SETUP - Processed output file names -->
<property name="TARGET_JAR_FILE" value="${TARGET_COMPRESSED_DIR}/sakai3-ux.jar" description="Target JAR file" />
<property name="TARGET_ZIP_FILE" value="${TARGET_COMPRESSED_DIR}/sakai3-ux.zip" description="Target ZIP file" />
<property name="TARGET_TAR_FILE" value="${TARGET_COMPRESSED_DIR}/sakai3-ux.tar.gz" description="Target TAR file" />
<!-- SETUP - Tools -->
<property name="YUI_COMPRESSOR" value="tools/yuicompressor/yuicompressor-2.4.2.jar" description="YUI Compressor 2.4.2" />
<property name="JSLINT" value="tools/jslint/jslint4java-1.3.3.jar" description="JSLint (jslint4java - 1.3.3)" />
<property name="JSDOCTOOLKIT_DIR" value="tools/jsdoc-toolkit" description="JSDoc-Toolkit" />
<!-- Define a patternset for core JS files (from ${TARGET_DIR}) -->
<patternset id="js.corefiles">
<include name="_javascript/**/*.js"/>
<include name="_configuration/**/*.js"/>
<include name="_lib/sakai_util/**/*.js"/>
</patternset>
<!-- Define patternset for widget JS files (from ${TARGET_DIR_W}) -->
<patternset id="js.widgetfiles">
<include name="**/javascript/*.js"/>
<exclude name="**/javascript/*.min.*"/>
</patternset>
<!-- Define patternset for core CSS files (from ${TARGET_DIR}) -->
<patternset id="css.corefiles">
<include name="_css/sakai/**/*.css"/>
<include name="_skins/**/*.css"/>
</patternset>
<!-- Define patternset for widget CSS files (from ${TARGET_DIR_W}) -->
<patternset id="css.widgetfiles">
<include name="**/css/*.css"/>
</patternset>
</target>
<!-- Target: Create target folders, set up logging -->
<target name="create_target_folders" depends="init" description="Creating target forlders">
<echo message="Sakai 3 UX Build: Creating target folders..." />
<mkdir dir="${TARGET_DIR}"/>
<mkdir dir="${TARGET_DIR_W}"/>
<mkdir dir="${TARGET_DIR_VAR}"/>
<mkdir dir="${TARGET_DIR_APPS}"/>
<mkdir dir="${TARGET_DIR_ROOT}"/>
<mkdir dir="${TARGET_COMPRESSED_DIR}"/>
<mkdir dir="${TARGET_DOCUMENTATION_DIR}"/>
<mkdir dir="${TARGET_REPORTS_DIR}"/>
<!-- Set up build logging -->
<record name="${TARGET_REPORTS_DIR}/build.log" loglevel="verbose"/>
</target>
<!-- Target: Copy source tree -->
<target name="copy_all" depends="create_target_folders" description="Copy source files to target folders">
<echo message="Making a copy of core source files..." />
<copy todir="${TARGET_DIR}">
<fileset dir="${SRC_DIR}" />
</copy>
<echo message="Making a copy of widget source files..." />
<copy todir="${TARGET_DIR_W}">
<fileset dir="${SRC_DIR_W}" />
</copy>
<echo message="Making a copy of var content files..." />
<copy todir="${TARGET_DIR_VAR}">
<fileset dir="${SRC_DIR_VAR}" />
</copy>
<echo message="Making a copy of apps content files..." />
<copy todir="${TARGET_DIR_APPS}">
<fileset dir="${SRC_DIR_APPS}" />
</copy>
<echo message="Making a copy of root content files..." />
<copy todir="${TARGET_DIR_ROOT}">
<fileset dir="${SRC_DIR_ROOT}" />
</copy>
</target>
<!-- Target: Normalise permissions -->
<target name="permissions">
<echo message="Normalising permissions..." />
<chmod dir="${TARGET}" perm="744" type="both"/>
</target>
<!-- Target: Check whitespace, tabs, line ending -->
<target name="formatting">
<echo message="Fixing encoding, EOL, tabs and EOF..." />
<fixcrlf srcdir="${TARGET_DIR}" includes="*.html,*.js,*.css,*.json" outputencoding="utf-8" eol="lf" tab="remove" tablength="4" eof="remove" />
</target>
<!-- Target: Run Javascript files through JSLint -->
<target name="js_lint">
<echo message="Generating JSLint report for core Javascript files..." />
<apply executable="java" parallel="true" output="${TARGET_REPORTS_DIR}/jslint_core.txt">
<arg value="-jar"/>
<arg path="${JSLINT}"/>
<arg line="--browser --css --devel --evil --eqeqeq --indent=4 --predef=window,sakai,fluid,$ --undef --maxerr=1000"/>
<fileset dir="${TARGET_DIR}">
<patternset refid="js.corefiles"/>
</fileset>
</apply>
<echo message="Generating JSLint report for widget Javascript files..." />
<apply executable="java" parallel="true" output="${TARGET_REPORTS_DIR}/jslint_widgets.txt">
<arg value="-jar"/>
<arg path="${JSLINT}"/>
<arg line="--browser --css --devel --evil --eqeqeq --indent=4 --predef=window,sakai,fluid,$ --undef --maxerr=1000"/>
<fileset dir="${TARGET_DIR_W}">
<patternset refid="js.widgetfiles"/>
</fileset>
</apply>
</target>
<!-- Target: Minfy CSS files -->
<target name="minify_css">
<echo message="Minifying core CSS files..." />
<apply executable="java" parallel="false" dest="${TARGET_DIR}" force="true">
<fileset dir="${TARGET_DIR}">
<patternset refid="css.corefiles"/>
</fileset>
<arg value="-jar"/>
<arg path="${YUI_COMPRESSOR}"/>
<srcfile/>
<arg value="-o"/>
<mapper type="identity"/>
<targetfile/>
</apply>
<echo message="Minifying widget CSS files..." />
<apply executable="java" parallel="false" dest="${TARGET_DIR_W}" force="true">
<fileset dir="${TARGET_DIR_W}">
<patternset refid="css.widgetfiles"/>
</fileset>
<arg value="-jar"/>
<arg path="${YUI_COMPRESSOR}"/>
<srcfile/>
<arg value="-o"/>
<mapper type="identity"/>
<targetfile/>
</apply>
</target>
<!-- Target: Minify Javascript -->
<target name="minify_js">
<echo message="Minifying core Javascript files..." />
<apply executable="java" parallel="false" dest="${TARGET_DIR}" force="true">
<fileset dir="${TARGET_DIR}">
<patternset refid="js.corefiles"/>
</fileset>
<arg value="-jar"/>
<arg path="${YUI_COMPRESSOR}"/>
<srcfile/>
<arg value="-o"/>
<mapper type="identity"/>
<targetfile/>
</apply>
<echo message="Minifying widget Javascript files..." />
<apply executable="java" parallel="false" dest="${TARGET_DIR_W}" force="true">
<fileset dir="${TARGET_DIR_W}">
<patternset refid="js.widgetfiles"/>
</fileset>
<arg value="-jar"/>
<arg path="${YUI_COMPRESSOR}"/>
<srcfile/>
<arg value="-o"/>
<mapper type="identity"/>
<targetfile/>
</apply>
</target>
<!-- Target: Create archives -->
<target name="compress">
<echo message="Creating ZIP file..." />
<zip destfile="${TARGET_ZIP_FILE}" basedir="${TARGET_RESOURCES}" encoding="UTF-8"/>
<echo message="Creating gzipped TAR file..." />
<tar destfile="${TARGET_TAR_FILE}" basedir="${TARGET_RESOURCES}" compression="gzip"/>
</target>
<!-- Create documentation -->
<target name="documentation" depends="init">
<echo message="Creating documentation..."/>
<property name="jsdoc.output" location="${TARGET_DOCUMENTATION_DIR}"/>
<property name="jsdoc.defaulttemplate" location="${JSDOCTOOLKIT_DIR}/templates/jsdoc"/>
<property name="jsdoc.logfile" location="${TARGET_REPORTS_DIR}/documentation.log"/>
<apply executable="java" parallel="true">
<arg value="-jar"/>
<arg path="${JSDOCTOOLKIT_DIR}/jsrun.jar"/>
<arg path="${JSDOCTOOLKIT_DIR}/app/run.js"/>
<arg value="-d=${jsdoc.output}"/>
<arg value="-t=${jsdoc.defaulttemplate}"/>
<arg value="-o=${jsdoc.logfile}"/>
<filelist dir="${SRC_DIR}/_lib/sakai_util">
<file name="sakai_magic.js" />
</filelist>
<fileset dir="${SRC_DIR_W}">
<patternset refid="js.widgetfiles"/>
</fileset>
</apply>
</target>
<!-- Target: Instrument with JSCoverage -->
<target name="instrument" depends="init">
<delete dir="${INSTRUMENTED_DIR}" includeemptydirs="true" />
<exec executable="jscoverage">
<arg value="--no-instrument" />
<arg value="_tests" />
<arg value="--no-instrument" />
<arg value="_lib${file.separator}google" />
<arg value="--no-instrument" />
<arg value="_lib${file.separator}Fluid" />
<arg value="--no-instrument" />
<arg value="_lib${file.separator}jquery" />
<arg value="--no-instrument" />
<arg value="_lib${file.separator}sakai_util${file.separator}trimpath.template.js" />
<arg value="${SRC_DIR}" />
<arg value="${INSTRUMENTED_DIR}" />
</exec>
</target>
<!-- Target: Build complete -->
<target name="finish" depends="init, create_target_folders, copy_all, permissions, formatting, js_lint, minify_css, minify_js, compress, documentation">
<echo message="Sakai 3 UX Build: Build complete." />
</target>
<!-- Target: Remove the build folder -->
<target name="clean" depends="init" description="Remove the build folder">
<delete dir="${TARGET}" includeemptydirs="true" />
<delete dir="${INSTRUMENTED_DIR}" includeemptydirs="true" />
</target>
</project>