[best approach] How i execute submodule task

include ('subProject')


task RunTest () {
  trace("bb") //output: bb / test bb
  trace("aa") //output: aa 
  trace("cc") //output: cc

def trace(string){
	project(":subProject").string = string;
	println  project(":subProject").string ;


project.ext {
task test << {
	println "test ${string});

What are you trying to do?

Gradle works by building a directed acyclic graph of the tasks to execute, so you wouldn’t execute tasks directly in the build script. You just setup the dependencies between tasks and run the “top level” task.

Reading up about the build lifecycle might help and some build script basics.