forked from aapotts/3akai-ux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
292 lines (239 loc) · 13 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
287
288
289
290
291
292
<?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="QUNIT_SRC_DIR" value="tests" description="QUnit test folder" />
<property name="TARGET" value="target" description="Core target folder" />
<property name="INSTRUMENTED_DIR" value="${TARGET}/instrumented" description="Instrumented source folder" />
<property name="TARGET_RESOURCES" value="${TARGET}/processed-resources" description="Top directory for JARs, archives" />
<property name="TARGET_COMPRESSED_DIR" value="${TARGET}/compressed" description="Core compressed folder" />
<property name="OPTIMIZED_DIR" value="${TARGET}/optimized" description="RequireJS optimized folder" />
<property name="TARGET_DIR" value="${TARGET_RESOURCES}/dev" description="Core target folder" />
<property name="TARGET_QUNIT_DIR" value="${TARGET_RESOURCES}/tests" description="QUnit target folder" />
<property name="TARGET_DOCUMENTATION_DIR" value="${TARGET_RESOURCES}/jsdoc" description="JSDoc documentation folder" />
<property name="TARGET_REPORTS_DIR" value="${TARGET_RESOURCES}/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="JSDOCTOOLKIT_DIR" value="tools/jsdoc-toolkit" description="JSDoc-Toolkit" />
<property name="ANT_CONTRIB" value="tools/ant-contrib/ant-contrib-1.0b3.jar" description="Ant-contrib 1.0b3" />
<property name="HASHTOOL_DIR" value="tools/hashfiles" description="hash js and css files" />
<!-- SETUP - Set Ant-contrib dependency -->
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${ANT_CONTRIB}"/>
</classpath>
</taskdef>
<!-- Define patternset for widget JS files (from ${TARGET_DIR_W}) -->
<patternset id="js.widgetfiles">
<include name="**/javascript/*.js"/>
</patternset>
<path id="hashfiles.jar.id">
<fileset dir="${HASHTOOL_DIR}/target">
<include name="*.jar"/>
</fileset>
</path>
<property name="HASHTOOL_JAR" refid="hashfiles.jar.id"/>
<echo message="Using this jar for hashing files: ${HASHTOOL_JAR}"/>
</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_prod" depends="create_target_folders" description="Copy source files to target folders">
<echo message="Making a copy of core source files from ${SRC_DIR}..." />
<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>
<copy todir="${TARGET_DIR_VAR}/ux-version" filtering="true" overwrite="true">
<filterset begintoken="@" endtoken="@">
<filtersfile file="${TARGET}/scm-version.properties" />
</filterset>
<fileset dir="${SRC_DIR_VAR}/ux-version" />
</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: Copy source tree -->
<target name="copy_test" depends="copy_prod" description="Copy qunit files to target folders">
<echo message="Making a copy of QUnit test files..." />
<copy todir="${TARGET_QUNIT_DIR}">
<fileset dir="${QUNIT_SRC_DIR}" />
</copy>
</target>
<!-- Target: Copy optimized source -->
<target name="copy_optimized" depends="optimize" description="Copy optimized files to target folders">
<antcall target="copy_prod">
<param name="SRC_DIR" value="${OPTIMIZED_DIR}/${SRC_DIR}" />
<param name="SRC_DIR_W" value="${OPTIMIZED_DIR}/${SRC_DIR_W}" />
<param name="SRC_DIR_VAR" value="${OPTIMIZED_DIR}/${SRC_DIR_VAR}" />
<param name="SRC_DIR_APPS" value="${OPTIMIZED_DIR}/${SRC_DIR_APPS}" />
</antcall>
</target>
<!-- Target: Copy instrumented source -->
<target name="copy_instrumented" depends="instrument" description="Copy instrumented files to target folders">
<if>
<equals arg1="${instrumentResult}" arg2="0"/>
<then>
<echo message="Copying instrumented files"/>
<antcall target="copy_test">
<param name="SRC_DIR" value="${INSTRUMENTED_DIR}" />
</antcall>
</then>
<else>
<echo message="Instrumenting failed, copying uninstrumented files"/>
<antcall target="copy_test"/>
</else>
</if>
</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" depends="create_target_folders">
<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>
<!-- Create documentation -->
<target name="documentation" depends="create_target_folders">
<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">
<file name="sakai.api.core.js" />
<file name="sakai.api.util.js" />
<file name="sakai.api.i18n.js" />
<file name="sakai.api.l10n.js" />
<file name="sakai.api.user.js" />
<file name="sakai.api.widgets.js" />
<file name="sakai.api.groups.js" />
<file name="sakai.api.communication.js" />
<file name="sakai.api.content.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" failifexecutionfails="false" resultproperty="instrumentResult">
<arg value="--no-instrument" />
<arg value="lib${file.separator}misc" />
<arg value="--no-instrument" />
<arg value="lib${file.separator}jquery" />
<arg value="--no-instrument" />
<arg value="lib${file.separator}tinymce" />
<arg value="${SRC_DIR}" />
<arg value="${INSTRUMENTED_DIR}" />
</exec>
</target>
<!-- Target: Optimize with requirejs -->
<target name="optimize" depends="init">
<delete dir="${OPTIMIZED_DIR}" includeemptydirs="true" />
<path id="reqjs.path">
<pathelement location="tools/requirejs-optimizer/r.js"/>
</path>
<property name="requireJs.path" refid="reqjs.path"/>
<property name="requireJs.conf" value="build.js" />
<!-- the rhino jar gets put here by maven -->
<java jar="${settings.localRepository}/rhino/js/1.7R2/js-1.7R2.jar" fork="true">
<arg value="${requireJs.path}" />
<arg value="-o" />
<arg value="${requireJs.conf}" />
</java>
</target>
<!-- Target: Unpack MathJax Font Images -->
<target name="unpackMathFonts" depends="copy_prod">
<property name="MATH_DIR" value="${TARGET_DIR}/lib/MathJax"/>
<property name="MATH_FONTS_DIR" value="${MATH_DIR}/fonts/HTML-CSS/TeX" />
<if>
<isset property="with-math"/>
<then>
<echo message="Unpacking MathJax Font images"/>
<unzip src="${MATH_FONTS_DIR}/png.zip" dest="${MATH_FONTS_DIR}"/>
<copy file="${MATH_DIR}/config/local/imageFonts.js" tofile="${MATH_DIR}/config/local/local.js"/>
</then>
<else>
<echo message="Not unpacking MathJax Font images, Math formulas on FireFox versions prior to 3.5 will not be supported!"/>
</else>
</if>
<delete file="${MATH_FONTS_DIR}/png.zip"/>
<delete file="${MATH_DIR}/config/local/imageFonts.js"/>
</target>
<!-- Target: Hash files-->
<target name="hash_files" depends="copy_optimized">
<!-- hashfiles jar gets put here by maven -->
<java jar="${HASHTOOL_JAR}"
fork="true">
<arg value="${HASHTOOL_DIR}/config.properties" />
</java>
</target>
<!-- Target: Release Builds-->
<target name="release" depends="init, create_target_folders, copy_optimized, permissions, formatting, unpackMathFonts, optimize, hash_files">
<echo message="Sakai 3 UX Build: Build complete." />
</target>
<!-- Target: Development Builds -->
<target name="development" depends="copy_instrumented, documentation, unpackMathFonts, instrument">
<echo message="Sakai 3 UX Development Build: Build complete." />
</target>
<!-- Target: Development Builds -->
<target name="dev_light" depends="copy_prod, copy_test, create_target_folders">
<echo message="Sakai 3 UX Development Build: Build complete." />
</target>
<!-- Target: Remove the build folder -->
<target name="clean" depends="init" description="Remove the build folder">
<delete dir="${TARGET}" includeemptydirs="true" />
</target>
</project>