getTaskDependencyFromProjectDependency not working for custom task using configuration on demand

(Matthew Giannini) #1

First, let me just say that the configuration on demand feature is awesome! It’s a life saver for our build which has over 175 projects in it.

I am running into a problem using COD when configuring a custom task to have a dependency on the same task in projects I depend on using getTaskDependencyFromProjectDependency. The problem is easily reproducible using the two project build below.

If you do

gradle :B:foo

then the foo task will run for both A and B as desired. However if you do

gradle --configure-on-demand :B:foo

then the ‘foo’ task will NOT run for project A.

Could you point out what I’m doing wrong, or explain how I can make this kind of inter-project dependency work with COD? Clearly it works for the Java plugin so I feel like I’m missing something. Thanks!


apply plugin: 'java'
  task('foo', dependsOn: jar) {
  doLast { println "${} foo executed" }


apply plugin: 'java'
  dependencies {
  compile project(':A')
  task('foo', dependsOn: jar) {
  doLast { println "${} foo executed" }
} configurations.runtime.getTaskDependencyFromProjectDependency(true, 'foo')

(Matthew Giannini) #2

Any help on this one?

(Peter Niederwieser) #3

In builds that use configuration on demand, projects can’t access the project model of other projects. (There is an exception for the root project.) What they can do is access other projects’ outputs via project dependencies (which implicitly leads to some task wiring).