15 Replies Latest reply on Jun 11, 2014 12:07 AM by wmTiger

    Are Flash builder and command line compiler different?

    Recep Haluk Öngör

      Hi everyone,

       

      I've an Air SDK project which uses resource bundles and compiles fine with the Flash Builder 4.7. However, when I try to compile the same project (with the same options) using the command line compiler or ant, they both fail whining about locale and include-resource-bundles options not being fully supported. How is this possible? Are these two different compilers and if so how am I supposed to compile a resource bundle using BOTH Air SDK and Ant?

       

      Thanks...

        • 1. Re: Are Flash builder and command line compiler different?
          Flex harUI Adobe Employee

          It is the same compiler, but FB passes it extra options under the covers which make it resolve paths to things slightly differently than the command line on occasion.

           

          If you post more details of what the command line output is, folks may be able to assist.

           

          -Alex

          • 2. Re: Are Flash builder and command line compiler different?
            Recep Haluk Öngör Level 1

            Hi Alex,

            I'll try to be more specific: ASC 2 seems to have no issues with resource related options like -locale when used by FB 4.7. When I use code with [ResourceBundle] tags and pass the resource folders to the compiler with -source-path option they're compiled in to the swf. I can verify their presence by checking a link report file: e.g: en_US$collections class is compiled. (I know it is used by flex collections, I've added them to the compilation explicitly. Let me be clear; this is not a flex post).

             

            Then, when I try to compile the same project using ant I get:

            [air:mxmlc] Error: Unable to resolve resource bundle 'collections'

            [air:mxmlc]   [ResourceBundle("collections")]

            [air:mxmlc]   ^

            [air:mxmlc] command line

            [air:mxmlc] Warning: 'compiler.locale' is not fully supported.

             

            I don't think that this is a path issue since all my ant paths are absolute.

             

            (I thought I had a solution using -Dlocale, turned out not working. So I'm deleting my previous post)

             

            So my question boils down to: If FB ant mxmlc compilers are the same; what are the necessary steps to compile resource bundles using mxmlc just like FB compiler does?

            • 3. Re: Are Flash builder and command line compiler different?
              Flex harUI Adobe Employee

              Looks more like a library-path issue if you are trying to use the collections bundle from the SWCs.

               

              FB puts a library path that uses the token.  Check your project properties under library-paths.  Do you have something like that in your ant script?

              • 4. Re: Are Flash builder and command line compiler different?
                Recep Haluk Öngör Level 1

                Hi Alex,

                May be I've should've stated that this is coming from a seasoned Flex/AS3 developer

                 

                Here is a setup to illustrate my problem:

                • Create a new actionscript project called Dummy
                • In the project create a folder named "locale/en_US"
                • Create a file named "mybundle.properties" in that folder
                • add "test=test" line to the file.
                • Add the folder to the source path: locale/{locale}
                • Add "-link-report=linkreport.xml" to your compile arguments.
                • Update Dummy.as so it has [ResourceBundle("mybundle")] before class definition and save.

                 

                If you have automatic builds, you now should have Dummy.swf in your bin-debug folder and a linkreport.xml in which you can verify class "en_US$mybundle_properties": The project compiles fine!

                 

                Now let's do the same thing in ant:

                • Create a build.xml:

                <?xml version="1.0" encoding="UTF-8"?>

                <project name="project" default="default">

                          <target name="default">

                                    <property name="AIR_SDK_HOME" location="/Applications/Adobe Flash Builder 4.7/eclipse/plugins/com.adobe.flash.compiler_4.7.0.349722/AIRSDK" />

                                    <taskdef resource="flexTasks.tasks"

                                                                 classpath="${AIR_SDK_HOME}/ant/lib/flexTasks.jar" />

                                    <mxmlc file="${basedir}/src/Dummy.as"

                                           output="${basedir}/Dummy.swf">

                                              <locale>${locale}</locale>

                                              <source-path path-element="${basedir}/locale/{locale}" />

                                              <source-path path-element="${basedir}/src" />

                                              <link-report>link-report.xml</link-report>

                                    </mxmlc>

                          </target>

                </project>

                • Right click file and select "Run as/2 Ant Build"; build options window should open.
                • In the JRE tab add the "-Dlocale=en_US" and "-Dconfigname=air" to the vm arguments.
                • Click Run.

                 

                Build fails:

                default:

                    [mxmlc] Loading configuration: /Applications/Adobe Flash Builder 4.7/eclipse/plugins/com.adobe.flash.compiler_4.7.0.349722/AIRSDK/frameworks/air-config.xm l

                    [mxmlc] /Users/rhalukongor/Projects/Dummy/src/Dummy.as:12

                    [mxmlc] Error: Unable to resolve resource bundle 'mybundle'

                    [mxmlc] [ResourceBundle("mybundle")]

                    [mxmlc] ^

                    [mxmlc] command line

                    [mxmlc] Warning: 'compiler.locale' is not fully supported.

                 

                Hmm may be I'm missing some configuration FB has. Let's dump config and retry:

                • Add the "-dump-config=config.xml" option to the compiler arguments in the project properties.
                • Replace everything in the mxmlc tag with the: <load-config filename="${basedir}/bin-debug/config.xml" />

                 

                Build still fails with a longer list of warnings.

                 

                Ok, may be ant task wasn't ment to be used. Let's go command-line:

                 

                • Replace the default task with the:

                <target name="default">

                                    <property name="AIR_SDK_HOME" location="/Applications/Adobe Flash Builder 4.7/eclipse/plugins/com.adobe.flash.compiler_4.7.0.349722/AIRSDK" />

                                    <java jar="${AIR_SDK_HOME}/lib/mxmlc-cli.jar" fork="true">

                                              <jvmarg value="-Xmx512m"/>

                                              <jvmarg value="-Dsun.io.useCanonCaches=false"/>

                                              <jvmarg value="-Dflexlib=${AIR_SDK_HOME}/frameworks"/>

                                              <arg value="+configname=air" />

                                              <arg value="-locale"/>

                                              <arg value="en_US"/>

                                              <arg value="-source-path"/>

                                              <arg value="${basedir}/src" />

                                              <arg value="-source-path"/>

                                              <arg value="${basedir}/locale/{locale}" />

                                              <arg value="-output"/>

                                              <arg value="Dummy.swf"/>

                                              <arg value="${basedir}/src/Dummy.as" />

                                    </java>

                          </target>

                 

                Build again fails:

                [java] Error: Unable to resolve resource bundle 'mybundle'

                     [java] [ResourceBundle("mybundle")]

                     [java] ^

                     [java] command line

                     [java] Warning: 'compiler.locale' is not fully supported.

                 

                Ok let's load the dumped config:

                 

                <java jar="${AIR_SDK_HOME}/lib/mxmlc-cli.jar" fork="true">

                                              <jvmarg value="-Xmx512m"/>

                                              <jvmarg value="-Dsun.io.useCanonCaches=false"/>

                                              <jvmarg value="-Dflexlib=${AIR_SDK_HOME}/frameworks"/>

                                              <arg value="+configname=air" />

                                              <arg value="-load-config" />

                                              <arg value="${basedir}/bin-debug/config.xml" />

                                              <arg value="${basedir}/src/Dummy.as" />

                                    </java>

                 

                Build fails...

                 

                I hope I made it pretty clear this time. If the compilers are the same (and if I'm not missing something pretty obvious) there is inconsistency between how Flash Builder and ant tasks/mxmlc handles stuff when it comes to resource bundles.

                 

                How am I supposed to compile a resource bundle in a CI environment? Any ideas?

                • 5. Re: Are Flash builder and command line compiler different?
                  Flex harUI Adobe Employee

                  Is core.swc in the library path?

                  • 6. Re: Are Flash builder and command line compiler different?
                    Recep Haluk Öngör Level 1

                    In my project; yes. For the above setup; I think by default air-config should include it also.

                    • 7. Re: Are Flash builder and command line compiler different?
                      Flex harUI Adobe Employee

                      I just noticed you appear to be running the compiler from an AIR SDK rather than a Flex SDK, and that AIR SDK compiler may not know how to do some Flex things.  I assumed you were running MXMLC from a Flex SDK's lib folder.

                       

                      -Alex

                      • 8. Re: Are Flash builder and command line compiler different?
                        Recep Haluk Öngör Level 1

                        That's the part I don't understand. If compiling a resource bundle is a Flex thing, how come Flash Builder using AIR SDK can do that, yet mxmlc can't. The compilers should be somehow different; my initial question remains.

                         

                        Should resource bundles be a Flex thing? Seriously? Adobe's new vision for the flash eco-system is gaming and video, right? I can not event think any of these without localization and cutting out an existing feature; wow...

                         

                        Another problem is: FB's ability to compile RB's drove me to the illusion of "Yes that's doable", and I've structured the project around RB's. Now, just after hitting the brick when it came to CI, I have to explain this to my boss and co-workers. I know I should have tested; well, I'm noting these in case it helps someone.

                         

                        Anyway, I beileve my current options are:

                        • Wait for some miracle solution from someone
                        • Use Flex SDK to compile RB's in CI env: I don't want to do that because the build script should download both SDK's.
                        • Use Flex SDK to manually compile RB's and treat them as any other swc artifact: That would really slow down programmers; they'd have to upload every change to the artifact repo and download back.
                        • Use Ant (or someother tool) to pre-compile .properties files into .as files extending ResourceBundle: It seems easy for strings, a bit harder for ClassReference and Embeds bu doable.

                         

                        I think I favor 3rd and the 4th options but really open to suggestions...

                        Thanks,

                         

                        Haluk

                        • 9. Re: Are Flash builder and command line compiler different?
                          Flex harUI Adobe Employee

                          If you run the ASC2.0 compiler, it isn't clear that it supports Flex concepts like Resources.  But I still don't understand your configuration enough to give a definite answer.  Are you saying that in Flash Builder you can create an ActionScript-only project for AIR and use resource bundles and it works but you think you are calling the same compiler from the command line and that doesn't work?  I'm not clear for AS-only projects whether FB calls the SDK's mxmlc or not.  It may not.

                           

                          The Flex resource sub-system is not lightweight or fast so it wouldn't be my first choice for games.

                          • 10. Re: Are Flash builder and command line compiler different?
                            Flex harUI Adobe Employee

                            I downloaded the 3.9 AIR SDK and ran its bin/amxmlc on an AS-only project with resources and it worked for me.

                            • 11. Re: Are Flash builder and command line compiler different?
                              Recep Haluk Öngör Level 1

                              Hi Alex,

                              Flex harUI wrote:

                               

                              Are you saying that in Flash Builder you can create an ActionScript-only project for AIR and use resource bundles and it works but you think you are calling the same compiler from the command line and that doesn't work?

                              Exactly.

                              Flex harUI wrote:

                               

                              The Flex resource sub-system is not lightweight or fast so it wouldn't be my first choice for games.

                              Our game is a UI heavy, and a "not so action-packed" one. Localization is really important for us. I wouldn't recommend it for any other game either. (BTW I do not beileve it is not lightweight when you don't use ResourceManager, but bundles only. I beileve compile time resources are much better than runtime string parsing etc. That's another discussion anyway).

                              Flex harUI wrote:

                               

                              I downloaded the 3.9 AIR SDK and ran its bin/amxmlc on an AS-only project with resources and it worked for me.

                              Well, that means I'm obviously missing something (probably silly) here since I also downloaded 3.9 and still facing the same issues. I posted the simplest build I could imagine above (see Post #4). Can you tell the difference considering that and your build? I'd also appreciate if you'd post yours here.

                               

                              Thanks...

                              • 13. Re: Are Flash builder and command line compiler different?
                                Recep Haluk Öngör Level 1

                                Flex harUI wrote:

                                 

                                I posted the project here: ASOnlyWithResources.zip<http://people.apache.org/~aharui/ASOnlyWithResources.zip

                                 

                                Thanks Alex,

                                Obviously this is a working configuration in FB but I was wondering your build file actually; that's the part I'm having trouble with.

                                 

                                Also my build is for web; not mobile (for now). I'm not sure if that makes any difference though.

                                • 14. Re: Are Flash builder and command line compiler different?
                                  Flex harUI Adobe Employee

                                  I then ran the AIR SDK's bin/amxmlc with the source path of the resource bundles and it worked.

                                  • 15. Re: Are Flash builder and command line compiler different?
                                    wmTiger

                                    I had the same problem. Did you solve the right problem?