Adobe Flex Ant , exec mxmlc , . , , build.xml, , FB3 ( ), , ... , ant -fu , .
<property name="dir.flex.sdk" value="${system.build.flex.sdk}"/>
<property name="dir.flex.home" value="${dir.abc}/flex/sdks/${dir.flex.sdk}"/>
<property name="dir.flex.projects" value="${dir.abcd_plat}/webapp/flexprojects/"/>
<property name="dir.modules" value="${dir.war}/modules/"/>
<property name="FLEX_HOME" value="${dir.flex.home}"/>
<property name="APP_ROOT" value="${dir.war}"/>
<property name="flexc.exe" value="This should be set in the build-${os.family}.xml file"/>
<property name="asdoc.exe" value="This should be set in the build-${os.family}.xml file"/>
<property name="optimizer.exe" value="This should be set in the build-${os.family}.xml file"/>
<property name="flex.mxmlc" value="${dir.flex.home}/bin/${flexc.exe}"/>
<property name="flex.compc" value="${dir.flex.home}/bin/${compc.exe}"/>
<property name="flex.asdoc" value="${dir.flex.home}/bin/${asdoc.exe}"/>
<property name="flex.optimizer" value="${dir.flex.home}/bin/${optimizer.exe}"/>
<property name="flex.options.warnings" value="false"/>
<property name="flex.meta.1" value="-creator 'MyCorp.' -publisher 'MyCorp.'"/>
<property name="flex.meta.2" value="-title MegaProduct -description http://ourURL.com"/>
<property name="flex.meta.props" value="${flex.meta.1} ${flex.meta.2}"/>
<property name="debug.options" value="-optimize=true -debug=false"/>
<property name="common.flex" value="-as3 -target-player=9.0.124 -warnings=${flex.options.warnings}"/>
<property name="license.flex3" value="(put your own here)"/>
<property name="common.fixed" value="-license=flexbuilder3,${license.flex3} -sp ${dir.war} -library-path+=${dir.webinf}/lib"/>
<property name="flex.common.args" value="${flex.meta.props} ${debug.options} ${common.flex} ${common.fixed}"/>
<property name="swf.suffix" value=""/>
<macrodef name="extract-flex-lib" description="For modularizing flex compilation">
<attribute name="swc-lib" default="NOT SET"/>
<sequential>
<copy todir="${dir.war}" preservelastmodified="true">
<zipfileset src="${dir.webinf}/lib/@{swc-lib}.swc">
<patternset>
<include name="library.swf"/>
</patternset>
</zipfileset>
<mapper type="glob" from="library.swf" to="@{swc-lib}-debug.swf"/>
</copy>
<exec executable="${flex.optimizer}" failonerror="true">
<arg line="-keep-as3-metadata='Bindable,Managed,ChangeEvent,NonCommittingChangeEvent,Transient'"/>
<arg line="-input @{swc-lib}-debug.swf -output @{swc-lib}.swf"/>
</exec>
<delete file="@{swc-lib}-debug.swf"/>
</sequential>
</macrodef>
<macrodef name="flexc-mxml" description="For building the flex modules during flex compilation">
<attribute name="name" default=""/>
<attribute name="mxml.args" default="${flex.common.args} ${module.args}"/>
<attribute name="sourcePath" default=""/>
<attribute name="destPath" default=""/>
<sequential>
<echo message=" Compiling with mxmlc: @{name}"/>
<exec executable="${flex.mxmlc}" failonerror="true">
<arg line="@{mxml.args} @{sourcePath} -output @{destPath}"/>
</exec>
</sequential>
</macrodef>
<macrodef name="flexc-subproject" description="For compiling the flex subprojects into .swc files">
<attribute name="name" default=""/>
<attribute name="xtra.args" default=""/>
<sequential>
<echo/>
<echo message=" Compiling subproject: @{name}"/>
<xslt in="${dir.flex.projects}/@{name}/.flexLibProperties" out="${dir.flex.projects}/@{name}/src/manifest.xml" style="${dir.war}/build-manifest-style.xsl"/>
<exec executable="${flex.compc}" failonerror="true">
<arg line="-load-config+=${dir.flex.projects}/@{name}/include-files.xml"/>
<arg line="-namespace http://@{name}.ourURL.com ${dir.flex.projects}/@{name}/src/manifest.xml"/>
<arg line="-include-namespaces http://@{name}.ourURL.com @{xtra.args}"/>
<arg line="-library-path+=${dir.webinf}/lib -sp ${dir.flex.projects}/@{name}/src -output ${dir.webinf}/lib/@{name}.swc"/>
</exec>
</sequential>
</macrodef>
<target name="flexcompile" depends="flexc-modularize" description="Builds the Flex sources" unless="flexc.notRequired.main">
<echo message="Compiling MegaProduct Flex application on OS family: ${os.family}"/>
<echo message=" mxmlc is: ${flex.mxmlc}"/>
<echo message=" compc is: ${flex.compc}"/>
<antcall target="flexc-projects"/>
<antcall target="flexc-main"/>
<antcall target="flexc-foorbars"/>
<html-wrapper title="MyCorp MegaProduct" application="app_name" swf="app_name" history="false" template="express-installation"/>
</target>
<target name="flexc-projects">
<flexc-subproject name="Dockable"/>
<flexc-subproject name="EXRibbon" xtra.args="-source-path+=${dir.flex.projects}/EXRibbon/locale/en_US/"/>
<copy todir="${dir.flex.projects}/MPLib/src/image"><fileset dir="${dir.war}/image"/></copy>
<flexc-subproject name="MPLib"/>
<delete dir="${dir.flex.projects}/MPLib/src/image"/>
</target>
<target name="flexc-main">
<property name="link.report" value="${dir.war}/abc_link_report.xml"/>
<property name="modular.args" value=""/>
<property name="main.args" value="-link-report=${link.report} ${modular.args}"/>
<property name="module.args" value="-load-externs=${link.report}"/>
<echo message="Compiling abc_flex application, sub-applications and modules..."/>
<echo/>
<flexc-mxml name="abc_flex" mxml.args="${flex.common.args} ${main.args}"
sourcePath="${dir.war}/abc_flex.mxml" destPath="${dir.war}/abc_flex${swf.suffix}.swf"/>
<flexc-mxml name="MPMainSubApplication" mxml.args="${flex.common.args} ${main.args}"
sourcePath="${dir.war}/MPMainSubApplication.mxml" destPath="${dir.war}/MPMainSubApplication.swf"/>
<parallel>
<property name="dir.module.src" value="${dir.war}/module/"/>
<flexc-mxml name="module1" sourcePath="${dir.module.src}/editor/Editor.mxml" destPath="${dir.module.src}/editor/Editor.swf" />
<flexc-mxml name="RunModule" sourcePath="${dir.module.src}/run/RunModule.mxml" destPath="${dir.module.src}/run/RunModule.swf" />
<flexc-mxml name="Editor2" sourcePath="${dir.module.src}/edit/Editor.mxml" destPath="${dir.module.src}/edit/Editor.swf" />
</parallel>
</target>
:
, , .swc Java WEB-INF/lib, , flex lib . , . , ; , , , - , - ( ). - linux, flexc.exe( ) - . , , , , n-paste.
In addition, incremental compilation is not actually used; It seems to be buggy. The same goes for modulation materials, so I did not include this goal.
I built it all myself, so I'm pretty proud of it, but if there is something that looks bad or smells bad, please feel free to let me know. Thanks!