How can gradle find sub-project's tasks in root project?

For example, I have a project organized like this:


And I have a baselineCheckstyle task in my :app project.

$ ./gradlew :app:tasks --all | grep baseline

$ ./gradlew tasks --all | grep baseline

So, my question is if I run this in my root project, how can :app:baselineCheckstyle be executed?

$ ./gradlew baselineCheckstyle

If :tools sub-project also has a baselineCheckstyle task, can it also be executed?

Thanks a lot.