Vampire
07/04/2023, 10:39 PMif (isFoo) {
return
}
in a Kotlin Script, specifically a Gradle Kotlin DSL script in this case?
Or do I really have to put all the code below into the parens and invert the condition?ephemient
07/04/2023, 11:10 PMephemient
07/04/2023, 11:10 PMVampire
07/05/2023, 6:35 AMAdam S
07/07/2023, 6:34 AMexitProcess(0)
? https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.system/exit-process.htmlVampire
07/07/2023, 7:13 AMmikehearn
07/07/2023, 9:55 AMfun end() { throw EndOfScriptException() }
Vampire
07/07/2023, 10:03 AMVampire
07/07/2023, 10:04 AMexitProcess
, except that the exit is not with success.
It would not help at all.mikehearn
07/07/2023, 10:05 AMexitProcess
exits the process, it doesn't throw an exception (it looks like it does, but that's just there to satisfy the compiler, it won't be called). The idea is use a custom exception (or actually you'd inherit from Error
to stop it being caught accidentally) and then catch it in your scripting host. Then you can do any tidy ups before quitting normally.mikehearn
07/07/2023, 10:06 AMVampire
07/07/2023, 10:06 AMVampire
07/07/2023, 10:07 AMmikehearn
07/07/2023, 10:07 AMephemient
07/09/2023, 3:22 AMthrow GradleScriptReturn()
to simulate an early return from within a buildscript, really just one line of non-boilerplate code. whether you should is a different question of course :p