Regarding multi project build

(m m) #1

I have the below project structure

myprojects ( root folder )
  projectP1 ( have their own build.gradle)
  projectP2 ( have their own build.gradle)
  projectP3 ( have their own build.gradle)
  projectP4 ( have their own build.gradle)

Component1 and Component2 are two multiprojects with a settings.gradle. Since gradle does not support nested settings.gradle , in order to build my components from the “myprojects” folder , I have .bat file in the “myprojects” folder

I would like to get rid of the .bat/.sh file to run the build from “myprojects” folder. I am planning to have

a build.gradle under “myproject” folder which will have a task. The task will recursively loop through the individual multiprojects and invoke gradle build.

Before proceeding , I would like to know whether my approach is feasible.

In case if there are any samples to read directories in groovy , please provide.

(m m) #2

I tried the below build

String[] components = ["component1","component2"]
  task buildAllComponents(type: GradleBuild) {
" Building
${it} "
     buildFile ="${it}/build.gradle"
     tasks << 'build'

Only the last component in the list of components is getting build. can you let me know the error in logic ?

(m m) #3

Found a solution.

String[] buildOrder = ["component1","component2"]
  task buildAllComponents() {
      buildOrder.each { def componentName ->
      tasks.add(name: "build$componentName", type: GradleBuild) {
   buildFile = componentName + "/build.gradle"
  tasks = ['clean','build','upload']
  println " ******** BUILDING ******** " + it
   String taskName = "build" + it