2014-11-15 109 views
0

我已经写了下面的简单脚本:构造函数首先声明

task init << { 
    println "init"; 
} 

task hello(dependsOn: init) << { 
    println "hello"; 
} 

task super(dependsOn: hello) << { 
    println "super" 
} 

但我得到当我试图执行gradle super错误:

build file 'D:\gradle\build.gradle': 9: Constructor call must be the first statement in 
a constructor. at line: 9 column: 12. 
File: build_69b6a3lkqqtk7j84lsls47ccta @ line 9, column 12. 
    task super(dependsOn: hello) << { 

什么是问题?

回答

8

super是Groovy的用于调用父类构造函数的保留关键字。将其改为例如super2并运行gradle super2,它会工作。

相关问题