Gradle:试图找出EOF错误。用户指南:例14.5。使用脚本配置任意对象。

时间:2013-05-16 15:24:14

标签: gradle eof

我在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

我无法弄清楚为什么会收到此错误。任何帮助,将不胜感激。谢谢!

1 个答案:

答案 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)