Andrei Sereda wrote:
Hi everybody,

I have a question regarding runtime configuration of project
dependencies. My goal is to dynamically configure project dependencies
 (compile, runtime, test etc.) based on it's name (then possibly to
override it on individual basis).

My script looks like this:

allprojects {

   beforeEvaluate { project ->
        if ( project.name.endsWith("-web") )
           project.dependencies.add("compile", project(':web-lib'))
    }

}

However I get this error :

Cause: Could not find method call() for arguments [:web-lib] on
project ':project1-web'

Is there any other way I could achieve this ?


You're pretty close. Groovy thinks that project(':web-lib') is a closure call on the 'project' parameter of the beforeEvaluate closure, but 'project' isn't a closure, so you get this error message. You could rename the parameter to something other than 'project':

beforeEvaluate { p ->
       if ( p.name.endsWith("-web") )
          p.dependencies.add("compile", project(':web-lib'))
   }


Or you could qualify the call to the project() method

beforeEvaluate { project ->
       if ( project.name.endsWith("-web") )
          project.dependencies.add("compile", *this*.project(':web-lib'))
   }



Adam

Reply via email to