Run a task for the current project only


(KwonNam Son) #1

If you run gradle dependencies on a multi project’s root directory, it only runs for the current project with out specifying project name.

When I make a task for all projects and I run the task on a root project, it always runs for all projects. How can I force a task to run only for the current project?

Thanks.


(Peter Niederwieser) #2

If you want to run some task only for a particular project, you have to use its task path rather than its task name. The path for a task ‘foo’ in the root project is ‘:foo’. The path for a task ‘foo’ in the ‘bar’ subproject is ‘:bar:foo’. You can learn more about this in the Gradle User Guide.

‘gradle dependencies’ is special in that it only executes the ‘dependencies’ task for the current project. I’m not aware of a way to do the same for your own tasks.