tag:support.gradlefx.org,2011-05-23:/discussions/questions/20-captive-air-supportGradleFx: Discussion 2016-08-11T02:32:05Ztag:support.gradlefx.org,2011-05-23:Comment/182628692012-08-24T19:05:11Z2012-08-24T19:05:11ZCaptive AIR support<div><p>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.</p>
<p>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:</p>
<pre>
<code>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']
}</code>
</pre>
<p>which you can then execute with 'gradle airBundle'.<br>
I haven't tested this piece of code (copied the biggest part from
GradleFx code), but it should be something like this.</p></div>Yennick Trevelstag:support.gradlefx.org,2011-05-23:Comment/182628692012-08-30T18:01:41Z2012-08-30T18:01:41ZCaptive AIR support<div><p>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.</p>
<p>Specifically, these are the changes I made:</p>
<p>In GradleFxConvention.groovy, I added the air.captive complex
property and defaulted it to "false" for backward
compatibility:</p>
<pre>
<code>air = [
keystore: "${project.name}.p12",
storepass: null,
applicationDescriptor: "/src/main/actionscript/${project.name}.xml",
includeFileTrees: null,
captive: "false"
]</code>
</pre>
<p>In AirPackage.groovy, I made the following 3 changes:</p>
<p>1) added a new addAirCaptiveOptions() method:</p>
<pre>
<code>private void addAirCaptiveOptions(List compilerOptions) {
if (flexConvention.air.captive == "true") {
compilerOptions.addAll([
"-target",
"bundle"
])
}
}</code>
</pre>
<p>2) I updated the createCompilerArguments() method to call the
newly added method:</p>
<pre>
<code>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
}</code>
</pre>
<p>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.</p>
<p>I hope that documenting these enhancements will be be beneficial
for both GradleFx users and for the excellent GradleFx project.
Enjoy!</p></div>Jeff Wilsontag:support.gradlefx.org,2011-05-23:Comment/182628692012-08-30T18:12:05Z2012-08-30T18:12:05ZCaptive AIR support<div><p>Thanks for sharing Jeff!</p>
<p>I'll probably try to open up all air packaging options by
including<br>
something like additionalAirOptions, similar to how you can
specify<br>
compiler options with additionalCompilerOptions.<br>
The timeout is indeed something we propably should provide a
property for,<br>
I'll make an issue for it on the GradleFx issue page.</p>
<p>-Yennick</p></div>Yennick Trevelstag:support.gradlefx.org,2011-05-23:Comment/182628692014-10-06T06:39:17Z2014-10-06T06:39:18ZCaptive AIR support<div><p>Is this functionality implemented in one of the latest GradleFX
versions?<br>
I would also need to build captive AIR apps.</p></div>plank.michaeltag:support.gradlefx.org,2011-05-23:Comment/182628692014-10-06T07:25:10Z2014-10-06T07:25:10ZCaptive AIR support<div><p>no, it hasn't. Currently we only support standard desktop apps
and mobile apps.</p></div>Yennick Trevels