From 204ca452e54ff1ebad97363f0f78e75bbe40f671 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 7 Mar 2017 13:24:49 -0800 Subject: [PATCH] Allow variables in buildScript{}. Fixes https://github.com/cbeust/kobalt/issues/340 --- .../src/main/kotlin/com/beust/kobalt/misc/BlockExtractor.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/BlockExtractor.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/BlockExtractor.kt index f8c3d76e..4a5c56ab 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/BlockExtractor.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/BlockExtractor.kt @@ -21,6 +21,7 @@ class BlockExtractor(val regexp: Pattern, val opening: Char, val closing: Char) var foundClosing = false var count = 0 val result = StringBuffer() + val topLines = arrayListOf() fun updateCount(line: String) { val currentLine = StringBuffer() @@ -46,8 +47,10 @@ class BlockExtractor(val regexp: Pattern, val opening: Char, val closing: Char) if (found) { foundKeyword = true count = 1 + result.append(topLines.joinToString("\n")) result.append(line).append("\n") } else { + topLines.add(line) updateCount(line) }