Ant task for AS projects with Flash Builder


/ Published in: XML
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <project name="Flex Application using Ant script"
  3. default="compile">
  4.  
  5.  
  6.  
  7. <!-- load previously defined configuration properties file -->
  8. <property file="build.properties"/>
  9.  
  10.  
  11.  
  12. <!-- points to our flexTasks.jar we copied to the libs folder to distribute with the project -->
  13. <taskdef resource="flexTasks.tasks"
  14. classpath="${LIBS_DIR}/flexTasks.jar"/>
  15.  
  16.  
  17.  
  18. <!-- This is what you have to include to be able to use the "foreach" ant task -->
  19. <taskdef resource="net/sf/antcontrib/antlib.xml">
  20. <classpath>
  21. <pathelement location="${LIBS_DIR}/ant-contrib-1.0b3.jar"/>
  22. </classpath>
  23. </taskdef>
  24.  
  25.  
  26.  
  27. <!-- Build and output the Main swf-->
  28. <target name="compile"
  29. depends="init,compileApplication,compileModules,copyImages,copyRSLs">
  30. </target>
  31.  
  32.  
  33.  
  34. <!-- delete and create the DEPLOY directory again -->
  35. <target name="init">
  36. <delete dir="${DEPLOY_DIR}"/>
  37. <mkdir dir="${DEPLOY_DIR}"/>
  38. </target>
  39.  
  40.  
  41.  
  42. <!-- Compile Application file -->
  43. <target name="compileApplication">
  44. <mxmlc file="${SRC_DIR}/${APPLICATION_FILE}.mxml"
  45. output="${DEPLOY_DIR}/${APPLICATION_FILE}.swf"
  46. actionscript-file-encoding="UTF-8"
  47. keep-generated-actionscript="false"
  48. debug="false
  49. link-report="c:/link-report.xml">
  50.  
  51.  
  52.  
  53. <load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
  54. <source-path path-element="${FLEX_HOME}/frameworks"/>
  55. <library-path dir="${LIBS_DIR}"
  56. append="true">
  57. <include name="*.swc"/>
  58. </library-path>
  59.  
  60.  
  61.  
  62. <!-- Using Runtime Shared Libraries -->
  63. <runtime-shared-library-path path-element="${FLEX_FRAMEWORK}/framework.swc">
  64. <url rsl-url="${FRAMEWORK_VERSION}.swz"/>
  65. <url rsl-url="${FRAMEWORK_VERSION}.swf"/>
  66. </runtime-shared-library-path>
  67. </mxmlc>
  68. </target>
  69.  
  70.  
  71.  
  72. <!-- Compile Modules -->
  73. <target name="compileModules">
  74. <pathconvert property="flex.modules"
  75. pathsep=",">
  76. <fileset dir="${MODULE_DIR}">
  77. <include name="**/*.mxml"/>
  78. </fileset>
  79.  
  80.  
  81.  
  82. <!-- Strips the module name out of the full path to the module -->
  83. <compositemapper>
  84. <mapper type="regexp"
  85. from="^(.*)[\\|/](.*)(\.mxml)$$"
  86. to="\2"/>
  87. </compositemapper>
  88. </pathconvert>
  89.  
  90.  
  91.  
  92. <echo>Modules that are found in current project are: ${flex.modules}</echo>
  93.  
  94.  
  95.  
  96. <!-- Calls the "compileModule" target and gives it the parameter "moduleName" -->
  97. <foreach list="${flex.modules}"
  98. delimiter=","
  99. parallel="false"
  100. param="moduleName"
  101. trim="true"
  102. target="compileModule"/>
  103.  
  104.  
  105.  
  106. </target>
  107.  
  108.  
  109.  
  110. <target name="compileModule">
  111. <echo>Compiling ${moduleName} ...</echo>
  112.  
  113.  
  114.  
  115. <!-- Get the package path to the module from the full path -->
  116. <pathconvert property="module.path"
  117. pathsep=",">
  118.  
  119.  
  120.  
  121. <fileset dir="${MODULE_DIR}">
  122. <include name="**/*.mxml"/>
  123. </fileset>
  124.  
  125.  
  126.  
  127. <compositemapper>
  128. <mapper type="regexp"
  129. from="^(.*)[\\|/](src)[\\|/](.*)[\\|/](${moduleName}\.mxml)$$"
  130. to="\3"/>
  131. </compositemapper>
  132. </pathconvert>
  133.  
  134.  
  135.  
  136. <mxmlc file="${MODULE_DIR}/${moduleName}.mxml"
  137. output="${DEPLOY_DIR}/${module.path}/${moduleName}.swf"
  138. actionscript-file-encoding="UTF-8"
  139. keep-generated-actionscript="false"
  140. optimize="true"
  141. debug="false"
  142. incremental="false"
  143. load-externs="c:/link-report.xml">
  144. <!-- Get default compiler options. -->
  145. <load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
  146.  
  147.  
  148.  
  149. <!-- List of path elements that form the roots of ActionScript class hierarchies. -->
  150. <source-path path-element="${FLEX_HOME}/frameworks"/>
  151. <compiler.source-path path-element="src"/>
  152.  
  153.  
  154.  
  155. <!-- List of SWC files or directories that contain SWC files. -->
  156. <!--<compiler.library-path dir="${FLEX_HOME}/frameworks"
  157. append="true">
  158. <include name="libs"/>
  159. <include name="../bundles/{locale}"/>
  160. </compiler.library-path> -->
  161.  
  162.  
  163.  
  164. <library-path dir="${LIBS_DIR}"
  165. append="true">
  166. <include name="*.swc"/>
  167. </library-path>
  168. </mxmlc>
  169. </target>
  170.  
  171.  
  172.  
  173. <!-- Copy RSLs -->
  174. <target name="copyRSLs">
  175. <copy todir="${DEPLOY_DIR}"
  176. file="${FLEX_HOME}/frameworks/rsls/${FRAMEWORK_VERSION}.swf"/>
  177. <copy todir="${DEPLOY_DIR}"
  178. file="${FLEX_HOME}/frameworks/rsls/${FRAMEWORK_VERSION}.swz"/>
  179. </target>
  180.  
  181.  
  182.  
  183. <!-- Copy Images -->
  184. <target name="copyImages">
  185. <copy todir="${DEPLOY_DIR}/${IMAGE_PATH}">
  186. <fileset dir="${SRC_DIR}/${IMAGE_PATH}"
  187. includes="images/,swf/"/>
  188. </copy>
  189. </target>
  190.  
  191.  
  192.  
  193. </project>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.