Captive AIR support

Jeff Wilson's Avatar

Jeff Wilson

24 Aug, 2012 06:14 PM

I would like to generate a captive AIR build using GradleFx. To do so, I need to pass the directive "-target bundle" to the adt compiler. The packageAir task action calls createCompilerArguments() method to collect the arguments, which uses the additionalCompilerOptions property. I therefore assume that I should be putting the "-target bundle" directive into the additionalCompilerOptions property.

This approach fails because the mxmlc compiler does not recognize the "-target bundle" directive with the error: "unknown configuration variable 'target'", preventing it from getting the adt compiler.

Is there another way to specify adt compiler directives that is independent of mxmlc directives, or is there an air property that enables captive air compile directives?

  1. Support Staff 1 Posted by Yennick Trevels on 24 Aug, 2012 07:05 PM

    Yennick Trevels's Avatar

    Unfortunately there isn't a build in way to specify these arguments. This is something high on my list to open up the adt compiler options. Right now the AIR support is limited to a standard desktop application.

    What you can do is to write a custom task and call the adt compiler in it (like we do internally in GradleFx), then you have the full freedom. This can look like this:

    task(airBundle) << {
         ant.java(jar: project.flexHome + '/lib/adt.jar',
                    fork: true,
                    timeout: 10000,
                    resultproperty: 'airResultProperty',
                    outputproperty: 'airOutputProperty') {
    
                arg(value: '-package')
                arg(value: '-target')
                arg(value: 'bundle')
            }
    
            if (ant.properties['airResultProperty'] != '0') {
                throw new Exception("Packaging failed: ${ant.properties['antResultProperty']}\n")
            }
    
            println ant.properties['airOutputProperty']
    }
    

    which you can then execute with 'gradle airBundle'.
    I haven't tested this piece of code (copied the biggest part from GradleFx code), but it should be something like this.

  2. 2 Posted by Jeff Wilson on 30 Aug, 2012 06:01 PM

    Jeff Wilson's Avatar

    I ended up by modifying the source for GradleFx 0.5 to add support for captive air packaging. In the modified version, the air complex property now supports a 'captive' property, so adding 'air.captive = "true"' to an air typed build.gradle file results in a captive packaging of the air file.

    Specifically, these are the changes I made:

    In GradleFxConvention.groovy, I added the air.captive complex property and defaulted it to "false" for backward compatibility:

    air = [
        keystore:               "${project.name}.p12",
        storepass:              null,
        applicationDescriptor:  "/src/main/actionscript/${project.name}.xml",
        includeFileTrees:       null,
        captive:                "false"
    ]
    

    In AirPackage.groovy, I made the following 3 changes:

    1) added a new addAirCaptiveOptions() method:

    private void addAirCaptiveOptions(List compilerOptions) {
      if (flexConvention.air.captive == "true") {
        compilerOptions.addAll([
          "-target",
          "bundle"
        ])
      }
    }
    

    2) I updated the createCompilerArguments() method to call the newly added method:

    private List createCompilerArguments() {
      List airOptions = ["-package"]
    
      addAirSigningOptions(airOptions)
      addAirCaptiveOptions(airOptions)
    
      airOptions.addAll([
            new File(project.buildDir.absolutePath, flexConvention.output).absolutePath,
            project.relativePath(flexConvention.air.applicationDescriptor),
            project.relativePath("${project.buildDir}/${flexConvention.output}.${FlexType.swf}")
        ])
    
        addFiles(airOptions)
    
        return airOptions
    }
    

    3) Finally, I removed the timeout parameter from the ant.java call in the packageAir() method. This was after noting that a 60-second timeout was still failing due to the increased time required by adt to complete a captive air packaging.

    I hope that documenting these enhancements will be be beneficial for both GradleFx users and for the excellent GradleFx project. Enjoy!

  3. Support Staff 3 Posted by Yennick Trevels on 30 Aug, 2012 06:12 PM

    Yennick Trevels's Avatar

    Thanks for sharing Jeff!

    I'll probably try to open up all air packaging options by including
    something like additionalAirOptions, similar to how you can specify
    compiler options with additionalCompilerOptions.
    The timeout is indeed something we propably should provide a property for,
    I'll make an issue for it on the GradleFx issue page.

    -Yennick

  4. 4 Posted by plank.michael on 06 Oct, 2014 06:39 AM

    plank.michael's Avatar

    Is this functionality implemented in one of the latest GradleFX versions?
    I would also need to build captive AIR apps.

  5. Support Staff 5 Posted by Yennick Trevels on 06 Oct, 2014 07:25 AM

    Yennick Trevels's Avatar

    no, it hasn't. Currently we only support standard desktop apps and mobile apps.

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

Recent Discussions

24 Jun, 2017 02:18 PM
10 Jun, 2017 04:16 PM
24 Mar, 2017 07:10 PM
19 Mar, 2017 04:39 AM
22 Jan, 2017 07:46 AM

 

11 Oct, 2016 01:18 PM
20 Sep, 2016 04:36 PM
06 Sep, 2016 08:05 PM
03 Aug, 2016 11:15 AM
01 Jun, 2016 05:20 PM
03 May, 2016 09:17 PM