Multiple settings gradle files for multiple projects building

前端 未结 6 1813
春和景丽
春和景丽 2020-11-29 21:03

I have the following project structure

-->Starnderd Location
        -->Project1 
           -->settings.gradle 
           -->build.gradle
              


        
6条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-29 21:52

    Building up on earlier answers this is what I came out with.

    interface Includer {
      def include(String... args)
    }
    
    def applyFrom(String folder) {
      apply from: folder + '/settings.gradle'
      def includer = [
        include: { args ->
              args.each {
                project(it.startsWith(':') ? it : ':' + it).projectDir =
                    new File(rootDir, folder + "/" + (it.startsWith(':') ? it.substring(1) : it).replace(':', '/'))
              }
        }] as Includer
    
      apply from: folder + '/settings.gradle', to: includer
    }
    
    applyFrom('A')
    applyFrom('B')
    

    The advantage is no duplication.

提交回复
热议问题