0
我有下面的代碼,這是失敗的gradle文件。任務聲明不在gradle中工作
task wakeup
task dressup
task playMusic
task goRunning
//dependsOn(task)
wakeup <<{
println("I am awake,i need to go for a run")
}
dressup(dependsOn: wakeup)<<{
println("I am ready with my track suit")
}
playMusic(dependsOn: dressup)<<{
println("I have played track 7")
}
goRunning(dependsOn: playMusic)<<{
println("I am running")
}
錯誤: -
C:\Users\akathaku\Desktop\gradlelearning>gradle -q -b taskmethods.gradle goRunning
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\akathaku\Desktop\gradlelearning\taskmethods.gradle' line: 14
* What went wrong:
A problem occurred evaluating root project 'gradlelearning'.
> Could not find method dressup() for arguments [{dependsOn=task ':wakeup'}] on root project 'gradlelearning'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
但是,如果我的代碼更改爲: -
//dependsOn(task)
task wakeup <<{
println("I am awake,i need to go for a run")
}
task dressup(dependsOn: wakeup)<<{
println("I am ready with my track suit")
}
task playMusic(dependsOn: dressup)<<{
println("I have played track 7")
}
task goRunning(dependsOn: playMusic)<<{
println("I am running")
}
其完美運行。 Normaly宣佈任務並稍後使用它。但用dependsOn方法會失敗。爲什麼?