forked from labadserver/Adplayer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
162 lines (149 loc) · 7.25 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
<project name="AdPlayer" default="_default-build" basedir=".">
<description>AdPlayer build script.</description>
<xmlproperty file=".project" keeproot="true"/>
<property name="version-major" value="${projectDescription.major}"/>
<property name="version-minor" value="${projectDescription.minor}"/>
<property name="version-patch" value="${projectDescription.patch}"/>
<property name="version-stage" value="${projectDescription.stage}"/>
<property name="version" value="${version-major}.${version-minor}.${version-patch}.${version-stage}"/>
<tstamp>
<format property="today" pattern="MMddyy" locale="en,UK"/>
</tstamp>
<property name="version-detailed" value="v${version} (${version-stage}.${today})"/>
<property name="jsfilename" value="adplayer"/>
<property name="cssfilename" value="adplayer"/>
<property name="build-dir" location="build"/>
<property name="test-dir" location="tests"/>
<property name="lib-dir" location="lib"/>
<property name="src-dir" location="src"/>
<property name="js-dir" location="src/js"/>
<property name="css-dir" location="src/css"/>
<property name="html-dir" location="src/html"/>
<target name="prepare" description="Prepares the build directory.">
<delete dir="${build-dir}" />
<mkdir dir="${build-dir}"/>
<copy todir="${build-dir}/css" overwrite="true">
<fileset dir="${css-dir}" includes="*">
<exclude name="*.png"/>
</fileset>
<mapper type="glob" from="*" to="${cssfilename}.css" />
</copy>
<copy todir="${build-dir}/css" overwrite="true">
<fileset dir="${css-dir}" includes="*.png" />
</copy>
<copy todir="${build-dir}/demo" overwrite="true">
<fileset dir="${html-dir}/demo" />
</copy>
<copy file="README" todir="${build-dir}" />
</target>
<target name="compile" depends="prepare" description="Compiles source and replaces all tokens.">
<concat destfile="${build-dir}/js/${jsfilename}.js" fixlastline="true">
<filelist dir="${js-dir}/player">
<!-- DEFINE Class list order -->
<file name="Namespace.js"/>
<file name="Registry.js"/>
<file name="Player.js"/>
<file name="PrivacyInfo.js"/>
<file name="Message.js"/>
<file name="Util.js"/>
<file name="Version.js"/>
<file name="Init.js"/>
<!-- END DEFINE Class list order -->
</filelist>
</concat>
<replace dir="${build-dir}" token="_@ADPLAYER_JS_FILE@_" value="${jsfilename}.js" />
<replace dir="${build-dir}" token="_@ADPLAYER_JS_FILE_MIN@_" value="${jsfilename}.min.js" />
<replace dir="${build-dir}" token="_@ADPLAYER_CSS_FILE@_" value="${cssfilename}.css" />
<replace dir="${build-dir}" token="_@VERSION@_" value="${version-detailed}" />
<replace dir="${build-dir}" token="_@VERSION_MAJOR@_" value="${version-major}" />
<replace dir="${build-dir}" token="_@VERSION_MINOR@_" value="${version-minor}" />
<replace dir="${build-dir}" token="_@VERSION_PATCH@_" value="${version-patch}" />
<replace dir="${build-dir}" token="_@VERSION_STAGE@_" value="${version-stage}" />
</target>
<target name="compress" depends="compile" description="Compresses js and css files.">
<apply executable="java" parallel="false">
<fileset dir="${build-dir}/js/" includes="*.js"/>
<arg line="-jar"/>
<arg path="tools/yui/yuicompressor-2.4.2.jar"/>
<srcfile/>
<arg line="-o"/>
<mapper type="glob" from="*.js" to="${build-dir}/js/*.min.js"/>
<targetfile/>
</apply>
<apply executable="java" parallel="false">
<fileset dir="${build-dir}/css/" includes="*.css"/>
<arg line="-jar"/>
<arg path="tools/yui/yuicompressor-2.4.2.jar"/>
<srcfile/>
<arg line="-o"/>
<mapper type="glob" from="*.css" to="${build-dir}/css/*.min.css"/>
<targetfile/>
</apply>
</target>
<target name="gnu" depends="compress" description="Appends GPL liscense to all build files.">
<copy tofile="${build-dir}/gpl.txt" file="gpl.txt" overwrite="true" />
<copy todir="${build-dir}/tmp" file="gnu.txt" overwrite="true" />
<replace file="${build-dir}/tmp/gnu.txt" token="_@VERSION@_" value="${version-detailed}" />
<!-- TODO: Possibly loop through files, but will require ant-contrib -->
<!-- JS/CSS Files -->
<antcall target="gnu.me">
<param name="filepath" value="${build-dir}/css/${cssfilename}.css" />
</antcall>
<antcall target="gnu.me">
<param name="filepath" value="${build-dir}/css/${cssfilename}.min.css" />
</antcall>
<antcall target="gnu.me">
<param name="filepath" value="${build-dir}/js/${jsfilename}.js" />
</antcall>
<antcall target="gnu.me">
<param name="filepath" value="${build-dir}/js/${jsfilename}.min.js" />
</antcall>
<!-- <antcall target="gnu.me"> -->
<!-- <param name="filepath" value="${build-dir}/demo/example1.js" /> -->
<!-- </antcall> -->
<!-- <antcall target="gnu.me"> -->
<!-- <param name="filepath" value="${build-dir}/demo/example2.js" /> -->
<!-- </antcall> -->
<!-- <antcall target="gnu.me"> -->
<!-- <param name="filepath" value="${build-dir}/demo/example3.js" /> -->
<!-- </antcall> -->
<!-- HTML Files -->
<replace file="${build-dir}/tmp/gnu.txt" token="/*" value="<!--" />
<replace file="${build-dir}/tmp/gnu.txt" token="*/" value="-->" />
<loadfile property="gnulicense" srcfile="${build-dir}/tmp/gnu.txt" />
<replace dir="${build-dir}" token="<!--_@GNULICENSE@_-->" value="${gnulicense}" />
</target>
<target name="gnu.me">
<concat destfile="${build-dir}/tmp/gnutemp.tmp" fixlastline="true">
<header filtering="no" trimleading="no" file="${build-dir}/tmp/gnu.txt"></header>
<path path="${filepath}"/>
</concat>
<move overwrite="true" file="${build-dir}/tmp/gnutemp.tmp" tofile="${filepath}"></move>
</target>
<target name="_default-build" depends="gnu" description="Processes default and cleans up all temp files.">
<delete dir="${build-dir}/tmp" />
<echo>AdPlayer ${version-detailed} - Default Build Complete</echo>
</target>
<target name="tests" depends="_default-build" description="prepares the the test directory">
<symlink action="delete" link="${test-dir}/adplayer.js"/>
<symlink link="${test-dir}/adplayer.js" resource="${build-dir}/js/${jsfilename}.js"/>
</target>
<target name="_jsdoc-build" depends="_default-build" description="Builds default and jsdoc output.">
<taskdef name="jsdoctoolkit" classname="uk.co.darrenhurley.ant.tasks.JsDocToolkit" classpath="tools/jsdoc/jsdoc-toolkit-ant-task-1.1.2.jar;tools/jsdoc/jsrun.jar" />
<jsdoctoolkit jsdochome="tools/jsdoc/" template="jsdoc" outputdir="${build-dir}/docs/">
<source file="${build-dir}/js/${jsfilename}.js" />
</jsdoctoolkit>
<echo>AdPlayer ${version-detailed} - JSDoc Build Complete</echo>
</target>
<target name="_release-build" depends="_jsdoc-build" description="Compiles and packages entire build to a zip.">
<zip destfile="${build-dir}/adplayer-v${version}.zip">
<zipfileset dir="${build-dir}">
<exclude name="**/docs/**" />
</zipfileset>
</zip>
<zip destfile="${build-dir}/apidocs_adplayer-v${version}.zip">
<zipfileset dir="${build-dir}/docs" />
</zip>
<echo>AdPlayer ${version-detailed} - Release Build Complete</echo>
</target>
</project>