(How) Can I build and create ANE package with gradleFX?

dpeeters's Avatar

dpeeters

26 Aug, 2015 10:14 AM

Hi,

I have a Native extension project for android. Is there a way to build and package this to and .ane file with gradleFX, that I can then use in my other Flex mobile project?
I see I can set the target to 'ane' in the airMobile settings. But I don't know what to do next. With the build file below I can build a swc file, which I can then manually change to an ane by extracting the swf file, putting it in the correct folder structure and using adt to create my ane. Is this already supported in gradleFX?

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath group: 'org.gradlefx', name: 'gradlefx', version: '1.3.1'
    }
}

apply plugin: 'gradlefx'
apply plugin: 'flashbuilder'

type = 'swcAir'
srcDirs = ['/src']

repositories {
    mavenCentral()
    maven {
        url "http://172.16.99.97:8081/nexus/content/groups/public"
    }
}

dependencies {
    merged group: 'org.as3commons', name: 'as3commons-lang', version: '0.3.4', ext: 'swc'   
}

airMobile {
    target = 'ane'
}
  1. Support Staff 1 Posted by Yennick Trevels on 26 Aug, 2015 05:55 PM

    Yennick Trevels's Avatar

    GradleFx currently doesn't support packaging ane files yet, although I think it wouldn't take much to add this since almost all required adt options are supported already, except for two.

    If you're interested in digging a little deeper, let me know and I'll give you some guidelines to get started.

  2. 2 Posted by dpeeters on 27 Aug, 2015 09:08 AM

    dpeeters's Avatar

    Thanks for the reply! :)
    I managed to do it myself creating a new gradle task.
    Here is the code, maybe you still have remarks :)

    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath group: 'org.gradlefx', name: 'gradlefx', version: '1.3.1'
        }
    }
    
    apply plugin: 'gradlefx'
    apply plugin: 'flashbuilder'
    
    type = 'swcAir'
    srcDirs = ['/src']
    
    repositories {
        mavenCentral()
    }
    
    dependencies {
        merged group: 'org.as3commons', name: 'as3commons-lang', version: '0.3.4', ext: 'swc'   
    }
    
    airMobile {
        target = 'ane'
    }
    
    task packageAne(dependsOn: build) { 
        description = 'Creates an ANE package after building the project.'
        def aneDirName = 'ane'
        def androidDirName = 'Android-ARM'
        def jarFileLocation = 'src/eidLibrary.jar'
        def extensionLocation = 'src/extension.xml'
        def swcLibFileLocation = "$buildDir/${project.name}.swc"
        def keystore = "${project.name}.p12"
        def storepass = 'password'
        
        doLast {
            // copy eidLibrary.jar to Android-ARM and unzip library.swf from compiled swc archive to Android-ARM
            // needed directories will be created
            copy {
                from "$projectDir/$jarFileLocation"
                from zipTree("$swcLibFileLocation").matching { include '*.swf'}
                into "$buildDir/$aneDirName/$androidDirName"
            }
            // Copy the built swc and extension.xml
            copy {
                from "$swcLibFileLocation"
                from "$projectDir/$extensionLocation"
                into "$buildDir/$aneDirName/"
            }
            
            // execute adt packaging command
            ant.java(jar: project.flexHome + '/lib/adt.jar', fork: true, timeout: 10000, resultproperty: 'airResultProperty', outputproperty: 'airOutputProperty') {
                arg(value: '-package')
                arg(value: '-storetype')
                arg(value: 'PKCS12')
                arg(value: '-keystore')
                arg(value: "${keystore}")
                arg(value: '-storepass')
                arg(value: "${storepass}")
                arg(value: "-tsa")
                arg(value: 'none')
                arg(value: "-target")
                arg(value: "ane")
                arg(value: "${buildDir}/eid.ane")
                arg(value: "$projectDir/$extensionLocation")
                arg(value: "-swc")
                arg(value: "$buildDir/$aneDirName/${project.name}.swc")
                arg(value: "-platform")
                arg(value: "Android-ARM")
                arg(value: "-C")
                arg(value: "$buildDir/$aneDirName/$androidDirName")
                arg(value: ".")
            }
    
            if (ant.properties['airResultProperty'] != '0') {
                throw new Exception("Packaging failed: ${ant.properties['antResultProperty']}\n")
            }
            println 'Succesfully packaged ane.'
        }
    }
    
  3. Support Staff 3 Posted by Yennick Trevels on 29 Aug, 2015 12:33 PM

    Yennick Trevels's Avatar

    Looks like a solid alternative ;) no remarks really.
    I've created a new feature request on our issue tracker: https://github.com/GradleFx/GradleFx/issues/196

  4. dpeeters closed this discussion on 25 Oct, 2015 11:04 PM.

Comments are currently closed for this discussion. You can start a new one.

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