Transitive dependencies

Pavel Bernshtam's Avatar

Pavel Bernshtam

31 Jan, 2013 06:57 AM

Hi!
Should dependencies be transitive?

I have swf project, which depends on my swc project, which depends on swiz.

However swf project compilation does not see swiz and passes compilation only if I provide to it swiz dependency explicitly

Thank you!

  1. Support Staff 1 Posted by Yennick Trevels on 31 Jan, 2013 07:18 AM

    Yennick Trevels's Avatar

    When you compile your library (swc) project, there are two options:

    • either you use merged or internal and the dependency will be compiled into your swc, which will then give no problems when compiling your swf because the code is already compiled into the swc

    • or you use external. It's basically saying like "I know my library needs this dependency, so I'm giving it the dependency during compilation, but after compilation I'm taking the dependency away and it's up to the swf project to define how it will link to the dependency (which can be merged, internal or rsl)"

    So depending on the type of linking you use in the swc project you have to redefine the dependency with a different scope in the swf project. It just how the Flex compilers work :)

    Also, rsl dependencies (which is typically what swz files are used for) are not supported in library projects, which is again a compc compiler limitation (aka the -runtime-shared-library-path option isn't supported in compc). So in your library project you should define that dependency with scope "external".

  2. 2 Posted by Pavel Bernshtam on 31 Jan, 2013 07:22 AM

    Pavel Bernshtam's Avatar

    Thank you!

    I did it, but still have the same compilation problem.

    Now I have my "common" swc depending on swiz as "external" and my swf depends on "common" swc as "merged". is it correct?

  3. Support Staff 3 Posted by Yennick Trevels on 31 Jan, 2013 07:32 AM

    Yennick Trevels's Avatar

    no :)

    If your swc depends on the swz with scope external, then your swf has to redefine the dependency either as merged, internal or rsl. Otherwise it won't have the swz dependency at runtime.

    Let's say you would've defined the swz dependency with scope merged in your swc project, then you wouldn't have to redefine the dependency in the swf project because it has a dependency to your swc project (which has the swz compiled in it). Using merged in a swc project is discouraged though since it will increase the size of your swc.

  4. 4 Posted by Pavel Bernshtam on 31 Jan, 2013 07:36 AM

    Pavel Bernshtam's Avatar

    Thank you, so do I understand correctly that only external dependencies are transitive?

    So if my swf depends on my swc as "merged", I need redefine in swf all swc external dependencies?

    (Thank you very much for your help, I'm Java programmer, new to Flex, and I need now convert some flex project from manual compilation to gradle build)

  5. Support Staff 5 Posted by Yennick Trevels on 31 Jan, 2013 07:44 AM

    Yennick Trevels's Avatar

    Yes, that's right. But in your swf project you should change the scope of those swc external dependencies.

    So a small example:

    swc project build.gradle file

    type = "swc"
    
    external group: 'org.as3commons', name: 'as3commons-lang', version: '2.4', ext: 'swc'
    

    swf project build.gradle file

    type = "swf"
    
    merged project(':swclibraryproject')
    merged group: 'org.as3commons', name: 'as3commons-lang', version: '2.4', ext: 'swc'
    

    It's a bit different then in Java, but that's the nature of the Flex compiler.

  6. 6 Posted by Pavel Bernshtam on 31 Jan, 2013 07:48 AM

    Pavel Bernshtam's Avatar

    Got it!

    As I understand, the reason for this is that, unlike Java, here I should tell not just dependency but also how I link it. And this requires for me declaration of dependency twice.

    Correct?

  7. Support Staff 7 Posted by Yennick Trevels on 31 Jan, 2013 07:56 AM

    Yennick Trevels's Avatar

    exactly

  8. Support Staff 8 Posted by Maxime Cowez on 31 Jan, 2013 09:09 AM

    Maxime Cowez's Avatar

    The difference with Java is that for a Flex application or library, file size is of the essence. That's why all those different, somewhat complicated linking options exist.

    As for your conversion task: if the build configuration already exists in your IDE (IntelliJ IDEA as I understand it), you should be able to just copy the linking scopes that were defined in there.
    In your project's settings window, go to the 'dependencies' tab. In the 'linkage' column you can find how libraries were linked in IntelliJ. You should be able to simply translate this to GradleFx dependency scopes.

    On a side note: unfortunately IntelliJ has no support for RSL linking libraries, only the Flex framework itself can be linked as RSL (it's a total mistery to me why there's such a glaring omission; feel free to vote on this issue). So for the time being this is one option more available to you through GradleFx or CLI build.

  9. 9 Posted by Pavel Bernshtam on 31 Jan, 2013 07:44 PM

    Pavel Bernshtam's Avatar

    Thank you, Maxime, I voted

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