From d157be9a186277f164d7f26c44c24bf178fce978 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Fri, 21 Apr 2017 20:04:27 -0700 Subject: [PATCH 1/5] Made warn() work like error() with provided message. --- .../main/kotlin/com/beust/kobalt/misc/KobaltLogger.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/KobaltLogger.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/KobaltLogger.kt index 1d235a44..54de1d36 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/KobaltLogger.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/KobaltLogger.kt @@ -1,6 +1,9 @@ package com.beust.kobalt.misc -import com.beust.kobalt.* +import com.beust.kobalt.Args +import com.beust.kobalt.AsciiArt +import com.beust.kobalt.Constants +import com.beust.kobalt.KobaltException import com.beust.kobalt.api.Kobalt import com.beust.kobalt.maven.aether.Exceptions import java.lang.Exception @@ -75,7 +78,7 @@ class Logger(val dev: Boolean) { fun error(tag: String, message: CharSequence, e: Throwable? = null) { val docUrl = if (e is KobaltException && e.docUrl != null) e.docUrl else null - val text = if (! message.isBlank()) message + val text = if (message.isNotBlank()) message else if (e != null && (! e.message.isNullOrBlank())) e.message else { e?.toString() } val shortMessage = "***** E $text " + if (docUrl != null) " Documentation: $docUrl" else "" @@ -88,7 +91,9 @@ class Logger(val dev: Boolean) { } fun warn(tag: String, message: CharSequence, e: Throwable? = null) { - val fullMessage = "***** WARNING " + (e?.message ?: message) + val fullMessage = "***** WARNING " + if (message.isNotBlank()) message + else if (e != null && (!e.message.isNullOrBlank())) e.message + else e?.toString() println(AsciiArt.Companion.warnColor(getPattern("W", fullMessage, fullMessage, tag))) if (KobaltLogger.LOG_LEVEL > 1 && e != null) { Exceptions.printStackTrace(e) From a10777ee1d3f1722363ff5ac72262a38c6a0404a Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Fri, 21 Apr 2017 21:25:35 -0700 Subject: [PATCH 2/5] Fix the duplicate compiler args bug. --- src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt index d8a1d153..b14244c3 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinCompiler.kt @@ -145,7 +145,6 @@ class KotlinCompiler @Inject constructor( // Collect the compiler args from kotlinCompiler{} and from settings.xml and parse them val args2 = info.compilerArgs + - (kotlinConfig(project)?.args ?: arrayListOf()) + (settings.kobaltCompilerFlags?.split(" ") ?: listOf()) val args = K2JVMCompilerArguments() val compiler = K2JVMCompiler() From 3a41868824ce4461e602971ee68be4de41d7718a Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Fri, 21 Apr 2017 21:25:52 -0700 Subject: [PATCH 3/5] 1.0.73. --- kobalt/wrapper/kobalt-wrapper.properties | 2 +- src/main/resources/kobalt.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index 9709019c..13f99ced 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=1.0.71 \ No newline at end of file +kobalt.version=1.0.73 \ No newline at end of file diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index 3bb86711..401bc33c 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=1.0.71 +kobalt.version=1.0.73 From c768507ed504b9b9b057dff7795e32d349360c46 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Fri, 21 Apr 2017 22:18:56 -0700 Subject: [PATCH 4/5] Reformat. --- .../main/kotlin/com/beust/kobalt/misc/KobaltLogger.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/KobaltLogger.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/KobaltLogger.kt index 54de1d36..67d31496 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/KobaltLogger.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/KobaltLogger.kt @@ -78,7 +78,8 @@ class Logger(val dev: Boolean) { fun error(tag: String, message: CharSequence, e: Throwable? = null) { val docUrl = if (e is KobaltException && e.docUrl != null) e.docUrl else null - val text = if (message.isNotBlank()) message + val text = + if (message.isNotBlank()) message else if (e != null && (! e.message.isNullOrBlank())) e.message else { e?.toString() } val shortMessage = "***** E $text " + if (docUrl != null) " Documentation: $docUrl" else "" @@ -91,9 +92,10 @@ class Logger(val dev: Boolean) { } fun warn(tag: String, message: CharSequence, e: Throwable? = null) { - val fullMessage = "***** WARNING " + if (message.isNotBlank()) message - else if (e != null && (!e.message.isNullOrBlank())) e.message - else e?.toString() + val fullMessage = "***** WARNING " + + if (message.isNotBlank()) message + else if (e != null && (!e.message.isNullOrBlank())) e.message + else e?.toString() println(AsciiArt.Companion.warnColor(getPattern("W", fullMessage, fullMessage, tag))) if (KobaltLogger.LOG_LEVEL > 1 && e != null) { Exceptions.printStackTrace(e) From cc481a4a7fe3ae58bf70ad39157047d49bdea64a Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Fri, 21 Apr 2017 23:02:59 -0700 Subject: [PATCH 5/5] GH-423: Overwrite files on Windows too. Fixes https://github.com/cbeust/kobalt/issues/423 --- .../kotlin/com/beust/kobalt/misc/KFiles.kt | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/KFiles.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/KFiles.kt index 15c2a15d..36efd995 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/KFiles.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/KFiles.kt @@ -227,22 +227,18 @@ class KFiles { private fun isWindows() = System.getProperty("os.name").contains("Windows") fun copy(from: Path?, to: Path?, option: StandardCopyOption = StandardCopyOption.REPLACE_EXISTING) { - if (isWindows() && to!!.toFile().exists()) { - kobaltLog(2, "Windows detected, not overwriting $to") - } else { - try { - if (from != null && to != null) { - if (!Files.exists(to) || Md5.toMd5(from.toFile()) != Md5.toMd5(to.toFile())) { - kobaltLog(3, "Copy from $from to $to") - Files.copy(from, to, option) - } else { - kobaltLog(3, " Not copying, indentical files: $from $to") - } + try { + if (from != null && to != null) { + if (!Files.exists(to) || Md5.toMd5(from.toFile()) != Md5.toMd5(to.toFile())) { + kobaltLog(3, "Copy from $from to $to") + Files.copy(from, to, option) + } else { + kobaltLog(3, " Not copying, indentical files: $from $to") } - } catch(ex: IOException) { - // Windows is anal about this - kobaltLog(1, "Couldn't copy $from to $to: ${ex.message}") } + } catch(ex: IOException) { + // Windows is anal about this + kobaltLog(1, "Couldn't copy $from to $to: ${ex.message}") } }