英文:
Gradle Kotlin DSL equivalent for Groovy DSL compilerArgs for compileJava?
问题
对于Gradle的Java插件,以下是与上述Groovy DSL等效的Kotlin DSL:
tasks.withType<JavaCompile> {
options.compilerArgs += listOf(
"-Amapstruct.suppressGeneratorTimestamp=true",
"-Amapstruct.suppressGeneratorVersionInfoComment=true",
"-Amapstruct.verbose=true"
)
}
英文:
For the Gradle Java plugin, what is the Kotlin DSL equivalent for the following Groovy DSL?
compileJava {
options.compilerArgs += [
'-Amapstruct.suppressGeneratorTimestamp=true',
'-Amapstruct.suppressGeneratorVersionInfoComment=true',
'-Amapstruct.verbose=true'
]
}
答案1
得分: 0
tasks.compileJava {
options.compilerArgs.addAll(
listOf(
"-Amapstruct.suppressGeneratorTimestamp=true",
"-Amapstruct.suppressGeneratorVersionInfoComment=true",
"-Amapstruct.verbose=true",
)
)
}
英文:
compilerArgs
is a Java List<String>
, which in Kotlin is mapped to a MutableList<String>
.
There are a few different ways to add elements to a mutable list in Kotlin. One option is to use addAll()
tasks.compileJava {
options.compilerArgs.addAll(
listOf(
"-Amapstruct.suppressGeneratorTimestamp=true",
"-Amapstruct.suppressGeneratorVersionInfoComment=true",
"-Amapstruct.verbose=true",
)
)
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论