Is it possible to set up a gradle project with more than 2 levels?

前端 未结 4 972
青春惊慌失措
青春惊慌失措 2020-12-14 06:19

We have been using gradle for about a year and have been somewhat successful with it. A number of features are still a little opaque, but we are getting there. I am not sure

4条回答
  •  执念已碎
    2020-12-14 06:50

    This is working quite well:

    ext{
      buildPrefix = "build"
      allProjects = ["P1", "P2"]
    }
    
    def createTasks(String prefix) {
      def newTasks = allProjects.each {
        def pName ->
          def tName = "$prefix$pName"
          tasks.add(name: tName, type: GradleBuild) {
            dir = pName
            tasks = [ prefix ]
          }
      }
    }
    
    createTasks(buildPrefix)
    
    ext {
      buildTasks = tasks.findAll{ t -> t.name.startsWith(buildPrefix) }
    }
    
    task build(dependsOn: buildTasks) {}
    

    I can just add the other tasks that I want to expose at the top level.

    Thanks for the pointers.

提交回复
热议问题