I agree, this is also an issue that I have. I've been putting off trying to 
solve it and just have the dependencies defined in each subproject at the 
moment (and use sed to replace them).

It would be nice to have something like a free floating configurations scope 
where you could define configurations and then reference them from the 
dependencies scope.

Cheers

Matt




________________________________
From: Adam Murdoch <[email protected]>
To: [email protected]
Sent: Monday, 23 February, 2009 18:33:30
Subject: Re: [gradle-user] Multiple project dependency management



[email protected] wrote: 
Multiple project dependency management 
Hi all, 
After reading the documentation, I
have a hard time understanding multiple projects dependency. My
requirement is quite simple. I'm still used to Maven, and I try to
reproduce features that seem the most interesting to me.
Here's my problem. I have a multiple
java project environment, with one project depending on the other. For
some obvious reason, the 2 projects depend on one same library. I thus
need to add the same dependency to both projects, but I don't want to
add this dependency globally (for ALL projects). How can I make sure
that the same library is used by both projects, i.e. the version is the
same? With Maven, it was quite easy, just declare all libraries and
versions required in the parent pom, and simply declare the name of the
library you want to use in the appropriate sub-projects. Thus, if you
want to upgrade a library, just change the version in parent pom, the
rest will follow.
What is the most convenient way to do
so with Gradle? I keep on reading chapter 14, but can't really find
what I'm looking for.
Currently, there's no built-in way to do this, though we do plan to add
it.

In the meantime, there are plenty of options for doing this using
groovy. For example, you could have a map of library name ->
dependency definitions in the root project, and use this from the each
project:

root project build.gradle

libraries = [ 'someLib': 'org:someLib:1.2', 'otherLib':
'other-org:otherLib:3.+' ]

project1 build.gradle

dependencies {
    compile libraries.someLib
}

project2 build.gradle

dependencies {
    compile libraries.someLib, libraries.otherLib
}

Then, to upgrade a library, you change the contents of the map (ie a
single place)


Thanks for your help, and sorry if my
question is clearly stated in the user guide. 
Erwan 


      

Reply via email to