Resolving a configuration initiates evaluation of projectDependency's build.gradle file

I have a multi project build where almost all the configuration is located in the root build.gradle file. So my subprojects only contain special stuff like, adding non-standard tasks to the build where necessary. This works, because the subprojects build.gradle won’t get evaluated before root finishes, so all configurations, tasks, dependencies are set and can be used.

but the addition of one single line destroys my entire concept:


as this will resolve the configuration, AND to my surprise will result in the subprojects included in the configuration to be evaluated to early.

Is there a way to avoid that?

For clarification an example settings.gradle:

include 'foo'


allprojects {

apply plugin: ‘java’


dependencies {

compile project(’:foo’)


println “before resolve”

configurations.compile.files.each {println it}

println “after resolve”


println "foo"

actual output:

before resolve



after resolve

expected output:

before resolve

/foo/build/libs/foo.jar # wouldn’t mind not having this path if projectDependency not configured yet.

after resolve


I don’t think there is a way to avoid that. Configurations should usually be resolved in the execution phase, not in the configuration phase.

I will try moving it back into the execution phase I guess …