我在 gradle 用户指南的第 78 页:示例 14.5。使用脚本配置任意对象。
我已经复制了示例中的所有代码:
构建.gradle
task configure << {
pos = java.text.FieldPosition( ) new 10
// Apply the script
apply from: 'other.gradle', to: pos
println pos.beginIndex
println pos.endIndex
}
其他.gradle
beginIndex = 1;
endIndex = 5;
gradle -q configure 的输出
D:\Gradle\ThisAndThat>gradle -q configure
FAILURE: Build failed with an exception.
Where: Build file 'D:\Gradle\ThisAndThat\build.gradle' line: 1
What went wrong: Could not compile build file 'D:\Gradle\ThisAndThat\build.gradle'.
> startup failed:
build file 'D:\Gradle\ThisAndThat\build.gradle': 1: expecting EOF, found 'configure' @ line 1, column 6.
task configure << { ^
1 error
我无法弄清楚为什么会收到此错误。任何帮助,将不胜感激。谢谢!