merged dependency doesn't work for swcAir

wenslayer's Avatar

wenslayer

26 Feb, 2015 07:53 PM

I'm attempting to migrate an existing Ant build to Gradle, but I'm having difficulty when trying to use swcAir dependencies that I don't experience when using just swc dependencies.

Files involved:

$ find * -type f
build.gradle
proj1/src/main/actionscript/org/gradle/example/simple/HelloWorld1.as
proj2/src/main/actionscript/org/gradle/example/simple/HelloWorld2.as
settings.gradle
Settings file:
include 'proj1', 'proj2'

Build.gradle:

buildscript {
    repositories { mavenCentral() }
    dependencies { classpath group: 'org.gradlefx', name: 'gradlefx', version: '1.1' }
}
subprojects {
    apply plugin: 'gradlefx'
    flexHome = "$System.env.AIR_SDK_HOME"
    type = 'swc'
}
project(':proj2') {
    dependencies {
        merged project(':proj1')
    }
}
The example source code in question:
$ cat proj?/src/main/actionscript/org/gradle/example/simple/HelloWorld?.as
package org.gradle.example.simple
{
    public class HelloWorld1 {
        private var _foo : int = 1;
    }
}
package org.gradle.example.simple
{
    public class HelloWorld2 extends HelloWorld1 {
        private var _foo : int = 2;
    }
}

OK, let's compile:

$ gradle -i compile
...
Compiling with compc_cli
    -load-config+=/tmp/air_16_mac/frameworks/flex-config.xml
    -source-path+=/tmp/repro/proj2/src/main/actionscript
    -include-sources+=/tmp/repro/proj2/src/main/actionscript
    -library-path+=/tmp/repro/proj1/build/proj1.swc
    -output=/tmp/repro/proj2/build/proj2.swc
[compc-cli.jar] Loading configuration: /tmp/air_16_mac/frameworks/flex-config.xml
1916 bytes written to /tmp/repro/proj2/build/proj2.swc in 1.252 seconds
...

Ok, that worked as expected, as we can see by the resulting .swc files:

$ find * -type f -name *.swc
proj1/build/proj1.swc
proj2/build/proj2.swc

Let's clean, and modify the type from 'swc' to 'swcAir':

$ gradle -q clean
$ cat build.gradle | grep type
    type = 'swcAir'

Compiling with swcAir:

$ gradle -i compile
...
Compiling with compc_cli
    -load-config+=/tmp/air_16_mac/frameworks/air-config.xml
    -source-path+=/tmp/repro/proj2/src/main/actionscript
    -include-sources+=/tmp/repro/proj2/src/main/actionscript
    -output=/tmp/repro/proj2/build/proj2.swc
[ant:java] Java Result: 2
:proj2:compileFlex FAILED
:proj2:compileFlex (Thread[main,5,main]) completed. Took 1.829 secs.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':proj2:compileFlex'.
> java.lang.Exception: compc_cli execution failed: Loading configuration: /tmp/air_16_mac/frameworks/air-config.xml
  /tmp/repro/proj2/src/main/actionscript/org/gradle/example/simple/HelloWorld2.as:3
  Error: The definition of base class HelloWorld1 was not found.
      public class HelloWorld2 extends HelloWorld1 {
                                       ^
...

So it seems the dependency was not pulled in.

Any advice? Am I doing something wrong? Thanks for any suggestions!

  1. 1 Posted by wenslayer on 26 Feb, 2015 08:12 PM

    wenslayer's Avatar

    For the record, I can manually work around this by replacing the proj1 configuration with:

    project(':proj2') {
        additionalCompilerOptions = ['-library-path+=/tmp/repro/proj1/build/proj1.swc']
    }
    

    However, this feels like a hack.

  2. 2 Posted by wenslayer on 26 Feb, 2015 11:52 PM

    wenslayer's Avatar

    Looking at the code, it appears this problem manifests in LibraryOptionsInjector.groovy.

    The function addLibraries() expects files for its first argument, but addMergedLibraries() passes in project.configurations.merged.files, and for swcAir types, that translates to /path-to/proj1/build/proj1.swcAir, which doesn't make sense (it should just be /path-to/proj1/build/proj1.swc).

    So I believe the fix involves correcting how files are constructed for the project when the type is swcAir, or doing that mapping in LibraryOptionsInjector.groovy (but that doesn't seem like the right place though).

    I'll investigate the project.configuration.files side of things...

  3. 3 Posted by wenslayer on 27 Feb, 2015 12:46 AM

    wenslayer's Avatar

    I filed issue #166 in GitHub.

  4. Support Staff 4 Posted by Yennick Trevels on 27 Feb, 2015 08:51 PM

    Yennick Trevels's Avatar
  5. Yennick Trevels closed this discussion on 27 Feb, 2015 08:51 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

Recent Discussions

24 Jun, 2017 02:18 PM
10 Jun, 2017 04:16 PM
24 Mar, 2017 07:10 PM
19 Mar, 2017 04:39 AM
22 Jan, 2017 07:46 AM

 

11 Oct, 2016 01:18 PM
20 Sep, 2016 04:36 PM
06 Sep, 2016 08:05 PM
03 Aug, 2016 11:15 AM
01 Jun, 2016 05:20 PM
03 May, 2016 09:17 PM