问题
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