在 Kotlin 脚本中不起作用 "include":^ 意外标记(使用“;”分隔同一行的表达式)
Not work "include" in Kotlin script: ^ Unexpected tokens (use ';' to separate expressions on the same line)
在我的build.gradle.kts:
val shadowJar by tasks.getting(ShadowJar::class) {
include '*.properties'
}
但是我得到错误:
Script compilation errors:
Line 93: include '*.properties'
^ Unexpected tokens (use ';' to separate expressions on the same line)
Line 93: include '*.properties'
^ Function invocation 'include(...)' expected
2 errors
Open File
需要对字符串使用双引号,并且 (...) 将函数参数括起来。这是文档中提到的前两件事,用于将 Groovy 构建脚本转换为 Kotlin。 https://guides.gradle.org/migrating-build-logic-from-groovy-to-kotlin/#prepare_your_groovy_scripts
Prepare your Groovy scripts
Some simple Kotlin and Groovy language differences can make converting scripts tedious:
Groovy strings can be quoted with single quotes 'string' or double quotes "string" whereas Kotlin requires double quotes "string".
Groovy allows to omit parentheses when invoking functions whereas Kotlin always requires the parentheses.
在我的build.gradle.kts:
val shadowJar by tasks.getting(ShadowJar::class) {
include '*.properties'
}
但是我得到错误:
Script compilation errors:
Line 93: include '*.properties'
^ Unexpected tokens (use ';' to separate expressions on the same line)
Line 93: include '*.properties'
^ Function invocation 'include(...)' expected
2 errors
Open File
需要对字符串使用双引号,并且 (...) 将函数参数括起来。这是文档中提到的前两件事,用于将 Groovy 构建脚本转换为 Kotlin。 https://guides.gradle.org/migrating-build-logic-from-groovy-to-kotlin/#prepare_your_groovy_scripts
Prepare your Groovy scripts
Some simple Kotlin and Groovy language differences can make converting scripts tedious:
Groovy strings can be quoted with single quotes 'string' or double quotes "string" whereas Kotlin requires double quotes "string".
Groovy allows to omit parentheses when invoking functions whereas Kotlin always requires the parentheses.