2

I am using ant to build my web application. I have a target in my ant script which takes approximately 8 minutes to compile. Since mxmlc compiles everything from scratch and loads up the JVM each time, it is taking a lot of time. Is there a way to optimize this task?

I am using Flex SDK 3.0. Here is my ant target:

<target name="compile.organic.flash" depends="setup">
  <property name="WelcomeBack.swf" value="${www.dir}/swf/as3/apps/welcome/WelcomeBack.swf" />
  <mxmlc file="${AS3.classpath}/com/organic/app/fthb/welcome/src/WelcomeBack.as"
         output="${WelcomeBack.swf}"
         incremental="${mxmlc.inc}"
         default-frame-rate="30"
         accessible="true"
         default-background-color="${swf.backgrond.color}"
         allow-source-path-overlap="true"
         compiler.strict="true">
    <default-size width="940" height="528" />
    <source-path path-element="${Welcome.path}"/>
    <source-path path-element="${AS3.classpath}"/>
  </mxmlc>

  <property name="Welcome.swf" value="${www.dir}/swf/as3/apps/welcome/Welcome.swf" />
  <mxmlc file="${AS3.classpath}/com/organic/app/fthb/welcome/src/Welcome.as"
         output="${Welcome.swf}"
         incremental="${mxmlc.inc}"
         default-frame-rate="30"
         accessible="true"
         default-background-color="${swf.backgrond.color}"
         allow-source-path-overlap="true"
         compiler.strict="true">
    <default-size width="940" height="528" />
    <source-path path-element="${Welcome.path}"/>
    <source-path path-element="${AS3.classpath}"/>
    <compiler.include-libraries dir="${AS3.component}/" >
    </compiler.include-libraries>
  </mxmlc>

  <property name="App.swf" value="${www.dir}/swf/as3/apps/App-${svnVersion}.swf" />
  <mxmlc file="${AS3.classpath}/com/organic/app/fthb/App.as"
         output="${App.swf}"
         incremental="${mxmlc.inc}"
         default-frame-rate="30"
         default-background-color="${swf.backgrond.color}"
         compiler.strict="true">
    <default-size width="300" height="300" />
    <source-path path-element="${AS3.classpath}"/>
    <compiler.include-libraries dir="${AS3.component}/" >
    </compiler.include-libraries>
  </mxmlc>

  <property name="LSOApp.swf" value="${www.dir}/swf/as3/apps/LSOApp-${svnVersion}.swf" />
  <mxmlc file="${AS3.classpath}/com/organic/boa/fthb/LSOApp.as"
         output="${LSOApp.swf}"
         incremental="${mxmlc.inc}"
         default-frame-rate="30"
         default-background-color="${swf.backgrond.color}"
         compiler.strict="true">
    <default-size width="300" height="300" />
    <source-path path-element="${AS3.classpath}"/>
    <compiler.include-libraries dir="${AS3.component}/" >
    </compiler.include-libraries>
  </mxmlc>

  <property name="CheckRates.swf" value="${www.dir}/swf/as3/apps/CheckRates-${svnVersion}.swf" />
  <mxmlc file="${CheckRates.path}/CheckRates.as"
         output="${CheckRates.swf}"
         incremental="${mxmlc.inc}"
         default-frame-rate="40"
         accessible="true"
         default-background-color="${swf.backgrond.color}"
         compiler.strict="true" compiler.allow-source-path-overlap="true" >
    <default-size width="940" height="528" />
    <compiler.source-path path-element="${AS3.classpath}"/>
    <compiler.source-path path-element="${CheckRates.path}"/>
    <!--  <source-path path-element="${AS3.classpath}"/> -->
    <compiler.include-libraries dir="${AS3.classpath}">
    <include name="fl/fl.swc" />
    </compiler.include-libraries>
  </mxmlc>

  <copy file="${AS3.classpath}/com/organic/app/fthb/checkRates/js/config/check_rates_config.js" tofile="${www.dir}/swf/as3/apps/config/check_rates_config.js"/>
  <property name="PointsCalculator.swf" value="${www.dir}/swf/as3/apps/PointsCalculator-${svnVersion}.swf" />
  <property name="flash.apps.build.dir" value="${www.dir}/swf/as3/apps" />
  <compile-flash basename="PointsCalculator" srcdir="${flash.apps.src.dir}/pointsCalculator">
  </compile-flash>
  <copy todir="${flash.apps.build.dir}/config">
    <fileset dir="${flash.apps.src.dir}/pointsCalculator/config" includes="*.js"/>
  </copy>
  <copy todir="${build.dir}/www/css">
    <fileset dir="${flash.apps.src.dir}/pointsCalculator/css" includes="*.css"/>
  </copy>
  <copy todir="${build.dir}/www/swf/as3/apps/welcome/assets/swfs">
    <fileset dir="${flash.apps.src.dir}/welcome/assets/swfs" includes="*.swf"/>
  </copy>
  <copy file="${videoplayer.dir}/videoplayer.swf" tofile="${www.dir}/swf/as3/apps/videoplayer.swf" />
</target>
Eddie
  • 53,828
  • 22
  • 125
  • 145
yesh
  • 2,052
  • 4
  • 28
  • 51
  • Perhaps you could try using the Flex 4.6 compiler. I guess it should compile your Flex 3 project just fine, but faster. – RIAstar Feb 06 '12 at 16:22
  • You mean update my Flex SDK to 4.6 and keep the same build file? Is there a another way to modify the build file without upgrading to Flex 4.6 – yesh Feb 06 '12 at 16:27
  • You don't have to 'upgrade' it: you just keep different versions side by side. – RIAstar Feb 06 '12 at 17:33
  • is it possible to make ant use the Flex SDK 4.6 just for compiling. Using Flex SDK 4.6 will require me to make changes to the code base which I cannot – yesh Feb 07 '12 at 16:44
  • I think so. This is what I would try: point my ANT taskdef to Flex 4.6 ANT tasks instead of those of 3.0. Now your build script should use mxmlc and compc from that version, but we must tell it to be backwards compatible by adding the `-compatibility-version=3.0.0` flag (cf. [docs](http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7ede.html)). Let me know if it works. – RIAstar Feb 07 '12 at 17:13
  • Thanks but it seems I need to set themes and other stuffs. Since I am not the flash developer who build these files I am not sure. I was thinking of using http://bytecode-workshop.com/hfcd/doc/HFCD-Ant-Task-Language-Reference.pdf . What do you think about this. This seems to be an alternate compiler to mxmlc – yesh Feb 07 '12 at 17:34
  • I keep getting this Warning for each MXMLC compile: "This compilation unit did not have a factoryClass specified in Frame metadata to load the configured runtime shared libraries. To compile without runtime shared libraries either set the -static-link-runtime-shared-libraries option to true or remove the -runtime-shared-libraries option" DO U KNOW WHAT THIS IS ? – yesh Feb 07 '12 at 23:23
  • 1) I didn't know about hfcd. The specs sure look interesting, but the problem with this kind of solution is: will it evolve when Flex moves on? 2) Do you get that error when you compile your Flex 3 app with the Flex 4.6 compiler? Anyway, perhaps it's time for a new question. – RIAstar Feb 08 '12 at 09:09

2 Answers2

1

Use fcsh. From the first paragraph of that link

The fcsh (Flex Compiler Shell) utility provides a shell environment that you use to compile Flex applications, modules, and component libraries. It works very similarly to the mxmlc and compc command line compilers, but it compiles faster than the mxmlc and compc command-line compilers. One reason is that by keeping everything in memory, fcsh eliminates the overhead of launching the JVM and loading the compiler classes. Another reason is that compilation results (for example, type information) can be kept in memory for subsequent compilations.

NoobsArePeople2
  • 1,986
  • 14
  • 21
  • That's a shell; can't use fcsh from ANT. – RIAstar Feb 06 '12 at 20:21
  • mxmlc checks out the flex sdk every time it compiles so I just want to know if there is a way to make sure it does not build the sdk every time ? – yesh Feb 06 '12 at 21:24
  • @RIAstar there is a fcsh for ant but I need to write another build script for this, I currently have 5 build scripts running so I am not sure if I will go down this road http://code.google.com/p/fsch/ – yesh Feb 06 '12 at 21:26
0

We found that what was slowing down the compiler was mostly linking assets. We made a library project swf that is just used for assets (images, swfs, etc.) except fonts, and it works a treat.

We have a massive project building under 2 mins from maven.

keyle
  • 2,762
  • 3
  • 24
  • 27