This repository has been archived by the owner on Mar 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
187 lines (174 loc) · 6.66 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
<?xml version="1.0"?>
<project name="CloudKidCaptions" default="build-all" basedir="./">
<property file="${os.name}.build.properties"/>
<property file="build/build.properties"/>
<macrodef name="uglifyjs">
<attribute name="options" default="-m" />
<attribute name="debug" default="false" />
<attribute name="compress" default="" />
<attribute name="output" />
<sequential>
<fail unless="source.order" message="version needs to be specified in the build.properties as the output directory" />
<fail unless="source.dir" message="The folder that contains all the source" />
<fail unless="compressor" message="Path to the uglify-js program" />
<jshint list="${source.order}" dir="${source.dir}" />
<echo message="+---------------------------------+" />
<echo message="| Building the Library JavaScript |" />
<echo message="+---------------------------------+" />
<resourcelist id="files">
<file file="${source.order}" />
<filterchain>
<prefixlines prefix="${source.dir}/" />
</filterchain>
</resourcelist>
<pathconvert property="allFiles" refid="files" pathsep=" " />
<exec executable="${compressor}" failonerror="true">
<arg line="${allFiles}" />
<arg line="-o @{output}" />
<arg line="@{options}" />
<arg line="-c @{compress}" />
<arg line="--define DEBUG=@{debug},RELEASE=!@{debug}" />
</exec>
<replaceregexp file="@{output}" match="\$\{version\}" replace="${version}" flags="g" />
</sequential>
</macrodef>
<macrodef name="jshint">
<attribute name="list" />
<attribute name="dir" />
<sequential>
<fail unless="js.validator" message="js.validator needs to be specified in the build.properties as the JSHint or similar lint app" />
<echo message="+--------------------------+" />
<echo message="| Validating the JS Source |" />
<echo message="+--------------------------+" />
<loadfile property="files" srcFile="@{list}">
<filterchain>
<prefixlines prefix=" @{dir}/" />
<striplinebreaks />
<trim />
</filterchain>
</loadfile>
<exec executable="${js.validator}">
<arg line="${files}" />
</exec>
</sequential>
</macrodef>
<target name="build-debug" description="Compile JS project in debug mode">
<uglifyjs output="${output.debug}" debug="true" options="-b" />
</target>
<target name="build-release" description="Compile JS project in release mode">
<uglifyjs output="${output.min}" />
</target>
<target name="build-uncompressed" description="Compile JS project with the docs">
<concat-source output="${output.docs}" dir="${source.dir}" order="${source.order}" />
<replaceregexp file="${output.docs}" match="\( ?RELEASE ?\)" replace="(false)" flags="g" />
<replaceregexp file="${output.docs}" match="\( ?DEBUG ?\)" replace="(true)" flags="g" />
</target>
<target name="build-all" description="Compile the Minified, Debug and Uncompressed versions of the library">
<antcall target="build-debug" />
<antcall target="build-release" />
<antcall target="build-uncompressed" />
</target>
<macrodef name="concat-source">
<attribute name="output" />
<attribute name="dir" />
<attribute name="order" />
<sequential>
<concat destfile="@{output}" encoding="UTF-8" outputencoding="UTF-8" fixlastline="true">
<resourcelist>
<file file="@{order}" />
<filterchain>
<prefixlines prefix="@{dir}/" />
</filterchain>
</resourcelist>
</concat>
</sequential>
</macrodef>
<target name="import-example-libs" description="Copy the files specified in dependencies.txt to examples project">
<fail unless="libs" message="libs needs to be specified in build.properties as the bower libs to install" />
<exec executable="${bower}" failonerror="true">
<arg line="install" />
<arg line="${libs}" />
</exec>
</target>
<macrodef name="docs-config">
<attribute name="template" default="${docs.config}" />
<attribute name="file" default="temp.json" />
<sequential>
<copy file="@{template}" tofile="@{file}" overwrite="true" />
<replaceregexp file="@{file}" match="\$\{docs\.description\}" replace="${docs.description}" flags="g" />
<replaceregexp file="@{file}" match="\$\{docs\.name\}" replace="${docs.name}" flags="g" />
<replaceregexp file="@{file}" match="\$\{version\}" replace="${version}" flags="g" />
<replaceregexp file="@{file}" match="\$\{docs\.outdir\}" replace="${docs.outdir}" flags="g" />
<replaceregexp file="@{file}" match="\$\{docs\.logo\}" replace="${docs.logo}" flags="g" />
<replaceregexp file="temp.json" match="\$\{docs\.helpers\}" replace="${docs.helpers}" flags="g" />
<replaceregexp file="temp.json" match="\$\{docs\.themedir\}" replace="${docs.themedir}" flags="g" />
</sequential>
</macrodef>
<macrodef name="docs-cleanup">
<attribute name="file" default="temp.json" />
<sequential>
<delete file="@{file}" />
</sequential>
</macrodef>
<target name="docs" description="Use YUIDoc to build the documentation for this library.">
<docs-config />
<exec executable="${docs}">
<arg line="${source.dir}" />
<arg line="--config temp.json" />
</exec>
<docs-cleanup />
</target>
<target name="docs-server" description="Set up a server to show a real-time preview of the docs page. Visit http://127.0.0.1:3000/ and refresh to see changes">
<docs-config />
<exec executable="${docs}">
<arg line="--server" />
<arg line="--config temp.json" />
<arg line="${source.dir}" />
</exec>
<docs-cleanup />
</target>
<target name="docs-to-git" description="Auto-sync the docs to the Git docs branch">
<antcall target="docs" />
<delete dir="../${docs.outdir}" />
<copy todir="../${docs.outdir}">
<fileset dir="${docs.outdir}"/>
</copy>
<!-- Switch the branch -->
<exec executable="${git}" failonerror="true">
<arg line="checkout" />
<arg line="${git.docs}" />
</exec>
<delete includeEmptyDirs="true">
<fileset dir="." />
</delete>
<copy todir="./" overwrite="true">
<fileset dir="../${docs.outdir}" includes="**/*">
<depth max="3" />
</fileset>
</copy>
<delete dir="../${docs.outdir}" />
<!-- Add the files -->
<exec executable="${git}" failonerror="true">
<arg line="add" />
<arg line="-A" />
<arg line="." />
</exec>
<!-- Commit the files -->
<exec executable="${git}" failonerror="true">
<arg line="commit" />
<arg line="-m" />
<arg line='"Auto updated docs"' />
</exec>
<!-- Sync the files -->
<exec executable="${git}" failonerror="true">
<arg line="push" />
<arg line="origin" />
<arg line="${git.docs}" />
</exec>
<!-- Switch the branch back -->
<exec executable="${git}" failonerror="true">
<arg line="checkout" />
<arg line="${git.master}" />
</exec>
</target>
</project>