SourceSets - Groovy -> Kotlin DSL

早过忘川 提交于 2021-01-05 06:46:00

问题


sourceSets {
   main {
     java.srcDirs = ['src/main/kotlin', 'src/main/java']
     res.srcDirs =
       [
          'src/main/res/layouts/activity',
          'src/main/res/layouts/fragment',
          'src/main/res/layouts/dialog',
          'src/main/res/layouts/items',
          'src/main/res/layouts/views',
          'src/main/res/layouts',
          'src/main/res'
       ]
   }
}

Here for java.srcDirs we convert it in kotlin DSL like

java.sourceSets {
    getByName("main").java.srcDirs("src/main/kotlin")
}

But I don't know how to change sub folders within 'layout' res folder code in DSL in gradle or don't know it's possible or not? Anyone know if it's possible then how to do that ?

I want to write res.srcDirs = [] in DSL as whole Gradle scripts is write in kotlin DSL.


回答1:


Try this

sourceSets {
    getByName("main").java.srcDirs("src/main/kotlin")
    getByName("main").res.srcDirs(
        "src/main/res/layouts/activity",
        "src/main/res/layouts/fragment",
        "src/main/res/layouts",
        "src/main/res"
    )
}


来源:https://stackoverflow.com/questions/54339367/sourcesets-groovy-kotlin-dsl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!