我写了以下最简单的脚本:
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) << {
问题是什么?
答案 0 :(得分:8)
super
是Groovy用于调用父类构造函数的保留关键字。将其更改为例如super2
并运行gradle super2
,它会起作用。