Issues with configPath

Nicolas Estrada's Avatar

Nicolas Estrada

15 Mar, 2013 02:45 PM

Ok, I had many hopes trying to migrate from maven/flex-mojos to gradlefx but it seems as there are still some problems.
I like the idea of providing the flexSDK as a dependancy (so that all developers in our team can use the same one) so I added the artifacts to our repo and adding the following lines as per the doc:

dependencies {
    flexSDK group: 'com.adobe', name: 'flex-sdk', version: '4.6', ext: 'zip'
}
Things "seem" ok however the following issues need resolution:
- flexHome property is not set - configPath property defaults to 'null/frameworks/flex-config.xml'

Now this is problematic because many of our libraries generate 'swc' files yet depend on the 'air-config.xml' and it seemed impossible to set until I figured out that the flexHome property is lazily set and using this dirty trick I was able to compile the src:

compileFlex {
    doFirst { // Set the load-config to air-config.xml
        fxConvention.additionalCompilerOptions = ["-load-config=$flexHome/frameworks/air-config.xml"]
    }
}
So now we are compiling the source. Next when it comes to testing I was HOPING that the configPath would be the same in order to compile the tests but no it seems since I seem to get the following errors:
[ant:flexunit] Compiling test classes: [<many test as3>]
[ant:null] Loading configuration file C:\Users\nestrada.gradle\gradleFx\sdks\b47504bd1bbf485d6aa8a81136a6806528ba3d96\frameworks\flex-config.xml
:test FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':test'.
> Compilation failed:
So it seems to be using the default configPath. Do you have any suggestions on a possible workaround for this, I noticed several open issues seem to be related to my bug but it seems overall that the configuration of the flex ant tasks seems incomplete.

Thanks for any help

  1. Support Staff 1 Posted by Maxime Cowez on 15 Mar, 2013 03:58 PM

    Maxime Cowez's Avatar

    The flexHome property is not set thing shouldn't happen. But I'm not sure the SDK dependency was designed to be used with pre-Apache versions of the Flex SDK. (@Yennick: if this is the case, it should be clarified in the docs).
    Yennick created this feature: he should be able to provide you with a more precise answer.

    In the meantime perhaps you could try building this with Flex 4.9.x?
    In any case, I'm pretty sure this is not related to the ANT tasks.

  2. Support Staff 2 Posted by Yennick Trevels on 16 Mar, 2013 09:20 AM

    Yennick Trevels's Avatar

    The SDK dependency is designed to be used with pre-Apache version, so that shouldn't be a problem.
    Can you provide me the following information:
    1. operating system (Windows, Mac, Linux)
    2. the version of GradleFx you're using
    3. the version of Gradle you're using
    4. can you do a "gradle compile --info" and post the logs here

    Regarding testing, this is something I will be reworking in the near future. Problem now is that you can't specify any compiler options, it lets FlexUnit do the compilation. So I will be reworking this so that you have the same flexibility as when you do a regular compile.

  3. 3 Posted by Nicolas Estrada on 17 Mar, 2013 01:26 AM

    Nicolas Estrada's Avatar

    I'm running under Windows 7 using CYGWIN and using gradle 1.4 and gradlefx 0.6.4. I've included a really simple zip. As you can see just by running gradle with no arguments the properties are indeed not set (until later).

  4. Support Staff 4 Posted by Yennick Trevels on 17 Mar, 2013 10:09 AM

    Yennick Trevels's Avatar

    Ok, now I see what you mean. But there isn't much we can do about that.
    To install the SDK (and after that set the flexHome property) we need some convention properties, which are initialized by Gradle during its configuration phase. That is why we have to execute our code right after this phase, so we can access these properties.

    So that is why you can't use the flexHome property in a standard way (because that code is processed by Gradle during the configuration phase). You can fix this by using an afterEvaluate block, like this:

     afterEvaluate {
               additionalCompilerOptions = ["-load-config=$flexHome/frameworks/air-config.xml"]
     }
    
  5. Support Staff 5 Posted by Maxime Cowez on 17 Mar, 2013 07:22 PM

    Maxime Cowez's Avatar

    Oh now I get it! (Hey, it's weekend you know!)
    You want to use air-config.xml instead of flex-config.xml.

    Well, it turns out there's a type for that. We have two additional undocumented types: air and mobile.
    They're undocumented because the API for these types is incomplete (another feature that's pretty close on Yennick's roadmap I believe). But they do load the appropriate config file already:

    • type = "air" loads air-config.xml
    • type = "mobile" loads airmobile-config.xml

    So try replacing type = "swc" with type = "air".
    I must warn you that it's been close to a year since I tested these types and a lot has happened to GradleFx in the meantime. And I never ever tested them against FlexUnit integration. So, use at your own risk ;)

  6. Support Staff 6 Posted by Yennick Trevels on 17 Mar, 2013 08:11 PM

    Yennick Trevels's Avatar

    'air' is a documented type though, but it will create a swf, so that's not an option since he wants to use the air config with a swc as output.

  7. Support Staff 7 Posted by Maxime Cowez on 17 Mar, 2013 10:48 PM

    Maxime Cowez's Avatar

    Perhaps we should create an issue for this one then: creating a swc that uses AIR specific API's doesn't strike me as very uncommon. Same goes for mobile.

  8. Support Staff 8 Posted by Yennick Trevels on 18 Mar, 2013 07:33 AM

    Yennick Trevels's Avatar

    It is possible to specify the air config, it's just that the flexHome property isn't initialized during the configuration phase when using the SDK autoinstall. And this is something I can't fix because it needs certain convention properties which are only available after the configuration phase.
    So imo the only solution is either using an afterEvaluate or CompileFlex.doFirst block.

  9. 9 Posted by Nicolas Estrada on 18 Mar, 2013 09:43 AM

    Nicolas Estrada's Avatar

    Thanks for all of your help! I'm going to try the suggestions later today. However one thing I would like to note (and please correct me if I'm wrong) is I feel that the global 'type' property is somewhat clumsy to be able to apply on an entire project.
    I'm currently attempting to migrate many flex/as3 projects to gradle and well I was more hoping that gradlefx could provide a syntax similar to this (which is classic gradle):

    sourceSets {
        testlib
    }
    task testSwc(type: Swc) {
        appendix = 'test'
        from sourceSets.testlib.output
    } ...
    

    Well I'm sure you get the idea, but choosing the final type of artifact/compiling/linking method I think would be clearer if done on source sets rather than the entire project.

    In any case thanks for the reactivity :)

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