Steven Devijver wrote:
Hey all,

It seems the project delegation situation with the subprojects { } method is worse than I originally thought. Today I've discovered that the dependencies { } method is also affected which means you can't declare proper project dependencies in a multi-project build.


Do you have an example?

Generally, the stuff in dependencies { } is executed immediately, so will not be affected by the delegate problem.

I've been working on porting spring to gradle for more than a week now, mostly struggling with weird behavior that I've now all attributed to the same issue. At this point I have to abandon my work for now until this issue is fixed.

Here is an (ugly) workaround you can put in your root build script somewhere. It will change the behaviour of the task action closures, so that they work correctly when used in a subprojects { } closure. You can delete this chunk of code when the issue is fixed.

subprojects {
   afterEvaluate {project ->
       project.tasks.each {task ->
           task.actions.findAll { it instanceof ClosureTaskAction }.each {
               it.closure.delegate = project
               it.closure.resolveStrategy = Closure.DELEGATE_FIRST
           }
       }
   }
}


--
Adam Murdoch
Gradle Developer
http://www.gradle.org

Reply via email to