Thank you, it does the trick. I thought I tried that option before, obviously 
not hard enough :)
Anyway, looking forward for a more 'gradely' way to do so.


________________________________

        From: Adam Murdoch [mailto:[email protected]] 
        Sent: Monday, February 23, 2009 7:34 PM
        To: [email protected]
        Subject: Re: [gradle-user] Multiple project dependency management
        
        


        [email protected] wrote: 

                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