How to generate a SWC (and use that in a multimodule project)

rafanami's Avatar

rafanami

21 Oct, 2013 09:03 PM

Hey guys, how are you? First of all, thanks for this great build tool.
Currently I'm migrating a medium to big Flex project that is currently relying in FlexMojos.
The main problem is that I have to generate a test swc from the src/test/flex folder, and use that only in test scope.
The second thing - how do I reference it? Just plain test project(':commonTest') ?

Thanks in advance, and Kind Regards
Rafa

  1. Support Staff 1 Posted by Yennick Trevels on 22 Oct, 2013 06:05 AM

    Yennick Trevels's Avatar

    Do you have other sources in src/main/flex? If not, then you can assign the src/test/flex folder to the srcDirs property, like this:

    type = 'swc'
    srcDirs = ['src/test/flex']
    

    Then you can reference it as you suggested, so just "test project(':commonTest')"

  2. 2 Posted by rafanami on 22 Oct, 2013 07:33 PM

    rafanami's Avatar

    Thanks Yennick. I was using includeSources, but I'll try with srcDirs, because it really makes more sense.

    Cheers, keep up the great work!

  3. 3 Posted by rafanami on 22 Oct, 2013 08:15 PM

    rafanami's Avatar

    Hey Yennick, I've tried the srcDirs, but since the test classes uses a test scoped flexunit setup, I have compilation errors. So I'm sticking with the includeSources for now.

    Thanks!

    Rafa

  4. Support Staff 4 Posted by Yennick Trevels on 22 Oct, 2013 08:21 PM

    Yennick Trevels's Avatar

    Normally you can put the FlexUnit libraries on 'external' scope. Then, in the project where you want to use that test swc, include the FlexUnit libraries in 'test' scope.

  5. 5 Posted by rafanami on 27 Nov, 2013 11:16 PM

    rafanami's Avatar

    Hi Yennick, how are you?
    Had to drop this for some time, but now that I have some time to follow it up, it seems that I'm having some problem to compile 2 dependent SWCs.
    I have a layout like this:
    project
    swc1 build.gradle swc2 (depends on swc1) build.gradle swf build.gradle build.gradle
    settings.gradle

    As I'm using the includeSources in the swc1 subproject, It's getting really strange results, because when I do a gradle build, and the build arrives in swc2, there are some compile errors.
    And plus, the size of the swc for swc1 is really tiny compared with the maven counterpart (as I've said earlier, I'm trying to migrate from Maven to GradleFx).

    So far, I was following the same pattern described in the examples for multimodules project.

    the root build.gradle had the following structure

    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath group: "org.gradlefx", name: "gradlefx", version: "0.7.1"
        }
    }
    subprojects {
        apply plugin: "gradlefx"
        apply plugin: "ide"
        version = ext."project.version"
        repositories {
            mavenRepo our local maven repo here
        }
        dependencies {
            merged group: "com.adobe.flex.extras.controls", name: "springgraph", version: "1.0.0", ext: "swc"
            merged group: "com.degrafa", name: "Degrafa", version: "Flex4", ext: "swc"
            merged group: "org.swizframework", name: "swiz-framework", version: "1.0.0", classifier: "RC1", ext: "swc"
            merged group: "org.babelfx", name: "Framework_BabelFx", version: "2.0.1", ext: "swc"
            test group: "com.adobe.flexunit", name: "flexunit", version: "0.90", ext: "swc"
            test files(project.file("../libs/flexUnitTasks-4.1.0.jar").absolutePath,
                    project.file("../libs/flexunit-4.1.0.swc").absolutePath,
                    project.file("../libs/flexunit-cilistener-4.1.0-4.6.0.swc").absolutePath,
                    project.file("../libs/hamcrest-as3-flex-1.1.3.swc").absolutePath)
        }
        flexHome = ext."flex.sdkPath"
        srcDirs = ["/src/main/flex"]
        resourceDirs = ["src/main/resources"]
        testDirs = ["src/test/flex"]
        testResourceDirs = ["src/test/resources"]
        playerVersion = ext."flex.projectPlayerVersion"
        output = name + "-" + version
        jvmArguments = [
                "-Xmx1024m",
                "-Xms1024m"
        ]
    }
    

    for swc1:

    type = "swc"
    includeSources = [ **list of actionscript classes for the testing purposes** ]
    flexUnit {
        command = ext."flex.flashExeCommandPath"
        includes = ["**/*Test.as", "**/Test*.as"]
        verbose = "true"
    }
    dependencies {
        merged group: "flexlib", name: "flexlib", version: "2.4", ext: "swc"
        theme files("${flexHome}/frameworks/themes/Halo/halo.swc")
    }
    

    and for swc2

    type = "swc"
    dependencies {
        merged project(":swc1")
        merged group: "flexlib", name: "flexlib", version: "2.4", ext: "swc"
        theme files("${flexHome}/frameworks/themes/Halo/halo.swc")
    }
    flexUnit {
        command = ext."flex.flashExeCommandPath"
        includes = ["**/*Test.as", "**/Test*.as"]
        verbose = "true"
    }
    

    Thanks in advance, and Kind Regards
    Rafa

  6. Support Staff 6 Posted by Yennick Trevels on 28 Nov, 2013 07:41 AM

    Yennick Trevels's Avatar

    for swc1, can you try this:

    type = "swc"
    srcDirs = ['src/test/flex']
    includeSources = [ **list of actionscript classes for the testing purposes** ]
    flexUnit {
        command = ext."flex.flashExeCommandPath"
        includes = ["**/*Test.as", "**/Test*.as"]
        verbose = "true"
    }
    dependencies {
        merged group: "flexlib", name: "flexlib", version: "2.4", ext: "swc"
        theme files("${flexHome}/frameworks/themes/Halo/halo.swc")
    }
    

    So combine the srcDirs property with the includeSources property. In case you get an error, please post it here.

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

07 May, 2023 04:17 PM
28 Apr, 2023 11:22 PM
23 Apr, 2023 09:43 AM
03 Nov, 2022 01:22 AM
29 Jun, 2022 05:39 PM

 

04 Aug, 2021 12:50 PM
15 Apr, 2021 06:10 PM
15 Jan, 2021 06:56 PM
09 Mar, 2020 11:11 PM
09 Mar, 2020 11:09 PM
17 Apr, 2019 02:51 PM