16 Replies Latest reply on May 7, 2008 11:48 AM by Catar44

    FB 3 vs flexAntTasks

    Catar44
      Greetings everyone.

      I hope someone here can help me. My problem is that we are using two different build tools to build our Flex projects here, Flex Builder 3 in our development environment but we want to use our own custom build tool, using Ant, to build our projects in our "Prod" environment.

      I'm the one developping the build tool, so I thought my choices to emulate Flex Builder 3's builds were either 1) using the "exec" task to launch a command line or 2) using flexAntTasks which are included with Flex 3.0.0 SDK.

      The root of my problem is this:

      I have a mxml file containing this code

      quote:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:UIComponent xmlns:mx=" http://www.adobe.com/2006/mxml">
      <mx:Model id="requisitionListData" source="../prototype/assets/xml/requisitionListData.xml"/>
      <mx:Model id="candidateListData" source="../prototype/assets/xml/candidateListData.xml"/>
      <mx:Model id="questionListData" source="../prototype/assets/xml/questionListData.xml"/>
      <mx:Model id="searchListData" source="../prototype/assets/xml/searchListData.xml"/>
      <mx:Model id="offersListData" source="../prototype/assets/xml/offerListData.xml"/>
      </mx:UIComponent>


      This code works fine when I am compiling with my ant build scripts ... but if I want to be able to compile using Flex Builder 3 (I am using Flex Builder 3.0 build 3.0.194161) I have to alter my code like this:

      quote:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:UIComponent xmlns:mx=" http://www.adobe.com/2006/mxml">
      <mx:Model id="requisitionListData" source="prototype/assets/xml/requisitionListData.xml"/>
      <mx:Model id="candidateListData" source="prototype/assets/xml/candidateListData.xml"/>
      <mx:Model id="questionListData" source="prototype/assets/xml/questionListData.xml"/>
      <mx:Model id="searchListData" source="prototype/assets/xml/searchListData.xml"/>
      <mx:Model id="offersListData" source="prototype/assets/xml/offerListData.xml"/>
      </mx:UIComponent>


      In other words, when using Flex Builder 3 the path seems to be relative to my flex/src folder but when I am compiling with my Ant build script it seems to be relative to the file being compiled ... is there a way to force the same behavior in my Ant build script than Flex Builder 3's behavior ?

      Thanks in advance for any pointer ... I took a lot of time trying to figure a way to do this, I failed. Am now relying on the community
        • 1. Re: FB 3 vs flexAntTasks
          Ansury Level 3
          I'm coming to the conclusion that Flex Ant tasks "sucks" (can't use custom templates!?)

          This may not be helpful, but why would you want to build on production? I've never figured out why one would do that, we always use the EXACT build that was tested rather than hoping that the special production build was going to work. Maybe this is harder to do if you're not using Java (just build and deploy a single war or ear), but I'd just change the deployment process and avoid the technical problems altogether if at all possible.
          • 2. Re: FB 3 vs flexAntTasks
            riesvantwisk Level 1
            I don't agree with Ansury, I use ant tasks exclusively and without any pain. You can do a lot more with flex ant tasks rather then using the build in compiler. I don't know what Ansury means with (can't use custom templates!?) Since you make your own build environment you can build any template with any JS you like.

            Second I find using ant compiles much faster then using the build in compiler, third it also allows me to deploy in my dev server to test the new code. I also like the fact that I can build anywhere which is specially help-full when doing developments with my colleagues and storing everything in svn.

            Ries




            • 3. Re: FB 3 vs flexAntTasks
              slaingod Level 1
              If you want to use conditional compilation in an automated 'release build' versus 'debug build' way, then ant tasks are the best way presumably. Particularly helpful when in production your swf's and asset images may be stored on a CDN (S3, etc.) so all of your source URL's change.
              • 4. Re: FB 3 vs flexAntTasks
                Catar44 Level 1
                Thanks for the replies but the debate I hoped to trigger was not one of "debug vs release" builds, maybe my question was not precise enough ...

                The fact is we have to use Ant tasks in our build tool, because we do not develop Flex products exclusively and it is way easier to have a custom made build tool for all our different "modules" being built by the same tool which behavior we can totally control and modify as we see fit. That might not be ideal but it's the best we can do with our multiple components using different technologies ... it is interesting for us to develop our prototypes using, in this example, Flex Builder 3 and then reproduce the behavior to make sure we are able to reproduce and control the development process in different environments. It is indeed more complicated but it allows us to automate building and testing on different platforms and allows us to make sure we are also able to deploy in different environments.

                Getting back to the core of my problem which I'll try to explain more clearly:

                My problem is that when telling my Flex component to load a source (an asset such as an image), we have a different behavior in Flex Builder 3 than we have in Flex Ant Tasks ... meaning that when I compile my Flex in Flex Builder 3 the paths for those sources have to be relative to my flex/src folder (in other words, the value of my "source-path" argument) but when using Flex Ant Tasks to compile the paths to those sources have to be relative to the folder in which we find the source file ... am I clearer ? Is this a known issue ? Am I simply missing a command line argument or something (note that we tried to stay as close as possible to the arguments used by Flex Builder) ?

                Thanks again.
                • 5. Re: FB 3 vs flexAntTasks
                  Ansury Level 3
                  What I meant by "custom templates", and correct me if I'm missing something, was regarding the html-wrapper task. I use the mxmlc task and it works okay, so I should have been more specific.

                  My complaint is that the html-wrapper task seems to only allow you to choose from one of a few 'templates':

                  quote:

                  There are six types of HTML wrapper templates that you can generate with the html-wrapper Flex Ant task:

                  Client-side detection only — Provides scripts that detect the version of the client's player and return alternate content if the client's player does not meet the minimum required version.
                  Client-side detection with history — Provides the same scripts as those in the client-side-detection template, but adds history management support.
                  Express installation — Provides scripts that support Express Install.
                  Express installation with history — Provides scripts that support Express Install and history management.
                  No player detection — Provides a basic wrapper.
                  No player detection with history — Provides a basic wrapper with history management support.

                  You determine which template is used by using a combination of the history and template attributes of the html-wrapper task.



                  I've previously asked about/researched this and IIRC I *think* I found an enhancement request filed with Adobe calling out this problem specifically, and I think Adobe staff didn't have much to say about it other than the favorite "deferred". :P

                  Specifically what I'd like to do is have a swf not cache at all (not the best solution), or only download when the swf has changed. For now with Dev I was just trying to use one of those "Cache-Control" or "Pragma" header things to disable swf caching while a final solution is researched. They have to go within the html wrapper, and it seems to me that the person who wrote that livedoc wasn't using Flex Ant Tasks at the time...
                  • 6. Re: FB 3 vs flexAntTasks
                    Catar44 Level 1
                    Please, my problem does not have anything to do with "custom-templates" or the html-wrapper task.

                    I don't mind the conversation slipping in a different directions, but I'm posting this just for people to keep in mind that my personal problem is different and I'm more interested in replies about my own problem :)

                    Or maybe I'm really missing something and the html-wrapper task is linked to my problem (which I currently doubt).

                    Thanks for understanding.
                    • 7. Re: FB 3 vs flexAntTasks
                      riesvantwisk Level 1
                      @Catar44:
                      I don't have the problem with different paths so this let me to believe it might be a setup issue on your end? For teh sake of completeness, this is my version :

                      <!--
                      ! Build the mxml file
                      !-->
                      <target name="main.swf" depends="main.check" unless="main.skip">
                      <mxmlc
                      file="build/swf/${WEBAPP_NAME}.mxml"
                      output="build/swf/${WEBAPP_NAME}.swf"
                      services="ear/main.war/WEB-INF/flex/services-config.xml"
                      context-root="${WEBAPP_CONTEXT_ROOT}"
                      use-network="true"
                      keep-generated-actionscript="false"
                      debug="${FLEX_DEBUG}"
                      locale="${LOCALE}"
                      incremental="true"
                      link-report="link-report.xml"
                      load-externs="${LOADEXTERNS}">

                      <load-config filename="${FLEX_HOME}/frameworks/flex-config.xml" />

                      <!-- List of path elements that form the roots of ActionScript class hierarchies. -->
                      <source-path path-element="${FLEX_HOME}/frameworks" />

                      <source-path path-element="build/swf" />
                      <source-path path-element="flex" />
                      <source-path path-element="${FLEX_PROJECTS}/flex/components" />
                      <source-path path-element="${FLEXLIB}" />
                      <source-path path-element="ear/main.war/locale/{locale}" />

                      <compiler.library-path dir="${FLEX_HOME}/frameworks" append="true">
                      <include name="libs" />
                      <include name="../bundles/{locale}" />
                      </compiler.library-path>

                      <!-- Include framework files -->
                      <compiler.include-libraries dir="${FLEX_PROJECTS}/flex/libs" append="true">
                      <include name="corelib.swc" />
                      </compiler.include-libraries>
                      </mxmlc>
                      </target>


                      as you can see I use multiple source-path elements to poiint to the 'root' (package I can say) if each directory where I have flex modules/components.

                      Ries
                      • 8. Re: FB 3 vs flexAntTasks
                        Catar44 Level 1
                        I have tested this solution (using multiple source-path elements to point to the root packages) and it does not solve my problem ... but if you are saying you can compile in Flex Builder 3 and then compile with Flex Ant Tasks without having to adjust your paths and without receiving this kind of errors:

                        [mxmlc] D:\dev\project\trunk\flex\src\prototype\dataprovider\PrototypeDataProvider.mxml(3): Error: Problem finding external Model: prototype/assets/xml/requisitionListData.xml
                        [mxmlc] <mx:Model id="requisitionListData" source="prototype/assets/xml/requisitionListData.xml"/>

                        Then I'll try some more of what you are doing differently than me, hoping it could solve the issue. Thanks a lot riesvantwisk

                        If someone has other suggestions, I'm still taking them :)
                        • 9. Re: FB 3 vs flexAntTasks
                          Ansury Level 3
                          quote:

                          Originally posted by: Catar44
                          Or maybe I'm really missing something and the html-wrapper task is linked to my problem (which I currently doubt).


                          No they aren't related, we did get off topic here. I think it's a setup issue probably too.. I'm using Flex Ant Tasks and FB and I don't have path issues like this. But I'm also using FB 2 at my current location. I don't use any "../" in my Ant build file so I'm thinking you should focus on eliminating that.

                          I think the way FB works when debugging is it "runs in" the directory that your application mxml is in.
                          I'm not sure who's build file yours is more similar to, but I have a <source-path path-element="[flex root directory here]"/> in my Ant build file, which I would think is how mxmlc is getting a hold of my asset files since I use source paths that start from that directory.

                          If I have time tonight I will see if I can figure out what it's doing...in FB3. You may need to post some of your build file here if that's possible.
                          • 10. FB 3 vs flexAntTasks
                            Catar44 Level 1
                            No worries Ansury, just wanted to make sure newcomers to the discussion would see that too :)

                            Thanks in advance for checking what you can reproduce in Flex Builder 3 ... I remember we didn't have such problems with Flex Builder 2 than we do now with Flex Builder 3 ... it would be useful to me if I knew which version of Flex Builder Ries is using himself cause FB 2 really isn't a good reference for this issue.

                            quote:

                            I don't use any "../" in my Ant build file so I'm thinking you should focus on eliminating that.


                            Me neither. The "../" was in my "PrototypeDataProvider.mxml" file.

                            I have this line in the file which causes the error with my mxmlc task:

                            <mx:Model id="requisitionListData" source="prototype/assets/xml/requisitionListData.xml"/>

                            This line compiles well in Flex Builder 3. In my Ant script I get this error at compile time:

                            PrototypeDataProvider.mxml(3): Error: Problem finding external Model: prototype/assets/xml/requisitionListData.xml
                            [mxmlc] <mx:Model id="requisitionListData" source="prototype/assets/xml/requisitionListData.xml"/>

                            But if I change the line to this in the PrototypeDataProvider.mxml file:

                            <mx:Model id="requisitionListData" source="../prototype/assets/xml/requisitionListData.xml"/>

                            it works well with my Ant mxmlc task (which you can find attached) but not with my Flex Builder 3 (or maybe I'm just missing something about how to make them behave ...). Since Flex Builder uses the Flex SDk as specified by our FLEX_HOME environment variable that can't be the difference ... anyways here's mxmlc task (I know I'm repeating a lot of arguments, this is the "debug" version of my code, normally it's a lot lighter with no useless repetitions ... just wanted to be sure that's not what was missing !)
                            • 11. FB 3 vs flexAntTasks
                              Ansury Level 3
                              (Not thinking well today - what I meant to say was I don't have an issue where I have to change paths when building with Ant.)

                              Would src.flex.dir happen to be something like:
                              /FlexProjectDirectory/src

                              Is ${flex.product.name}.mxml at your TOP level of the Flex project, or within a /src subdirectory?

                              If it is in a src subdirectory, can you move your "main" mxml file out of the /src directory into your root project folder? Seems odd I know, but that's actually how I have at least one project setup (was prob generated that way) and I don't have the ant/FB path issue. If this is the case and you move it I'm thinking it'll eliminate the need for the ../ when building with Ant. Of course I'm not sure how FB3 will react... lol
                              • 12. Re: FB 3 vs flexAntTasks
                                Ansury Level 3
                                quote:

                                Originally posted by: Ansury
                                I think the way FB works when debugging is it "runs in" the directory that your application mxml is in.



                                Yeah this could be wrong the more I think about it, FB may just be running at the top level of the project directory. Ant's mxmlc task may do something like that though. Path issues with FB (3 at least) have always been a major pain. Not gonna talk about css and design view... arg.
                                • 13. Re: FB 3 vs flexAntTasks
                                  riesvantwisk Level 1
                                  CSS in design view works fine here, I use it like this :

                                  <mx:Style source="assets/css/defaults.css" />

                                  And I see this properly in my design view and works just the same in my final swf.

                                  That said, I only debug using remote debug (loading my swf into my application server).

                                  Ries
                                  • 14. Re: FB 3 vs flexAntTasks
                                    Ansury Level 3
                                    I had those problems more during the beta and it was one of those difficult to reproduce things...might have been fixed. Seems to work now but I'm paranoid that it'll just "show up" again some day since that's how it behaved. :p
                                    • 15. Re: FB 3 vs flexAntTasks
                                      Catar44 Level 1
                                      We are currently trying to ajust either our FB 3 or our Ant scripts to make them work, I believe I might have found a solution but I have to test it first ... might not have the time today but I'm dropping an update here anyways.

                                      If my solution doesn't work then I'll try what you guys just suggested.

                                      Thanks again for helping out :)
                                      • 16. Re: FB 3 vs flexAntTasks
                                        Catar44 Level 1
                                        I have, finally, realised that Flex Builder 3 was using its own SDK which is included in its installation ... we had differences between the Flex SDKs that were used by Flex Builder 3 and our Ant build tool.

                                        Right now, we are able to compile in both "environment" ... I feel a little bit stupid not having realised all this before, but thanks a lot to those who took time and efforts to help me ...