mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -07:00
Merge branch 'master' of github.com:cbeust/kobalt
This commit is contained in:
commit
2a545b6638
4 changed files with 22 additions and 19 deletions
|
@ -242,22 +242,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}")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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,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.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 +92,10 @@ 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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue