forked from InteractiveAdvertisingBureau/openvv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
137 lines (119 loc) · 4.84 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
<?xml version="1.0" encoding="utf-8"?>
<project name="OpenVV"
basedir="."
default="compile-all">
<property environment="env"/>
<property name="FLEX_HOME" value="${env.FLEX_HOME}"/>
<property name="src.dir" value="src" />
<property name="bin.dir" value="bin" />
<property name="tmp.dir" value="tmp" />
<property name="test.dir" value="tests" />
<property name="test_ad.dir" value="${test.dir}/test_ad" />
<property name="asdoc.dir" value="asdoc" />
<condition property="uglifyjs" value="uglifyjs.cmd" else="uglifyjs">
<os family="windows"/>
</condition>
<taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar"/>
<target name="compile-all" depends="clean, compile-beacon, minify-js, compile-lib"/>
<target name="compile-debug" depends="clean, compile-beacon, copy-js, compile-lib"/>
<target name="sign-version">
<sequential>
<echo>Signing build with version: ${build.version}</echo>
<delete file="${src.dir}/org/openvv/OVVVersion.as" />
<filter token="version" value="${build.version}" />
<copy file="util/Version.as.template" toFile="${src.dir}/org/openvv/OVVVersion.as" filtering="true" />
</sequential>
</target>
<target name="minify-js">
<mkdir dir="${tmp.dir}"/>
<exec executable="${uglifyjs}">
<arg path="${src.dir}/org/openvv/js/OVVAsset.js"/>
<arg value="-o"/>
<arg path="${tmp.dir}/OVVAsset.min.js"/>
<arg value="-c"/>
<arg value="-m"/>
<arg value="evaluate=false"/>
</exec>
</target>
<target name="copy-js" depends="clean">
<copy file="${src.dir}/org/openvv/js/OVVAsset.js" tofile="${tmp.dir}/OVVAsset.min.js" />
<!-- Escape line endings -->
<fixcrlf srcdir="${tmp.dir}" includes="*.js"
eol="lf" eof="remove" />
<property name="foo.esc">%%%***%%%</property>
<replaceregexp file="${tmp.dir}/OVVAsset.min.js"
flags="g"
match="\n"
replace="${foo.esc}${line.separator}"
byline="false"
/>
<replace file="${tmp.dir}/OVVAsset.min.js" token="${foo.esc}" value="\" />
</target>
<target name="compile-beacon" depends="check-env, sign-version">
<mxmlc file="${src.dir}/org/openvv/OVVBeacon.as"
output="${bin.dir}/OVVBeacon.swf"
static-rsls="true">
<source-path path-element="${src.dir}"/>
</mxmlc>
<copy file="${bin.dir}/OVVBeacon.swf" todir="${test.dir}/test_site/ad" overwrite="true" />
</target>
<target name="compile-lib" depends="check-env, sign-version">
<!-- Copy the entire source tree to temp dir so we can alter the source code -->
<copy todir="${tmp.dir}" overwrite="true">
<fileset dir="${src.dir}"/>
</copy>
<!-- Store the minified JS code (which was already under temp) in js-src -->
<loadfile property="js-src" srcfile="${tmp.dir}/OVVAsset.min.js"/>
<!-- Escape the minified JS code -->
<loadresource property="js-src-esc">
<propertyresource name="js-src"/>
<filterchain>
<tokenfilter>
<filetokenizer/>
<replacestring from=""" to="\""/>
</tokenfilter>
</filterchain>
</loadresource>
<!-- Store the escaped and minified JS code in OVVAsset -->
<replace file="${tmp.dir}/org/openvv/OVVAsset.as" token="{{OVVAssetJS}}" value="${js-src-esc}" />
<!-- Time to compile! -->
<compc output="${bin.dir}/openvv.swc"
include-classes="org.openvv.OVVAsset org.openvv.OVVCheck org.openvv.OVVRenderMeter org.openvv.OVVThrottleType org.openvv.events.OVVEvent net.iab.IVPAID net.iab.VPAIDEvent org.openvv.OVVVersion">
<source-path path-element="${tmp.dir}"/>
</compc>
<!-- copy result to the test ad compile area -->
<copy file="${bin.dir}/openvv.swc" todir="${test_ad.dir}/libs" overwrite="true" />
<!-- Remove the temp dir -->
<delete dir="${tmp.dir}" failonerror="false"/>
</target>
<target name="compile-doc" depends="check-env, sign-version">
<asdoc output="${asdoc.dir}" lenient="true" failonerror="true">
<doc-sources path-element="${src.dir}" />
</asdoc>
</target>
<target name="clean">
<delete file="${src.dir}/org/openvv/OVVVersion.as" failonerror="false" />
<delete file="${tmp.dir}/OVVAsset.min.js" failonerror="false" />
<delete file="${tmp.dir}/org/openvv/OVVAsset.as" failonerror="false" />
<delete dir="${bin.dir}" failonerror="false" />
<delete dir="${asdoc.dir}" failonerror="false" />
</target>
<target name="check-env">
<echo>Value of FLEX_HOME is ${FLEX_HOME}</echo>
<fail message="You must set the FLEX_HOME environment variable to your SDK's home directory">
<condition>
<not>
<isset property="env.FLEX_HOME"/>
</not>
</condition>
</fail>
<echo>UglifyJS will be invoked as ${uglifyjs}</echo>
<fail message="Could not find ${uglifyjs} in your PATH! Please get node.js and run `npm i -g uglify-js`">
<condition>
<not>
<available file="${uglifyjs}" filepath="${env.PATH}${path.separator}${env.Path}${path.separator}${env.path}"/>
</not>
</condition>
</fail>
</target>
</project>