Running one task for flex compiling Flex code start compiling ant.mxmlc files of others similars tasks defined also

Pawan's Avatar

Pawan

28 Jun, 2017 06:03 AM

Hello, I am compiling my Ant build to gradle build files and I have one section for compiling Flex part converting mxmlc to swf files. I created to tasks in gradle build task task flexopt__compile() and task task flexopt_qtp_compile().

task flexopt_compile(){
println("Calling flexopt_qtp_compile +++ : ")
    //ant.taskdef(resource: "flexTasks.tasks", classpath: resourcePath)
    //<!-- START -ITG 74139 Promote-->
    ant.mxmlc(fork:'true', file:"${src}/workplace/FlexOptimization/PromoteDocument.mxml", output:"${FLEX_QTP_DEPLOY_DIR}/PromoteDocument.swf", services: "${src}/workplace/webContent/WEB-INF/flex/services-config.xml", 'context-root': CONTEXT_ROOT){
        //'license product'("flexbuilder3") "serial-number"("${FLEX_LICENSE_KEY}")    
        //'jvmarg'(value: "-Xms512m -Xmx700m -XX:MaxPermSize=700m -XX:PermSize=512m")
        "load-config"(filename:"${FLEX_HOME}/frameworks/flex-config.xml")
        "load-config"(filename="${FLEX_HOME}/frameworks/air-config.xml")        
        'source-path'('path-element': "${FLEX_HOME}/frameworks")      
        'target-player'('10.0.0')
        "compiler.debug"(false)
        'compiler.include-libraries'(dir:"${src}/workplace/FlexOptimization/", append: true){
            include(name: "libs")
        }
        'compiler.include-libraries'(dir:"${FLEX_HOME}/frameworks", append: true){
            include(name: "libs")
            include(name: "locale/en_US")
        }
        'compiler.include-libraries'(dir:"${src}/workplace/FlexOptimization/libs", append: true){
            include(name: "automation.swc")
            include(name: "automation_agent.swc")
            include(name: "automation_dmv.swc")
            include(name: "qtp.swc")  
        }

  }

AND

task flexopt_qtp_compile(){
println("Calling flexopt_qtp_compile +++ : ")
    //ant.taskdef(resource: "flexTasks.tasks", classpath: resourcePath)
    //<!-- START -ITG 74139 Promote-->
    ant.mxmlc(fork:'true', file:"${src}/workplace/FlexOptimization/PromoteDocument.mxml", output:"${FLEX_QTP_DEPLOY_DIR}/PromoteDocument.swf", services: "${src}/workplace/webContent/WEB-INF/flex/services-config.xml", 'context-root': CONTEXT_ROOT){
        //'license product'("flexbuilder3") "serial-number"("${FLEX_LICENSE_KEY}")    
        //'jvmarg'(value: "-Xms512m -Xmx700m -XX:MaxPermSize=700m -XX:PermSize=512m")
        "load-config"(filename:"${FLEX_HOME}/frameworks/flex-config.xml")
        "load-config"(filename="${FLEX_HOME}/frameworks/air-config.xml")        
        'source-path'('path-element': "${FLEX_HOME}/frameworks")      
        'target-player'('10.0.0')
        "compiler.debug"(false)
        'compiler.include-libraries'(dir:"${src}/workplace/FlexOptimization/", append: true){
            include(name: "libs")
        }
        'compiler.include-libraries'(dir:"${FLEX_HOME}/frameworks", append: true){
            include(name: "libs")
            include(name: "locale/en_US")
        }
        'compiler.include-libraries'(dir:"${src}/workplace/FlexOptimization/libs", append: true){
            include(name: "automation.swc")
            include(name: "automation_agent.swc")
            include(name: "automation_dmv.swc")
            include(name: "qtp.swc")  
        }
    
  }

My problem is when I run task flexopt_compile () code gets compiles generate SWF files but other task code flexopt_qtp_compile() also started getting compiled SWF files. What I want is only one task execute and generate the SWF files but I my case both SWF files are generating. Pleas help on this

  1. Support Staff 1 Posted by Yennick Trevels on 28 Jun, 2017 05:01 PM

    Yennick Trevels's Avatar

    oh, you're manually calling the mxmlc compiler via ant. In that case you might not even need GradleFx (GradleFx is there so you shouldn't have to do this, by providing an abstraction layer over mxmlc/compc)

    Am I right in the assumption that you only need one SWF output file?
    I can't see a difference between these two tasks, except their name. Any reason why you've defined two very similar tasks?

  2. 2 Posted by Pawan on 29 Jun, 2017 03:16 AM

    Pawan's Avatar

    Actually I do not know much history why these two separate tasks are created. I have about 15 mxml files that need to be compiled(It just one sample example 15 in one task).Is there any way to run these tasks independently. One task generate one set only not both anyway to achive this.

    Also I have seem mostly single mxml compiling example in GradleFx but if We have 15 mxml files how to compile all these files. Also i do not only need swf files. I need swf, swf.cache ,html files for all these 15 mxml files.

  3. Support Staff 3 Posted by Yennick Trevels on 29 Jun, 2017 07:43 PM

    Yennick Trevels's Avatar

    When you have to compile multiple swf files, it's generally recommended to make a multi-project build. So splitting up the code into multiple submodes.

    An example of such a multi-project build is this: https://github.com/GradleFx/GradleFx-Examples/tree/master/multiproj...
    This one has a module for a client (which compiles to a swf) and two library modules (which compile to a swc)

  4. 4 Posted by Pawan on 30 Jun, 2017 05:39 AM

    Pawan's Avatar

    I need to compile my flex code using product name and key , How can I add this information to my gradlefx file so that I can compile my code successfully using license (product_name license_key)

    This is corresponding ant build code
     <license product="flexbuilder3" serial-number="${flex_license}"/>, how to use in gradle

  5. Support Staff 5 Posted by Yennick Trevels on 02 Jul, 2017 11:39 AM

    Yennick Trevels's Avatar

    GradleFx exposes an "additionalCompilerOptions" property which allows you to provide any of the mxmlc or compc compiler options. For the license it would look something like this:

    additionalCompilerOptions = [
      '-license',
      'flexbuilder3',
      '${flex_license}'
    ]
    
  6. 6 Posted by Pawan on 03 Jul, 2017 04:11 AM

    Pawan's Avatar

    Thanks Yennick for the replies.Its really helpfull.
    Regarding license how we can use this license (product_name license_key) in this task --> ant.mxmlc(fork:'true', file:"${src}/workplace/FlexOptimization/PromoteDocument.mxml", output:"${FLEX_DEPLOY_DIR}/PromoteDocument.swf", services: "${src}/workplace/webContent/WEB-INF/flex/services-config.xml", 'context-root': CONTEXT_ROOT){
    //
    //
    //
    }

  7. Support Staff 7 Posted by Yennick Trevels on 03 Jul, 2017 06:17 AM

    Yennick Trevels's Avatar

    I think something like:

    ant.mxmlc(...){
        license(product_name: "flexbuilder3", license_key: "${flex_license}")
    }
    

    With the ant mxmlc task (which is not related to GradleFx) you basically just pass the compiler options right into it. It's sort of the equivalent of GradleFx's additionalCompilerOptions.

  8. 8 Posted by Pawan on 03 Jul, 2017 06:23 AM

    Pawan's Avatar

    Thanks for the reply actually when I add like this

    ant.mxmlc(){
         license(product_name: "flexbuilder3", license_key: "${FLEX_LICENSE_KEY}")
    }
    

    build fails with below error

    The type doesn't support the "product_name" attribute.

    But If I provide info as this

    ant.mxmlc(){
    additionalCompilerOptions = ['-license','flexbuilder3','${FLEX_LICENSE_KEY}']
    }
    

    Build compiles succesfully

  9. Support Staff 9 Posted by Yennick Trevels on 03 Jul, 2017 06:46 AM

    Yennick Trevels's Avatar

    wait, you're mixing up two things here :)

    Either you use GradleFx, in which case you can use the properties (such as additionalCompilerOptions) exposed by GradleFx to configure your build. In this case GradleFx will call the mxmlc or compc compiler for you.

    Or you use the the mxmlc compiler directly via the Ant task, which is not related to GradleFx in any way, so you can't use GradleFx's properties with it. In this case you would use the mxmlc or compc compiler options. These are defined here in Adobe's documentation:
    mxmlc options compc options

    So to come back to your last comment, using the 'additionalCompilerOptions' won't work with the ant.mxmlc() task. The first form should be closer to what you need, but probably contains a syntax error (I didn't test my example). Maybe try putting some quotes around "license", or its properties (product_name and license_key)

  10. 10 Posted by Pawan on 03 Jul, 2017 06:52 AM

    Pawan's Avatar

    Ok Yennick I tried many options regarding this
    ant.mxmlc(){
         license(product_name: "flexbuilder3", license_key: "${FLEX_LICENSE_KEY}")
    } but I got error everytime did not find a way to add it till now.

    But question is why code is compiling with this option then
    ant.mxmlc(){
    additionalCompilerOptions = ['-license','flexbuilder3','${FLEX_LICENSE_KEY}']
    } and if it is compiling is it makes any meaningful effect .

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac