Expecting EOF error not helpful

(John Norris) #1

I have cut my build file down to

task norris << { println(“hello john norris”) \ def mojo = new my.company.program.assemble() }

and running it gives C:\Temp\gradle_play>gradle -q norris hello john norris

but if I uncomment the def then I get * What went wrong: Could not compile build file ‘C:\Temp\gradle_play\build.gradle’. > startup failed:

build file ‘C:\Temp\gradle_play\build.gradle’: 1: expecting EOF, found ‘norris’ @ line 1, column 6.

task norris << {

I would have expected that it had no idea how to get my.company.program as the buildscript is not set. But it is complaining about end of file at a line that previously was OK. So it is the def mojo line that is wrong but no idea why.

Regards, John

(John Norris) #2

I realise what I did. In the my.company.program I had a colon which gradle say as a EOF. Now falls over with a far more sensible message.

(Luke Daley) #3

Just to be clear, this is coming from the Groovy compiler, not Gradle.

It would be nice to have a better error message, agreed.

(Diana Ma) #4

I have the following code based onthe example in the Gradle 2.0 documentation. Based on the above discussion, I think the problem is the two colons in the loadfile task, however, I do not know of a legitimate way to eliminate these from the example code(?)

Here is the documentation http://www.gradle.org/docs/current/userguide/tutorial_using_tasks.html

task checksum << {

fileList(’…/antLoadfileResources’).each { File file ->

ant.checksum(file: file. property: “cs_$file.name”)

println “$file.name Checksum: ${ant.properties[“cs_$file.name”]}”

} }

task loadfile << {

fileList(’…/antLoadfileResources’).each {

ant.loadfile(srcFile: file, property: file.name)

println “I’m fond of $file.name

} }

File[] fileList(String dir) {

file(dir).listFiles({file -> file.isFile() } as FileFilter).sort() }

Any help would be greatly appreciated.