From 9d2d6dba30748681bf9d2629e40e353654ea8fb0 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Thu, 5 Nov 2015 06:33:28 -0800 Subject: [PATCH] Exit more gracefully on exception. --- src/main/kotlin/com/beust/kobalt/Main.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/Main.kt b/src/main/kotlin/com/beust/kobalt/Main.kt index 0024b0ce..6ec0c2af 100644 --- a/src/main/kotlin/com/beust/kobalt/Main.kt +++ b/src/main/kotlin/com/beust/kobalt/Main.kt @@ -9,6 +9,7 @@ import com.beust.kobalt.kotlin.BuildFile import com.beust.kobalt.kotlin.BuildFileCompiler import com.beust.kobalt.maven.DepFactory import com.beust.kobalt.maven.Http +import com.beust.kobalt.maven.KobaltException import com.beust.kobalt.maven.LocalRepo import com.beust.kobalt.misc.* import com.beust.kobalt.wrapper.Wrapper @@ -69,8 +70,11 @@ private class Main @Inject constructor( val latestVersionFuture = github.latestKobaltVersion benchmark("Build", { // runTest() - result = runWithArgs(jc, args) - executors.shutdown() + try { + result = runWithArgs(jc, args) + } finally { + executors.shutdown() + } }) log(1, if (result != 0) "BUILD FAILED: $result" else "BUILD SUCCESSFUL") @@ -128,6 +132,8 @@ private class Main @Inject constructor( val pluginInfo = PluginInfo(pluginInfoDescription) try { allProjects = buildFileCompilerFactory.create(listOf(buildFile), pluginInfo).compileBuildFiles(args) + } catch(ex: KobaltException) { + throw ex } catch(ex: Throwable) { // This can happen if the ABI for the build script file changed. Try to wipe .kobalt. log(2, "Couldn't parse preBuildScript.jar: ${ex.message}")