This repository has been archived by the owner on Feb 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.xml
167 lines (150 loc) · 7.39 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
<?xml version="1.0"?>
<project name="jameson" default="usage" basedir=".">
<description>ActionScript 3 JSON Object Mapper</description>
<property file="user.properties" />
<property file="build.properties" />
<!-- Add the ant-contrib tasks -->
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpath="${res.dir}/ant/ant-contrib.jar" />
<!-- Set up FlexUnit Ant tasks -->
<taskdef resource="flexUnitTasks.tasks" classpath="${res.dir}/ant/flexUnitTasks.jar" />
<target name="usage">
<echo message=""/>
<echo message="${project.name.full}"/>
<echo message="-----------------------------------"/>
<echo message=""/>
<echo message="Available targets:"/>
<echo message=""/>
<echo message="test --> Build Nobien ActionScript 3 Toolkit SWC and run unit tests"/>
<echo message="build --> Build Nobien ActionScript 3 Toolkit SWC"/>
<echo message="clean --> Remove all folders created by build script"/>
<echo message="init --> Create build folders"/>
<echo message=""/>
</target>
<target name="init" depends="clean">
<echo>[init] Creating directories: bin, report</echo>
<mkdir dir="${bin.dir}"/>
<mkdir dir="${report.dir}"/>
<echo>[init] Directories created: bin, report</echo>
</target>
<target name="clean">
<echo>[clean] Removing directories: bin, report, dist</echo>
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${docs.dir}" defaultexcludes="false">
<include name="**/*"/>
</fileset>
<fileset dir="${report.dir}" defaultexcludes="false">
<include name="**/*"/>
</fileset>
<fileset dir="${dist.dir}" defaultexcludes="false">
<include name="**/*"/>
</fileset>
<fileset dir="${bin.dir}" defaultexcludes="false">
<include name="**/*"/>
</fileset>
</delete>
<echo>[clean] Directories removed: bin, report, dist</echo>
</target>
<target name="build" depends="test">
<echo>[build] Compiling SWC</echo>
<echo>[build] Using Flex SDK at: ${FLEX_HOME}</echo>
<java jar="${FLEX_HOME}/lib/compc.jar" dir="${FLEX_HOME}/frameworks" fork="true" failonerror="true">
<arg value="-output=${bin.dir}/${project.name.versioned}.swc"/>
<arg value="-include-sources=${src.dir}" />
<arg value="-incremental=true"/>
<arg value="-keep-as3-metadata+=JsonProperty"/>
<arg value="-keep-as3-metadata+=JsonConstructor"/>
<arg value="-external-library-path+=${res.dir}/lib"/>
<arg value="-static-link-runtime-shared-libraries=true"/>
<arg value="-verbose-stacktraces=true"/>
<arg value="-include-sources=${src.dir}"/>
<arg value="-headless-server=true"/>
<arg value="-debug=false"/>
</java>
<echo>[build] Release SWC ${project.name.versioned}.swc created successfully</echo>
</target>
<target name="docs" depends="test">
<echo>[docs] Generating ASDoc documentation </echo>
<tstamp><format property="year" pattern="yyyy" /></tstamp>
<tstamp>
<format property="docgen.time" pattern="MM/dd/yyyy hh:mm aa" unit="hour"/>
</tstamp>
<java jar="${FLEX_HOME}/lib/asdoc.jar" dir="${FLEX_HOME}/frameworks" fork="true" failonerror="true">
<arg value="-output=${docs.dir}" />
<arg value="-doc-sources=${src.dir}" />
<arg value="-source-path=${src.dir}" />
<arg value="-main-title=${project.name.full} ${project.version}" />
<arg value="-window-title=${project.name.full} ${project.version}" />
<arg value="-footer=Copyright © ${year} Nobien" />
</java>
<echo>[docs] ASDoc documentation generated successfully.</echo>
</target>
<target name="test" depends="init">
<echo>[test] Compiling unit tests</echo>
<java jar="${FLEX_HOME}/lib/mxmlc.jar" dir="${FLEX_HOME}/frameworks" maxmemory="512m" fork="true" failonerror="true">
<arg value="${test.target}"/>
<arg value="-output=${test.output}"/>
<arg value="-source-path=${test.dir}"/>
<arg value="-source-path=${src.dir}"/>
<arg value="-keep-as3-metadata+=JsonProperty"/>
<arg value="-keep-as3-metadata+=JsonConstructor"/>
<arg value="-library-path+=${res.dir}/lib"/>
<arg value="-default-size=1024,768"/>
<arg value="-default-background-color=0xFFFFFF"/>
<arg value="-incremental=true"/>
<arg value="-verbose-stacktraces=true"/>
<arg value="-headless-server=true"/>
<arg value="-debug=true"/>
</java>
<echo>[test] Unit tests compiled successfully</echo>
<echo>[test] Running FlexUnit Ant task on ${report.dir}/flash/${test.output}.swf</echo>
<flexunit swf="${test.output}"
toDir="${report.dir}/xml"
haltonfailure="false"
verbose="true"
localTrusted="true"
failureproperty="flexunit.failed" />
<!-- Copy HTML container for FlexUnit UI -->
<echo>[test] Generating Flash report container</echo>
<copy file="${res.dir}/html/test-runner.html" tofile="${report.dir}/flash/index.html"/>
<copy file="${res.dir}/js/swfobject.js" tofile="${report.dir}/flash/swfobject.js"/>
<replace file="${report.dir}/flash/index.html">
<replacefilter token="@SWF@" value="${test.output}"/>
</replace>
<!-- Generate readable JUnit-style reports -->
<echo>[test] Generating JUnit (HTML) report </echo>
<junitreport todir="${report.dir}/xml">
<fileset dir="${report.dir}/xml">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${report.dir}/html"/>
</junitreport>
<if>
<isset property="flexunit.failed"/>
<then>
<property name="browser.target" value="file://${report.dir}/html/index.html"/>
<antcall target="launch-browser"/>
<fail message="Failures exist in unit tests." />
</then>
<else>
<echo>[test] Tests completed with 0 failures or errors</echo>
</else>
</if>
</target>
<target name="launch-browser" description="Launches the browser and directs it to the browser.target property">
<echo>[launch-browser] Launching browser</echo>
<echo>[launch-browser] Directing to: ${browser.target}</echo>
<if>
<equals arg1="${is.unix}" arg2="true"/>
<then>
<exec executable="open">
<arg line="-a '${browser.exe}' ${browser.target}"/>
</exec>
</then>
<else>
<exec executable="${browser.exe}" spawn="true">
<arg line="'file://${browser.target}'"/>
</exec>
</else>
</if>
</target>
</project>