Specifying task configuration order


Is there any way to specify the order in which gradle configures tasks? I’m trying to set up an implicit dependency between two tasks but gradle seems to configure tasks strictly alphabetically breadth-first. That is, say I have a project with this structure:

├── build.gradle
├── projA
│   ├── build.gradle
│   └── subA
│       └── build.gradle
└── projB
    └── build.gradle

Gradle configures them in the order rootProject, :projA, :projB, :projA:subA. So it’s fine if I go into projB and try to set dependencies like these:

// projB's build.gradle
task bug {
  inputs.files rootProject.bug.outputs.files
  inputs.files project(':projA').bug.outputs.files

since it’s already configured the rootProject and :projA, but if I try this:

// projB's build.gradle
task bug {
  inputs.files project(':projA:subA').bug.outputs.files

I get this error:

FAILURE: Build failed with an exception.

* Where:
Build file '/path/to/repository/projB/build.gradle' line: 13

* What went wrong:
A problem occurred evaluating project ':projB'.
> Could not get unknown property 'bug' for project ':projA:subA' of type org.gradle.api.Project.

If I add println statements they show that :projB thinks that :projA:subA has no tasks.

Does anyone have any ideas? Changing the order of their declaration in settings.gradle doesn’t seem to help, and my Internet searches haven’t turned up anything useful. I suspect this might be a bug in how gradle’s task configuration handles (or rather doesn’t handle) implicit task dependencies, but I figured I’d ask here first in case I’m missing something.


You can use evaluationDependsOn(':projA:subA')

See Project.evaluationDependsOn(String)

I urge you to not set up tasks like this. Instead, use configurations, artifacts and dependencies. Reaching into other projects is almost always wrong (except for getting their name and other immutable properties).

You can take the ideas of this blog post and adapt them to your situation: http://mrhaki.blogspot.de/2016/02/gradle-goodness-inter-project-artifact.html?m=1