Dependencies are empty if a subproject task depends on anothers subproject task

This is the expected behavior for the configure on demand feature. The root project is always configured. The projects of the tasks requested at the command line are configured and standard project dependencies are supported. Task dependencies are supported only if you declare them via task path.

In your example, you cannot add a task dependency by directly referencing the task:

project(':a').tasks['showDeps'].dependsOn(project(':b').showDeps)

For configuration on demand to work, you must declare this task dependency by using the task path:

project(':a').showDeps.dependsOn(':b:showDeps')

Due to the strict requirements of the configuration on demand feature, it is generally a bad idea to turn this on for all projects by setting it in your GRADLE_USER_HOME/gradle.properties. You should only explicitly turn this on for projects that meet the requirements. Your issue here would have been immediately recognizable had the sample project explicitly enabled it, the command line included it, or the full output been included.