getTaskDependencyFromProjectDependency not working for custom task using configuration on demand

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!

A/build.gradle

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

B/build.gradle

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

Any help on this one?

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).