How to distinguish between root project scan and multi project scan

plugins

(Siva Jeganathan) #1

In Multi project environment :
I remember gradle runs in root project only when invoked with

gradle :projectTask

and multiple projects (all sub projects) if invoked as

gradle projectTask

How can I distinguish whether my task is invoked for single project or for all project inside Plugin code (TaskAction part)?

Thanks


(Sterling Greene) #2

The tasks on the command line are selectors, so when you run gradle projectTask, Gradle is trying to find all tasks with that name in all subprojects. When you run with gradle :projectTask, that’s selecting the task with the path “:projectTask”.

So you don’t really know if your task was selected one way or the other and it shouldn’t matter. Your task is associated with a particular project, so you typically make it work relative to that project. If you have a multi-project build, there will be several, separate instances of your task.