我在gradle用户指南的第78页:示例14.5。使用脚本配置任意对象。
我复制了示例中的所有代码:
build.gradle
task configure << {
pos = java.text.FieldPosition( ) new 10
// Apply the script
apply from: 'other.gradle', to: pos
println pos.beginIndex
println pos.endIndex
}
other.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
我无法弄清楚为什么会收到此错误。任何帮助,将不胜感激。谢谢!
答案 0 :(得分:1)
当我从Chapter 14.5 of the userguide复制代码时,它可以正常工作。你的错误在build.gradle脚本中:
task configure << {
pos = java.text.FieldPosition( ) new 10
应该是
task configure << {
pos = new java.text.FieldPosition(10)