That's part of the price to pay for transitive dependencies, and you should
do your own home brewed ruby script to deal with duplicate dependencies your
own way.
Here is a way to do it:
libs = [project('core').compile.dependencies,
compile.dependencies].flatten.compact.uniq
libs_by_id = {}
libs.each do |lib|
lib = artifact(lib)
if libs_by_id[lib.id].nil?
libs_by_id[lib.id] = lib
else
libs_by_id[lib.id] = lib if libs_by_id[lib.id].version < lib.version
end
end
libs = libs_by_id.values
Note
that's not related to war packaging at all, that works in any packaging.
If you want to specify version, you can do so by acting on the versions as I
do.
On Tue, Aug 25, 2009 at 09:24, Martin Grotzke
<[email protected]>wrote:
> Hi,
>
> this is related to my other post: I want to detect duplicate artifacts
> for a package of type war. For a "webapp" subproject it might look like
> this:
>
> package(:war).with :libs=>[project('core').compile.dependencies,
> compile.dependencies]
>
> For us this leads to several duplicate libs in WEB-INF/lib that I would
> like to filter out.
>
> Also a good thing would be to be able to specify which version to use
> for a certain artifact.
>
> I also found the artifact_namespace.rb, which seems to allow more
> advanced artifact handling, but I don't see if this would help in this
> situation. Right now we specify artifacts dead simple like
> FOO = transitive('group:id:type:version')
> and use this in project.compile.with.
>
> Any hints how to improve this situation?
>
> Thanx && cheers,
> Martin
>
>