Trying to figure out an EOF error. Gradle Userguide: Example 14.5. Configuring arbitrary objects using a script

I am on page 78 of the gradle userguide: Example 14.5. Configuring arbitrary objects using a script.

I have copied all of the code in the example:

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;

Output of 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

I cannot figure out why I am getting this error. Any help would be appreciated. Thanks!

The line starting with ‘pos’ isn’t valid Groovy code (it’s correct in the user guide).

What is the correct code?

Thanks!

The one in the user guide.

Looking at 14.5. Configuring arbitrary objects using an external script http://www.gradle.org/docs/current/userguide/tutorial_this_and_that.html

There is a reference to ‘other.gradle’ but the contents shown for that file is empty.