Impressions

tyutchev.alex's Avatar

tyutchev.alex

29 Jul, 2013 08:41 AM

Hi! I spent around one week converting flexmojos project to gradleFx. And finally it seems that I succeeded. Build file turned to be twice smaller then mavens pom and generally I am really happy about result. Thank you! Really great. There are couple of things that are missing, I want to list:
1) Filtering of resources. descriptor.xml etc...That was my main struggle.
2) Somehow I got all swf files from Flex SDK in my build deirectory
3) In descriptor.xml initialWindow was specified without path, but to make it work I had to add "build/" in front.
4) It will be really cool, if it will be standard way to specify themes.

Anyway with couple of workarounds I got following build script. If you can check and say, am Idoing something working - it will be great :)

apply plugin: "gradlefx"


ext {
    //Backend
    set('app.protocol', 'http')
    set('appserver.hostname', 'stage')
    set('appserver.port', '8081')

    // Build properties
    set('config.debug', 'true')
    set('clients.versionLabel', '1')
    set('clients.versionNumber', '1')
    set('clients.revisionName', '1')
    set('clients.buildNumber', '1')
    set('installation.suffix', '')
    set('nightly.buildId', '3333')
    set('build.mode.release', 'false')

    set('client.width', '1366')
    set('client.height', '768')
}


type = "air"
version = "0.0.1-SNAPSHOT"
srcDirs = ["src/main/flex"]
localeDir="src/main/locales"
locales=["nb_NO", "en_US"]
mainClass="Client"
playerVersion="11.7"
output="Client${ext["installation.suffix"]}${ext["nightly.buildId"]}"


buildscript {
    repositories {
        mavenCentral() 
    }

    dependencies {
        classpath group: 'org.gradlefx', name: 'gradlefx', version: '0.6.4'
    }
}


repositories {
    mavenLocal()

    add(new org.apache.ivy.plugins.resolver.URLResolver()) {
        name = 'Apache'
        addArtifactPattern 'http://apache.cu.be/flex/[revision]/binaries/[module]-[revision]-bin.[ext]'
    }

    add(new org.apache.ivy.plugins.resolver.URLResolver()) {
        name = 'Adobe Air SDK'
        addArtifactPattern 'http://download.macromedia.com/air/win/download/[revision]/[module].[ext]'
    }
}


dependencies {
    flexSDK group: 'org.apache', name: 'apache-flex-sdk', version: '4.9.1', ext: 'zip'
    airSDK group: 'com.adobe', name: 'AdobeAIRSDK', version: '3.7', ext: 'zip'

    merged group: 'org.graniteds', name: 'granite-gravity-swc', version: '1.2.0_SP1', ext: 'swc'
    merged group: 'org.graniteds', name: 'granite-swc', version: '2.3.2.GA', ext: 'swc'

    merged group: 'org.spicefactory', name: 'parsley-flex4', version: '2.4.1', ext: 'swc'
    merged group: 'org.spicefactory', name: 'spicelib-flex', version: '2.4.0', ext: 'swc'

    merged group: 'com.phidgets', name: 'phidgetlibrary', version: '2.1.7', ext: 'swc'

    merged group: 'xxx.frontend', name: 'common', version: '0.0.1-SNAPSHOT', ext: 'swc'
    merged group: 'xxx.frontend', name: 'datamodel', version: '0.0.1-SNAPSHOT', ext: 'swc'
    merged group: 'xxx.frontend', name: 'common-air', version: '0.0.1-SNAPSHOT', ext: 'swc'
    merged group: 'com.adobe.flex.framework', name: 'osmf', version: '2.0-SNAPSHOT', ext: 'swc'
    merged group: 'com.adobe', name: 'as3corelib', version: '0.92.1', ext: 'swc'
}


sdkAutoInstall {
    showPrompts = true
}

air {
    keystore 'src/main/resources/sign.p12'
    storepass 'xxx'
    applicationDescriptor "$buildDir/descriptor.xml"

    includeFileTrees = [
        fileTree(dir: 'build', includes: [
            'icons/**.*',
            'config.xml',
            'update.xml'
        ])
    ]
}


afterEvaluate {
    additionalCompilerOptions = [
        "-swf-version=20",
        "-library-path+=${flexHome}/frameworks/libs/mobile/",
        "-compiler.fonts.managers=flash.fonts.CFFFontManager",
        "-theme+=${flexHome}/frameworks/themes/Halo/halo.swc",
        "-theme+=${flexHome}/frameworks/themes/Mobile/mobile.swc",
        "-define=CONFIG_VERSION::buildNumber, '${ext["clients.buildNumber"]}'",
        "-define=CONFIG_VERSION::revisionName, '${ext["clients.revisionName"]}'",
        "-define=CONFIG_VERSION::versionNumber, '${ext["clients.versionNumber"]}'",
        "-define=CONFIG_VERSION::versionLabel, '${ext["clients.versionLabel"]}'",
        "-define=CONFIG::debug, '${ext["config.debug"]}'"
    ]
}

task('filterCopy', type: Copy) {
    from("src/main/resources/gradle")
    into "${buildDir}"
    include '**/*.xml'
    filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: project.ext.properties)
    outputs.upToDateWhen { false }
}

compileFlex.dependsOn filterCopy
  1. Support Staff 1 Posted by Yennick Trevels on 29 Jul, 2013 11:12 AM

    Yennick Trevels's Avatar

    Hi! Great to hear your experiences!

    1) Filtering of resources. descriptor.xml etc...That was my main struggle.
    

    That's indeed a good point and something we can certainly add sometime in the future. I'll create a feature request for this on our issue tracker.

    2) Somehow I got all swf files from Flex SDK in my build directory
    

    These are the failover rsl libraries.

    3) In descriptor.xml initialWindow was specified without path, but to make it work I had to add "build/" in front.
    

    I'll have to check this.

    4) It will be really cool, if it will be standard way to specify themes.
    

    There is. You can specify themes as dependencies, like this (or as a file-based dependency):

    theme group: 'my.organization', name: 'fancy-theme', version: '1.0', ext: 'swc'
    

    Your script looks ok to me, so good job :)

  2. Support Staff 2 Posted by Yennick Trevels on 01 Aug, 2013 06:34 AM

    Yennick Trevels's Avatar

    Here's the feature request I created for the resource filtering: https://github.com/GradleFx/GradleFx/issues/99

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