Eclipse下使用Ant编译actionScript
最近一直在做Flex版的地图,忙忙碌碌的搞了三个多星期,基本功能算是完成了,在这里记录下在Eclipse下使用Ant编译actionScript的方法,供日后查询。工程目录下需要有这两个文件:
build.properties
1# Window and document title for the documentation
2title = DZ Map
3
4# Class-folders you want to search for classes to be included in the docs, seperated by spaces (for example ../com/ ../net/ )
5# to include every .as and .mxml file within your project, just state ../
6domainextensions = ./src
7
8# The Location of deployment library on your Computer (PC/Mac) for compiled SWC file
9liboutputfolder = libs
10liboutputfile = map.swc
11libpath = libs
12
13# The Location of the output folder for your generated documents
14docsoutputfolder = bin-debug/docs
15
16# Home directory for flex sdk 3, change this to build for Mac or PC using # as comment
17# FLEX_HOME = C:/Program Files/Adobe/Flex Builder 3/sdks/3.0.0
18FLEX_HOME = D:/tools/Adobe/Flex Builder 3 Plug-in/sdks/3.2.0
19
20# The location of your asdoc.exe, change this to build for Mac or PC using # as comment
21#asdoc.exe = C:/Program Files/Adobe/Flex Builder 3/sdks/3.0.0/bin/asdoc.exe
22asdoc.exe = D:/tools/Adobe/Flex Builder 3 Plug-in/sdks/3.2.0/bin/asdoc.exe
1# Window and document title for the documentation
2title = DZ Map
3
4# Class-folders you want to search for classes to be included in the docs, seperated by spaces (for example ../com/ ../net/ )
5# to include every .as and .mxml file within your project, just state ../
6domainextensions = ./src
7
8# The Location of deployment library on your Computer (PC/Mac) for compiled SWC file
9liboutputfolder = libs
10liboutputfile = map.swc
11libpath = libs
12
13# The Location of the output folder for your generated documents
14docsoutputfolder = bin-debug/docs
15
16# Home directory for flex sdk 3, change this to build for Mac or PC using # as comment
17# FLEX_HOME = C:/Program Files/Adobe/Flex Builder 3/sdks/3.0.0
18FLEX_HOME = D:/tools/Adobe/Flex Builder 3 Plug-in/sdks/3.2.0
19
20# The location of your asdoc.exe, change this to build for Mac or PC using # as comment
21#asdoc.exe = C:/Program Files/Adobe/Flex Builder 3/sdks/3.0.0/bin/asdoc.exe
22asdoc.exe = D:/tools/Adobe/Flex Builder 3 Plug-in/sdks/3.2.0/bin/asdoc.exe
build.xml
1<?xml version="1.0" encoding="utf-8"?>
2
3<!-- Flex Library Project ASDocs -->
4
5<project name="ASDocsTest" default="compile" basedir=".">
6
7 <!-- import our build properties file -->
8 <property file="./build.properties" />
9
10 <!-- Flex Ant Tasks used to perform compc and mxml compiling more info at http://labs.adobe.com/wiki/index.php/Flex_Ant_Tasks -->
11 <taskdef resource="flexTasks.tasks" classpath="${basedir}/flexTasks/lib/flexTasks.jar" />
12
13 <target name="setup" description="perform an setup operations"/>
14
15 <!-- Execute the ASDoc Compile wich runs 3 seperate tasks in a series -->
16 <target name="compile" description="series of tasks to create docs and swc">
17
18 <antcall target="cleanDir" description="clean the docs directory"/>
19
20 <antcall target="asDocs" description="full build of asdocs"/>
21
22 <antcall target="buildSWC" description="build the SWC file"/>
23
24 </target>
25
26 <target name="deploy" description="perform an deployment operations"/>
27
28 <target name="install" description="perform an installation operations"/>
29
30 <!--
31
32 DELETE the existing output folder and files and then re-generate the output folder
33
34 -->
35
36 <target name="cleanDir" description="DELETE the existing output folder and files and then re-generate the output folder">
37
38 <delete dir="${basedir}/${docsoutputfolder}" failOnError="true" includeEmptyDirs="true"/>
39
40 <mkdir dir="${basedir}/${docsoutputfolder}"/>
41
42 <!-- echo dumps output to the console window -->
43 <echo>doc directory cleaned</echo>
44
45 </target>
46
47
48 <!--
49
50 Run the ASDoc executable and generate the ASDocs to the new output folder
51
52 -->
53
54 <target name="asDocs" description="Run the ASDoc executable and generate the ASDocs to the new output folder">
55
56 <exec executable="${asdoc.exe}" failonerror="true">
57
58 <arg line="-doc-sources ${domainextensions}"/>
59
60 <arg value="-window-title" />
61 <arg value="'${title}'"/>
62
63 <arg value="-output" />
64 <arg value="${basedir}/${docsoutputfolder}"/>
65
66 <arg value="-external-library-path" />
67 <arg value="${basedir}/${libpath}" />
68
69 </exec>
70
71 <echo>docs created</echo>
72
73 </target>
74
75 <!--
76
77 Compile the SWC file library including libs folder and the path to our classes, we use compc for library, but we
78 would use mxml for MXML files, check the docs for Flex Ant Tasks, http://labs.adobe.com/wiki/index.php/Flex_Ant_Tasks.
79
80 -->
81
82 <target name="buildSWC" description="Compile the SWC file for the Librayr Project">
83
84 <compc output="${basedir}/${liboutputfolder}/${liboutputfile}">
85
86 <!--
87 Include the path to any external SWC files used in our document, you may have to place name of SWC (corelib.swc) at end of path
88 I didn't inlcude it because I didn't want to redistribute the corelib.swc. So file path would be file="${basedir}/${libpath}/corelib.swc"
89 -->
90 <include-libraries file="${basedir}/${libpath}/" />
91
92 <source-path path-element="${basedir}/${domainextensions}" />
93
94 <!-- include our Class packages into the build (com folder) -->
95 <include-sources dir="${basedir}/${domainextensions}" includes="*" />
96
97 </compc>
98
99 <echo>SWC created</echo>
100
101 </target>
102
103</project>
1<?xml version="1.0" encoding="utf-8"?>
2
3<!-- Flex Library Project ASDocs -->
4
5<project name="ASDocsTest" default="compile" basedir=".">
6
7 <!-- import our build properties file -->
8 <property file="./build.properties" />
9
10 <!-- Flex Ant Tasks used to perform compc and mxml compiling more info at http://labs.adobe.com/wiki/index.php/Flex_Ant_Tasks -->
11 <taskdef resource="flexTasks.tasks" classpath="${basedir}/flexTasks/lib/flexTasks.jar" />
12
13 <target name="setup" description="perform an setup operations"/>
14
15 <!-- Execute the ASDoc Compile wich runs 3 seperate tasks in a series -->
16 <target name="compile" description="series of tasks to create docs and swc">
17
18 <antcall target="cleanDir" description="clean the docs directory"/>
19
20 <antcall target="asDocs" description="full build of asdocs"/>
21
22 <antcall target="buildSWC" description="build the SWC file"/>
23
24 </target>
25
26 <target name="deploy" description="perform an deployment operations"/>
27
28 <target name="install" description="perform an installation operations"/>
29
30 <!--
31
32 DELETE the existing output folder and files and then re-generate the output folder
33
34 -->
35
36 <target name="cleanDir" description="DELETE the existing output folder and files and then re-generate the output folder">
37
38 <delete dir="${basedir}/${docsoutputfolder}" failOnError="true" includeEmptyDirs="true"/>
39
40 <mkdir dir="${basedir}/${docsoutputfolder}"/>
41
42 <!-- echo dumps output to the console window -->
43 <echo>doc directory cleaned</echo>
44
45 </target>
46
47
48 <!--
49
50 Run the ASDoc executable and generate the ASDocs to the new output folder
51
52 -->
53
54 <target name="asDocs" description="Run the ASDoc executable and generate the ASDocs to the new output folder">
55
56 <exec executable="${asdoc.exe}" failonerror="true">
57
58 <arg line="-doc-sources ${domainextensions}"/>
59
60 <arg value="-window-title" />
61 <arg value="'${title}'"/>
62
63 <arg value="-output" />
64 <arg value="${basedir}/${docsoutputfolder}"/>
65
66 <arg value="-external-library-path" />
67 <arg value="${basedir}/${libpath}" />
68
69 </exec>
70
71 <echo>docs created</echo>
72
73 </target>
74
75 <!--
76
77 Compile the SWC file library including libs folder and the path to our classes, we use compc for library, but we
78 would use mxml for MXML files, check the docs for Flex Ant Tasks, http://labs.adobe.com/wiki/index.php/Flex_Ant_Tasks.
79
80 -->
81
82 <target name="buildSWC" description="Compile the SWC file for the Librayr Project">
83
84 <compc output="${basedir}/${liboutputfolder}/${liboutputfile}">
85
86 <!--
87 Include the path to any external SWC files used in our document, you may have to place name of SWC (corelib.swc) at end of path
88 I didn't inlcude it because I didn't want to redistribute the corelib.swc. So file path would be file="${basedir}/${libpath}/corelib.swc"
89 -->
90 <include-libraries file="${basedir}/${libpath}/" />
91
92 <source-path path-element="${basedir}/${domainextensions}" />
93
94 <!-- include our Class packages into the build (com folder) -->
95 <include-sources dir="${basedir}/${domainextensions}" includes="*" />
96
97 </compc>
98
99 <echo>SWC created</echo>
100
101 </target>
102
103</project>
通过Window-Preferences-Ant-Runtime-Classpath-Ant Home添加如下.jar文件(路径根据实际需要更改)
D:\tools\Adobe\Flex Builder 3 Plug-in\sdks\3.2.0\ant\lib\flexTasks.jar
最后,使用build.xml,Run As-Ant Build即可