28 lines
651 B
Groovy
28 lines
651 B
Groovy
|
// Define an extra property for the correct code
|
||
|
ext.correctCode = "1234"
|
||
|
|
||
|
// Task to save the code to a file
|
||
|
task save {
|
||
|
doLast {
|
||
|
def code = correctCode
|
||
|
file("code.txt").text = code
|
||
|
println "Code wurde gespeichert!"
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Task to check the saved code, depends on the 'save' task
|
||
|
task check() {
|
||
|
doLast {
|
||
|
def code = file("code.txt").text.trim()
|
||
|
|
||
|
if (code == correctCode)
|
||
|
println "Ausgelesener Code ${code} ist korrekt."
|
||
|
else
|
||
|
throw new Exception("Fehler: Der Code ist inkorrekt.")
|
||
|
}
|
||
|
}
|
||
|
|
||
|
task unlock(dependsOn: check) {
|
||
|
println "Das Schloss wurde geoeffnet."
|
||
|
}
|