From d3882914273faad7eedbc08db1a4ba3d6c791c55 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 3 Nov 2015 21:03:56 -0800 Subject: [PATCH] Handle ABI changes better. --- src/main/kotlin/com/beust/kobalt/Main.kt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/Main.kt b/src/main/kotlin/com/beust/kobalt/Main.kt index 6f5f2d3b..852a391f 100644 --- a/src/main/kotlin/com/beust/kobalt/Main.kt +++ b/src/main/kotlin/com/beust/kobalt/Main.kt @@ -120,14 +120,15 @@ private class Main @Inject constructor( try { allProjects = buildFileCompilerFactory.create(listOf(buildFile)).compileBuildFiles(args) } catch(ex: Throwable) { - error("Couldn't build", ex.cause ?: ex) + // 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}") -// if (! File(".kobalt").deleteRecursively()) { -// warn("Couldn't delete .kobalt, please delete it manually") -// } else { -// log(1, "Deleted .kobalt") -// allProjects = buildFileCompilerFactory.create(listOf(buildFile)).compileBuildFiles(args) -// } + if (! File(".kobalt").deleteRecursively()) { + warn("Couldn't delete the .kobalt directory, please delete it manually and try again") + return 1 + } else { + log(1, "Deleted .kobalt") + allProjects = buildFileCompilerFactory.create(listOf(buildFile)).compileBuildFiles(args) + } } if (args.tasks) {