-
Notifications
You must be signed in to change notification settings - Fork 53
/
build.xml
147 lines (114 loc) · 4.87 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
<?xml version="1.0" encoding="UTF-8"?>
<project name="ZipBuilder" basedir=".">
<taskdef resource="net/sf/antcontrib/antlib.xml" classpath="ant/ant-contrib.jar" />
<description>
Tasks to construct the downloadable ZIP files for the tutorial projects.
Requires an manifest.xml file located in the tutorial folder to be included in the
zip. The manifest.xml file contains the filenames of the classes to be used to create
launch scripts.
</description>
<property name="temp.folder" value="temp-zip-folder" />
<property name="manifest.location" value="/Users/Greg/Trunks/away3d-tutorials-fp11/tutorials/animation/basic_tweening/manifest.txt" />
<target name="Util:Remove-temp-folder" if="tempFolderExists" depends="Util:CheckTempFolder">
<echo> - Util:Removing temporary folder.</echo>
<delete includeEmptyDirs="true">
<fileset dir="${temp.folder}"/>
</delete>
</target>
<target name="Util:CheckTempFolder">
<condition property="tempFolderExists">
<available file="${temp.folder}" type="dir"/>
</condition>
</target>
<target name="Util:Create-temp-folder" depends="Util:Remove-temp-folder">
<echo> - Util:Creating temporary folder.</echo>
<mkdir dir="${temp.folder}"/>
</target>
<target name="Generate Specified Tutorial ZIP" depends="Util:Create-temp-folder">
<echo>Generate Specified Tutorial ZIP"</echo>
<Generate-Zip-bundle manifest-file="${manifest.location}" />
</target>
<target name="Generate ALL Tutorial ZIP Bundles" depends="Util:Create-temp-folder">
<echo>Generate ALL Tutorial ZIP Bundles</echo>
<for param="manifest.file">
<path>
<fileset dir="." includes="**/manifest.txt"/>
</path>
<sequential>
<Generate-Zip-bundle manifest-file="@{manifest.file}" />
</sequential>
</for>
</target>
<macrodef name="Generate-Zip-bundle">
<attribute name="manifest-file"/>
<sequential>
<echo>Generating tutorial ZIP bundle @{manifest-file}</echo>
<!-- Reset vars -->
<var name="file-content" unset="true"/>
<var name="project-name" unset="true"/>
<var name="project-path" unset="true"/>
<var name="project-name" unset="true"/>
<!-- Read the contents of the manifest file to get the project name and source files -->
<loadfile srcfile="@{manifest-file}" property="file-content" />
<!-- Make the launch directory -->
<mkdir dir="${temp.folder}/launch" />
<!-- Make the empty bin directory -->
<mkdir dir="${temp.folder}/bin" />
<!-- Loop through each element in the file (Project:<project name>,src-file1,src-file2) -->
<for list="${file-content}" delimiter="," param="manifest-item">
<sequential>
<if>
<matches string="@{manifest-item}" pattern="^Project:"/>
<then>
<!-- Set the project name -->
<propertyregex property="project-name"
input="@{manifest-item}"
regexp="^(Project:)(.*)"
select="\2"
casesensitive="false" />
<echo message="Project reference found:${project-name}" />
</then>
<else>
<!-- Process the source file -->
<echo message="Source file found:@{manifest-item}" />
<!-- Get the sources name -->
<var name="source-name" unset="true"/>
<basename property="source-name" file="@{manifest-item}" suffix=".as"/>
<echo message="Trimmed source file found:${source-name}" />
<!-- Copy and rename the launch file to the project name -->
<copy file="bundle/launch/project.launch" tofile="${temp.folder}/launch/${source-name}.launch"/>
<!-- Change the launch source reference in the launch template -->
<replace file="${temp.folder}/launch/${source-name}.launch" token="---SOURCE---" value="${source-name}"/>
<!-- Change the launch source reference in the launch template -->
<replace file="${temp.folder}/launch/${source-name}.launch" token="---PROJECT---" value="${project-name}"/>
</else>
</if>
</sequential>
</for>
<!-- Get the project path -->
<dirname property="project-path" file="@{manifest-file}" />
<!-- Copy the template files -->
<copy todir="${temp.folder}">
<fileset dir="./bundle">
<exclude name="**/launch/**"/>
</fileset>
</copy>
<!-- Copy the project files -->
<copy todir="${temp.folder}">
<fileset dir="${project-path}">
<exclude name="**/bin/**"/>
<exclude name="**/images/**"/>
<exclude name="manifest.txt"/>
</fileset>
</copy>
<!-- Create the archive -->
<zip destfile="${project-path}/${project-name}.zip"
basedir="${temp.folder}"
excludes="**/${project-name}.zip"
update="no"
/>
<!-- Remove the temporary folder -->
<antcall target="Util:Remove-temp-folder" />
</sequential>
</macrodef>
</project>