Hi Christophe,

I have investigated a bit your problem.

I think the core of the problem you are encountering is in maven dependency
mediation mechanism, to sum up: when there's a discrepancy between
transitive dependencies (dependencies indicated by your dependencies) it
favors nearest dependency. From version 2.0.9 (!) when two dependencies are
at the same level the one indicated first in the pom is chosen.

In your case you might have specified something like this


             <dependency>
                <groupId>com.adobe.flex.framework</groupId>
                <artifactId>flex-framework</artifactId>
                <version>${flex-sdk.version}</version>
                <scope>external</scope>
                <type>pom</type>
            </dependency>

             <dependency>
                <groupId>org.as3commons</groupId>
                <artifactId>as3commons-lang</artifactId>
                <version>0.2.1</version>
                <scope>external</scope>
                <type>swc</type>
            </dependency>


Now what happens here is that flex-framework (level 1 dependency) depends on
commons-framework (level 2 pom dependency) which depends on all the various
framework libraries (level 3) while as3commons (level 1) depends directly on
all other dependencies (level 2). Level 2 transitive dependencies of
as3commons win over level 3 flex-framework dependencies.

The solution for your project would be using directly common-framework
instead of flex-framework and all the other libraries and put this BEFORE
any other library.

             <dependency>
                <groupId>com.adobe.flex.framework</groupId>
                <artifactId>common-framework</artifactId>
                <version>${flex-sdk.version}</version>
                <scope>external</scope>
                <type>pom</type>
            </dependency>

            <dependency>
                <groupId>org.as3commons</groupId>
                <artifactId>as3commons-lang</artifactId>
                <version>0.2.1</version>
                <scope>external</scope>
                <type>swc</type>
            </dependency>


No need for tedious and long dependency exclusions.

This makes me also think we should use common-framework in as3commons,
adding so a level of indirection for the dependency and making this sort of
things less likely to happen.


This leaves unsolved the playerglobal dependency problem which I still don't
get exactly why is acting the way it is.


To have more details on maven dependency mediation mechanism you can have a
look at:

http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html


   - *Dependency mediation* - this determines what version of a dependency
   will be used when multiple versions of an artifact are encountered.
   Currently, Maven 2.0 only supports using the "nearest definition" which
   means that it will use the version of the closest dependency to your project
   in the tree of dependencies. You can always guarantee a version by declaring
   it explicitly in your project's POM. Note that if two dependency versions
   are at the same depth in the dependency tree, until Maven 2.0.8 it was not
   defined which one would win, but since Maven 2.0.9 it's the order in the
   declaration that counts: the first declaration wins.
      - "nearest definition" means that the version used will be the closest
      one to your project in the tree of dependencies, eg. if
dependencies for A,
      B, and C are defined as A -> B -> C -> D 2.0 and A -> E -> D
1.0, then D 1.0
      will be used when building A because the path from A to D through E is
      shorter. You could explicitly add a dependency to D 2.0 in A to force the
      use of D 2.0


Hope this could help.

Cheers

Martino

P.S.

we could further specify the version numbers of as3commons dependencies for
example with:

        <dependency>
            <groupId>com.adobe.flex.framework</groupId>
            <artifactId>flex</artifactId>
            <version>[${flex-sdk.version},)</version>
            <type>swc</type>
            <scope>external</scope>
        </dependency>

this will specify explicitly that as3commons will work with version >=
${flex-sdk.version} but this implies compiling and testing with latest flex
framework version and (still!) having a transient dependency to
${flex-sdk.version}. This is in fact consistent with the behaviour I've
reported above: non compulsory transient dependencies are affected by maven
dependency mediation who favours the nearest dependency specification, which
means if in my project I specify I want to use flex 4 and one of my
dependencies specified (not compulsory) flex 3 dependency flex 4 dependency
will win (distance = 1 from my project < distance = 2).

Note that maven dependency specified without angle brackets ([]) are
considered to be overridible witout generating any conflict.

See
http://docs.codehaus.org/display/MAVEN/Dependency+Mediation+and+Conflict+Resolution

On Sat, Sep 4, 2010 at 9:36 AM, Christophe Herreman <
[email protected]> wrote:

> Any ideas on this?
>
> Is there any reference to creating swc's that can be used with both the
> Flex 3.x and 4.x SDK? I assume the key is to externalize the flex framework
> from the generated swc, but perhaps I'm missing something.
>
> regards,
> Christophe
>
> 2010/9/3 Christophe Herreman <[email protected]>
>
> Hi,
>>
>> I managed to remove the dependency on framework:zip:configs by adding
>> the external scope. I do however still have a reference to
>> playerglobal:swc:10:3.5.0.12683:runtime which is pulled in by
>> as3commons-logging.
>>
>> I have the playerglobal dependency defined like this in the pom of
>> as3commons:
>>
>> <dependency>
>>  <groupId>com.adobe.flex.framework</groupId>
>>  <artifactId>playerglobal</artifactId>
>>  <version>${flex-sdk.version}</version>
>>  <scope>external</scope>
>>  <type>swc</type>
>>  <classifier>${flashplayer.version.major}</classifier>
>> </dependency>
>>
>> ... so I would assume the reference is gone, but it is not.
>>
>> Is there any way to remove the runtime dependency on playerglobal?
>>
>> regards,
>> Christophe
>>
>> On Sep 2, 9:59 am, Christophe Herreman <[email protected]>
>> wrote:
>> > Hi all,
>> >
>> > I have a project that is built with Flex SDK 4.1.0 and that uses some
>> > libraries that have been compiled with Flex SDK 3.5.0. The problem I
>> > have is that the dependencies of the flex framework pom seem to
>> > include references to the 3.5.0 SDK while I would expect it to include
>> > only references to the 4.1.0 libraries. I see that one of the
>> > libraries seems to include a reference to a 3.5.0 dependency and I
>> > managed to compile my app when I add exclusions for some of the Flex
>> > SDK libraries. This seems a bit of a pain as I'm sure other people
>> > will run into this problem as well.
>> >
>> > Is this an issue with the pom of the as3commons libraries where it
>> > compiles SDK libraries into the swc? If so, what is the correct way to
>> > exclude libraries when compiling swc's? We currently have the scope
>> > set to "external", but not for the zips:config dependency (see below).
>> > Could this be bringing in the 3.5.0 dependencies? How about the
>> > runtime reference to playerglobal.swc?
>> >
>> > Here is a dependency:tree log:
>> >
>> > [INFO] com.labtracker:client:swf:1.0-SNAPSHOT
>> > [INFO] +- com.adobe.flex.framework:flex-framework:pom:
>> > 4.1.0.16076:compile
>> > [INFO] |  +- com.adobe.flex.framework:common-framework:pom:
>> > 4.1.0.16076:compile
>> > [INFO] |  |  +- com.adobe.flex.framework:flash-integration:swc:
>> > 4.1.0.16076:compile
>> > [INFO] |  |  +- com.adobe.flex.framework:flex:swc:3.5.0.12683:compile
>> > [INFO] |  |  +- com.adobe.flex.framework:framework:swc:
>> > 3.5.0.12683:compile
>> > [INFO] |  |  +- com.adobe.flex.framework:osmf:swc:4.1.0.16076:compile
>> > [INFO] |  |  +- com.adobe.flex.framework:rpc:swc:3.5.0.12683:compile
>> > [INFO] |  |  +- com.adobe.flex.framework:textLayout:swc:
>> > 4.1.0.16076:compile
>> > [INFO] |  |  +- com.adobe.flex.framework:utilities:swc:
>> > 3.5.0.12683:compile
>> > [INFO] |  |  +- com.adobe.flex.framework:datavisualization:rb.swc:
>> > 4.1.0.16076:compile
>> > [INFO] |  |  +- com.adobe.flex.framework:framework:rb.swc:
>> > 3.5.0.12683:compile
>> > [INFO] |  |  +- com.adobe.flex.framework:osmf:rb.swc:
>> > 4.1.0.16076:compile
>> > [INFO] |  |  +- com.adobe.flex.framework:rpc:rb.swc:
>> > 3.5.0.12683:compile
>> > [INFO] |  |  +- com.adobe.flex.framework:spark:rb.swc:
>> > 4.1.0.16076:compile
>> > [INFO] |  |  +- com.adobe.flex.framework:textLayout:rb.swc:
>> > 4.1.0.16076:compile
>> > [INFO] |  |  \- com.adobe.flex.framework:flash-integration:rb.swc:
>> > 4.1.0.16076:compile
>> > [INFO] |  +- com.adobe.flex.framework:playerglobal:swc:
>> > 10.0:4.1.0.16076:compile
>> > [INFO] |  \- com.adobe.flex.framework:playerglobal:rb.swc:
>> > 4.1.0.16076:compile
>> > [INFO] +- com.adobe.flex.framework:spark:swc:4.1.0.16076:theme (scope
>> > not updated to compile)
>> > [INFO] +- com.adobe.flex.framework:sparkskins:swc:4.1.0.16076:compile
>> > [INFO] +- com.adobe.lcds:fds:swc:4.0.1.277662:compile
>> > [INFO] +- com.adobe.lcds:fds:rb.swc:en_US:4.0.1.277662:compile
>> > [INFO] +- com.adobe.lcds:fiber:swc:4.0.1.277662:compile
>> > [INFO] +- com.adobe.lcds:fiber:rb.swc:en_US:4.0.1.277662:compile
>> > [INFO] +- com.adobe.lcds:playerfds:swc:4.0.1.277662:compile
>> > [INFO] +- com.adobe.lcds:serializers:swc:4.0.1.277662:compile
>> > [INFO] +- org.as3commons:as3commons-lang:swc:0.3:compile
>> > [INFO] |  +- com.adobe.flex.framework:framework:zip:configs:
>> > 3.5.0.12683:compile
>> > [INFO] |  \- com.adobe.flex.framework:playerglobal:swc:
>> > 10:3.5.0.12683:runtime
>> > [INFO] +- org.as3commons:as3commons-logging:swc:1.1.1:compile
>> > [INFO] +- org.as3commons:as3commons-reflect:swc:1.3.1:compile
>> > [INFO] +- com.adobe.flex.framework:datavisualization:swc:
>> > 4.1.0.16076:compile
>> > [INFO] +- com.adobe.flex.framework:datavisualization:rb.swc:en_US:
>> > 4.1.0.16076:compile
>> > [INFO] +- com.google.code.flex-iframe:flex-iframe:swc:1.4.6:compile
>> > [INFO] +- com.googlecode.flexlib:flexlib:swc:2.5:compile
>> > [INFO] \- com.adobe.flexunit:flexunit:swc:0.85:test
>> >
>> > In case anyone is interested, all sources can be found here:
>> http://code.google.com/p/as3-commons/source/browse/#svn/trunk
>> >
>> > Many thanks,
>> > Christophe
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Flex Mojos" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]<flex-mojos%[email protected]>
>> For more options, visit this group at
>> http://groups.google.com/group/flex-mojos
>>
>> http://flexmojos.sonatype.org/
>>
>
>
>
> --
> Christophe Herreman
> http://www.herrodius.com
> http://www.springactionscript.org
> http://www.as3commons.org
>
> --
> You received this message because you are subscribed to the Google
> Groups "Flex Mojos" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<flex-mojos%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/flex-mojos
>
> http://flexmojos.sonatype.org/
>

-- 
You received this message because you are subscribed to the Google
Groups "Flex Mojos" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/flex-mojos

http://flexmojos.sonatype.org/

Reply via email to