You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Suranga Kasthurirathne <su...@gmail.com> on 2013/09/23 17:12:03 UTC

Problem managing multiple versions of the same dependency via patient - child poms

Hi,

I apologize in advance if this email contains sketchy / incomplete details.
I'm not really a maven expert, and would love any advice that would be
helpful.

I'm  a volunteer for a open source product which uses a modular
architecture. We have a core project (supported by maven). Users can write
their own modules (also supported by maven) to add the custom features that
they require, and load them onto the OpenMRS core.

Now in maven, if we declare multiple versions of the same dependency in the
pom, maven automatically uses the very latest version of the given
dependency.

However, I am having trouble trying to replicate this by overriding a core
dependency via a module.
Assuming that the project trunk uses version 1.0 of jar A, and I want to
write a module that requires version 2.0 of the same jar, how can I add
this dependency to the pom file of a module, and make maven use the more
recent dependency declared in the pom file of the module ? At the moment,
what happens when I try this is both versions of the jar get loaded, and a
casting error occurs.

Any advice on how to manage this would be very much appreciated !


Best Regards,
Suranga

Re: Problem managing multiple versions of the same dependency via patient - child poms

Posted by Ron Wheeler <rw...@artifact-software.com>.
Do you really mean "project trunk"?
That is not a Maven concept. It is a source version management term.

You may want to describe your project structure in more detail.

You also have to consider how your run-time will select the version of 
the library that it will run. It may just pick the first 
com.company.project.package.Class that it finds regardless of the 
version. You need to understand how the classes get loaded. This may not 
have anything to do with Maven.
If you load a version 1 and a module needs the class with the same name, 
the classloader will not go looking for another version of the class 
since it only needs one.
If you have code that expects the Class to behave like a version 2, you 
will get an error - casting is likely, MethodNotFound is pretty common 
if you have added new methods or added methods with the same name as a 
version 1 method but a different argument list.

Compile-time decisions that Maven makes can have nothing to do with 
run-time choices if your run-time is putting together a set of Classes 
at execution time.

Ron


On 23/09/2013 11:12 AM, Suranga Kasthurirathne wrote:
> Hi,
>
> I apologize in advance if this email contains sketchy / incomplete details.
> I'm not really a maven expert, and would love any advice that would be
> helpful.
>
> I'm  a volunteer for a open source product which uses a modular
> architecture. We have a core project (supported by maven). Users can write
> their own modules (also supported by maven) to add the custom features that
> they require, and load them onto the OpenMRS core.
>
> Now in maven, if we declare multiple versions of the same dependency in the
> pom, maven automatically uses the very latest version of the given
> dependency.
>
> However, I am having trouble trying to replicate this by overriding a core
> dependency via a module.
> Assuming that the project trunk uses version 1.0 of jar A, and I want to
> write a module that requires version 2.0 of the same jar, how can I add
> this dependency to the pom file of a module, and make maven use the more
> recent dependency declared in the pom file of the module ? At the moment,
> what happens when I try this is both versions of the jar get loaded, and a
> casting error occurs.
>
> Any advice on how to manage this would be very much appreciated !
>
>
> Best Regards,
> Suranga
>


-- 
Ron Wheeler
President
Artifact Software Inc
email: rwheeler@artifact-software.com
skype: ronaldmwheeler
phone: 866-970-2435, ext 102


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org