gradle异常(1)-EOF初识


异常信息


FAILURE: Build failed with an exception.

* Where:
Build file '/Users/qianhui/Documents/Developer/gradle_project/1228/build.gradle' line: 9

* What went wrong:
Could not compile build file '/Users/qianhui/Documents/Developer/gradle_project/1228/build.gradle'.
> startup failed:
  build file '/Users/qianhui/Documents/Developer/gradle_project/1228/build.gradle': 9: expecting EOF, found 'other' @ line 9, column 6.
     task other <<{
          ^
  
  1 error


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug 

build.gradle内容


defaultTasks 'clean','run'
task clean <<{
        println 'Default Cleaning!'
}
task run <<{
        println 'Default Running!'
}
task other <<{
        println 'I'm not a default task'
}

上面的异常说明文件应该是结束了,但是却出现了other任务。搜了下这个问题


eof


说明 EOF的问题在于该任务体中有语法错误。这个问题在于单引号和双引号的问题没有弄清楚,


'I'm not a default task'

这个问题有2种方式解决,一是将I'm改为I am或者将外层的单引号改为双引号


println "I'm  not a default task"

符合代码规范的是第二种



你可能感兴趣的:(异常)