15 Replies Latest reply on Mar 31, 2011 6:08 AM by JabbyPandaUA

    Command line compiling FLEX 4

    Devtron Level 3

      Hello

       

      I am trying to make automated builds for my FLEX project(s).

       

      I have read a few different things but am pretty confused how to approach this in FLEX.

       

      Does anyone have any examples or tips/tricks/hints how to make Flashbuilder compile my project from Windows command line? Or any other approaches?

       

      I would really like to figure out how to do this from DOS.

       

      It's rather easy to use the MSBuild command line tool for my .NET projects. Is there a similar compiler tool that I can use from the command line, for my FLEX 4 project? Hopefully without the need for Ant?

        • 1. Re: Command line compiling FLEX 4
          Devtron Level 3

          Ok, I found this:

          http://help.adobe.com/en_US/flashbuilder/using/WSbde04e3d3e6474c4-59108b2e1215eb9d5e4-8000 .html

           

           

          but the Windows example is very confusing and POORLY commented/explained.

           

          What is this?

           

          set WORKSPACE=%HOMEPATH%\Adobe Flash Builder 

          REM works with either FlashBuilderC.exe or eclipsec.exe
          "C:\Program Files\Adobe\Adobe Flash Builder\FlashBuilderC.exe" ^
              --launcher.suppressErrors ^
              -noSplash ^
              -application org.eclipse.ant.core.antRunner ^
              -data "%WORKSPACE%" ^
              -file "%cd%\build.xml" MyTarget

           

           

          What are the "^" character for? Is that required?

           

          I dont use ANT. Why does this assume you MUST use ANT?

           

          What is "MyTarget" ? Why is it used but not defined? Is that a placeholder for my project name?

           

          So many questions looking at this poor example. SMH.

          • 2. Re: Command line compiling FLEX 4
            Flex harUI Adobe Employee

            ANT is a popular cross-platform build tool.  I would recommend using it.

             

            I don't know for sure, but the "^" probably tells the script that the next

            line is a continuation of the current line.

             

            MyTarget is a target in the ant build.xml script, similar to having targets

            in a .MAK file if you've used MS tools for Windows apps.

             

            You can just use .BAT files.  I do for small projects.  But anything serious

            deserves the power of ANT or something even more powerful.

            • 3. Re: Command line compiling FLEX 4
              Devtron Level 3

              Thanks. The previous example above actually did not compile anything. All it did was invoke FB4 to launch open. I ended up writing a .BAT file using mxmlc.exe.That worked well and I was able to remove some exceptions I intially received by using some library arguments to the .exe.

               

              Then I read your suggestion to try ANT and found an article here:
              http://www.adobe.com/devnet/flex/articles/flex_ant_pt1.html

               

              ^ Which gave a good explanation on how to set this all up (Ant w/ FB). Problem though is that it was built for FlexBuilder3 and the example project is out of date for FB4, so it wasnt useful unless you really dig into it.

               


              Ive poked around with ANT a bit before, so I knew already how to set that up (Environment variables, etc).

               

              Now that I have ANT up and running, I am receiving the same exact build errors I was getting using my .BAT file. So essentially, my ANT work is working equivalently to my working .BAT build script (which was much easier and faster to write than configuring ANT, by the way).

               

              The error I am now stuck on (with both approaches) is:

               


              C:\Workspace\MYSUPERTOPSECRETPROJECT>ant
              Buildfile: C:\Workspace\MYSUPERTOPSECRETPROJECT\build.xml

               

              init:
                 [delete] Deleting directory C:\Workspace\MYSUPERTOPSECRETPROJECT\DEPLOY
                  [mkdir] Created dir: C:\Workspace\\MYSUPERTOPSECRETPROJECT\DEPLOY

               

              compile flex project:
                  [mxmlc] Loading configuration file C:\Program Files (x86)\Adobe\Adobe Flash
              Builder 4\sdks\4.0.0\frameworks\flex-config.xml
                  [mxmlc] C:\Workspace\\MYSUPERTOPSECRETPROJECT\src\monitoring\CheckBoxLegend.mxml: Error: Unable to locate specified base cla
              ss 'mx.charts.Legend' for component class 'monitoring.CheckBoxLegend'.

                  [mxmlc]

               

              BUILD FAILED
              C:\Workspace\\MYSUPERTOPSECRETPROJECT\build.xml:
              17: mxmlc task failed

               

              Total time: 6 seconds

               

               

               

              I was able to remove several other exceptions by enabling the library references explicitly in my ANT XML build script. But this one exception  kinda baffles me because it appears to be a part of the FLEX 4 framework? Why is 'mx.charts.Legend' generating exceptions here?

               

              I read somewhere that maybe this is because the base class signature does not make use of the "package" keyword? Is that true?

               

              How can I work around this? Do I need to get rid of CheckBoxLegend references in my app (completely remove?) and extend my own component beast? I would rather not do that (at the moment) if there is a workaround. Do you know about this? I've heard that the Charting framework stuff doesnt compile with the free open source FLEX compiler? Is this the same issue?? Help!

               

              Thanks!

              • 4. Re: Command line compiling FLEX 4
                injpix Level 3

                I believe the correct terminology is to say, you need to "compile against" those external sources.  In other words, ANT needs to know about these class files that are some how linked from within your project.  Below is part of my ANT script of a Flex Library project of mine.  Noticed the external-library-path and compiler.library-path.

                 

                <compc output="${flash.output.file}" link-report="${report.loc}/${build.groupId}-flash-link-report.xml">
                     
                     <source-path path-element="${src.loc}" />
                     <include-sources dir="${src.loc}">
                          <include name="**/*.as" />
                     </include-sources>
                          
                     <compiler.library-path dir="${src.libs}" append="true">
                          <include name="*.swc" />
                     </compiler.library-path>
                          
                     <external-library-path append="true" dir="${FLEX_HOME}/frameworks/libs">
                          <include name="*.swc" />
                     </external-library-path>
                     <external-library-path append="true" dir="${FLEX_HOME}/frameworks/libs/air">
                          <include name="*.swc" />
                     </external-library-path>
                
                     <compiler.verbose-stacktraces>true</compiler.verbose-stacktraces>
                     <compiler.headless-server>true</compiler.headless-server>
                
                </compc>
                
                • 5. Re: Command line compiling FLEX 4
                  Devtron Level 3

                  ^ Thanks I'll give that a shot. Mine looks rather similar though. But I may be missing "*.swc", Im not sure.

                   

                  Also, I see mx.charts is in the datavisualization.swc in the FLEX framework. Why would it be unhappy about it?

                  • 6. Re: Command line compiling FLEX 4
                    Flex harUI Adobe Employee

                    Make sure there is a datavisualization.swc specififed as one of the

                    libraries.

                    • 7. Re: Command line compiling FLEX 4
                      Devtron Level 3

                      I did try to include the datavisualization.swc but it still gave me the same error. I am not sure I was referencing it correctly though.

                       

                      I copied the SWC to my libs directory, and I did this in my ant task:

                      <compiler.library-path dir="${LIBS_DIR}/datavisualization.swc"/>

                       

                      I am unsure if "compiler.library-path" is correct? I am guessing not? Can I use this more than once in my script? different paths, but multiple entries in my ant task? Or does it use just one library path entry for the build?

                       

                      I had a friend of a friend, who has done this before for some large Flex projects, give some suggestions and he said something about including the Professional License Key for FB4 in the command arguments? Does anyone know about this, and how to accomplish it?

                       

                      I am still trying different library/source path combinations in my task script. I cant tell if I am making any progress because there is always a new reference exception. We have a lot of referenced libraries and resources in our application, so this may take me some time to figure out....

                      • 8. Re: Command line compiling FLEX 4
                        injpix Level 3

                        I noticed that you didn't have the append attribute in that node.  Flag it to true.

                        • 9. Re: Command line compiling FLEX 4
                          Devtron Level 3

                          That doesnt appear to work either.

                           

                           

                          Here is what I got now (two files):

                          # change this to your Flex SDK directory path - BUILD SERVER path should be--> C:\Workspace\flex_sdk_4.1.0.16076
                          FLEX_HOME=C:/Program Files (x86)/Adobe/Adobe Flash Builder 4/sdks/4.0.0

                           

                          # this points to your project's src directory
                          # {$basedir} is a default variable that can be used in any Ant script
                          # and it points to the project's root folder [ Flex_Ant_Tasks ] in this case
                          SRC_DIR =${basedir}/src

                           

                          # points to the project's libs directory
                          LIBS_DIR =${basedir}/libs

                           

                          # this is the folder we want to publish the swf to
                          DEPLOY_DIR = ${basedir}/DEPLOY

                           

                           

                           

                           

                          <project name="My Super Top Secret Application Build Script" default="compile flex project">

                              <!-- load previously defined configuration properties file -->
                              <property file="build.properties" />
                             
                              <!-- points to our flexTasks.jar we copied to the libs folder to distribute with the project -->
                              <taskdef resource="flexTasks.tasks" classpath="${basedir}/libs/flexTasks.jar"/>
                             
                              <!-- delete and recreate the DEPLOY dir -->
                              <target name="init">
                                  <delete dir="${DEPLOY_DIR}" />
                                  <mkdir dir="${DEPLOY_DIR}" />       
                              </target>
                             
                              <!-- Build and output the Main.swf-->
                              <target name="compile flex project" depends="init">
                                  <mxmlc file="${SRC_DIR}/MySuperTopSecretApplication.mxml" output="${DEPLOY_DIR}/MySuperTopSecretApplication.swf">
                                      <load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
                                      <source-path path-element="${FLEX_HOME}/frameworks"/>
                                      <source-path path-element="${SRC_DIR}"/>
                                      <source-path path-element="${LIBS_DIR}"/>
                                      <compiler.library-path dir="${LIBS_DIR}/ds_release.swc" append="true" />
                                      <compiler.library-path dir="${LIBS_DIR}/datavisualization.swc" append="true" />
                                      <compiler.library-path dir="${SRC_DIR}/com/as3xls/as3xls-1[1].0.swc" append="true" />
                                     
                                      <compiler.debug>true</compiler.debug>           
                                      <license product="flashbuilder4" serial-number="0000-0000-0000-0000-0000-0000"/>
                                  </mxmlc>
                              </target>
                             
                          </project>

                           

                           

                           

                          I get the same error on the mx.charts library not having a base class or whatever. I am so close I can smell it, but there are a few issues.

                           

                          If i go into my code and remove all references to mx.charts, I get errors related to my .SWC libraries. There is definitely some settings wrong here, but I dont know what. Any ideas?

                          • 10. Re: Command line compiling FLEX 4
                            Flex harUI Adobe Employee

                            I'm no longer sure if you are using ANT or BAT.

                             

                            Don't forget to use quotes in BAT files around paths with spaces in it.

                             

                            There should be some library-path statements in the flex-config.xml you are

                            using.  Make sure datavisualization.swc is covered by those statements.

                             

                            I didn't think there was a licensing issue that prevented compilation, but

                            I'm definitely not the expert there.

                            • 11. Re: Command line compiling FLEX 4
                              Devtron Level 3

                              I am using an ANT task script (XML), posted above.No more .BAT file. (my previous post has the contents of TWO XML files).

                               

                              library-path statements in the flex-config.xml? i'll have to look into that but im not sure what you mean? I am using it in my script there (datavisualization.swc)

                               

                              From what Ive read and gathered, there are some issues preventing compilation of MX.CHARTS. In FLEX3, if you did not provide the serial/key, you would get a watermark on your charts.

                               

                              We talked to a guy that automated FLEX builds at my co-worker's previous job. He mentioned that the license key must be used for charting. Ive looked a bit online and have seen some stuff, but Im not sure if "flashbuilder4" is a valid parameter or not.

                              • 12. Re: Command line compiling FLEX 4
                                injpix Level 3

                                I do remember that a serial number was needed, as you have shown, during the Flex 3 era.  However, in Flex 4 SDK (open-source), there is a charts.swc that contains, I believe those same classes.  You may be able to use this .swc file instead of the one that is in your Flex 3 project.  I also wouldnt think 'flashbuilder4' is a valid value for that parameter.  I would think it would be maybe 'flexbuilder3' or 'charting'.

                                • 14. Re: Command line compiling FLEX 4
                                  Devtron Level 3

                                  I am still stuck on this.

                                   

                                  I noticed the flex-config.xml configuration file in the SDK directory. In it, there is a section of "license" products.

                                   

                                  Here is the current setting:

                                     <!-- licenses: specifies a list of product and serial number pairs. -->
                                     <!-- not set -->
                                     <!--
                                     <licenses>
                                        <license>
                                           <product>string</product>
                                           <serial-number>number</serial-number>
                                        </license>
                                     </licenses>
                                     -->

                                   

                                   

                                   

                                  If I use Flashbuilder4, how do I specify that? I only see flexbuilder3 examples for this. Should I be using flexbuilder3, even though FLEX4 is installed?

                                   

                                  also, how can I specify the charting product? Is it considered a product in Flashbuilder4/Flex4? Does it need to be listed here to make this work? If so, how?

                                   

                                  I have all my .NET projects (all 20 of them) up and running and doing automated builds. This FLEX project is really annoying me.....help?

                                  • 15. Re: Command line compiling FLEX 4
                                    JabbyPandaUA Level 3

                                         It used to be in 2009 that you needed a license number of Flex Builder 3 Professional IDE in order to remove watermark symbol from Flex charting http://stackoverflow.com/questions/1055040/are-flex-charts-available-in-the-free-flex-sdk when used along with Flex 3 SDK.

                                     

                                       But in 2011 you not longer need a license number to use Flex charting in your projects  - "With the release of Flex 4; the "Data Visualization Package" is now part of the free SDK."

                                     

                                       Although you may or you may not run into nasty bug  of  "Ant Compc Task does not append Library namespaces" http://bugs.adobe.com/jira/browse/SDK-27881 .

                                     

                                        Related discussion: http://forums.adobe.com/thread/779701