diff options
author | Andrzej Ratajczak <andrzej.ratajczak98@gmail.com> | 2020-02-03 15:57:29 +0100 |
---|---|---|
committer | Andrzej Ratajczak <andrzej.ratajczak98@gmail.com> | 2020-02-04 12:10:59 +0100 |
commit | 582f5f89557e943169c10a4fc3d58d99528d8e86 (patch) | |
tree | eec837f5f235228df91659663b71fc4f0c281495 /runners | |
parent | 3a13b81f2aebc255bec5e48b276c86b2d4ee16a2 (diff) | |
download | dokka-582f5f89557e943169c10a4fc3d58d99528d8e86.tar.gz dokka-582f5f89557e943169c10a4fc3d58d99528d8e86.tar.bz2 dokka-582f5f89557e943169c10a4fc3d58d99528d8e86.zip |
Adds summary reporting for all logging runners
Diffstat (limited to 'runners')
-rw-r--r-- | runners/ant/src/main/kotlin/ant/dokka.kt | 18 | ||||
-rw-r--r-- | runners/cli/src/main/kotlin/cli/main.kt | 6 |
2 files changed, 19 insertions, 5 deletions
diff --git a/runners/ant/src/main/kotlin/ant/dokka.kt b/runners/ant/src/main/kotlin/ant/dokka.kt index 1395af31..6b83fc8f 100644 --- a/runners/ant/src/main/kotlin/ant/dokka.kt +++ b/runners/ant/src/main/kotlin/ant/dokka.kt @@ -7,15 +7,29 @@ import org.apache.tools.ant.types.Path import org.apache.tools.ant.types.Reference import org.jetbrains.dokka.* import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink +import org.jetbrains.dokka.utilities.DokkaConsoleLogger import org.jetbrains.dokka.utilities.DokkaLogger import java.io.File class AntLogger(val task: Task): DokkaLogger { + override var warningsCount: Int = 0 + override var errorsCount: Int = 0 override fun debug(message: String) = task.log(message, Project.MSG_DEBUG) override fun info(message: String) = task.log(message, Project.MSG_VERBOSE) override fun progress(message: String) = task.log(message, Project.MSG_INFO) - override fun warn(message: String) = task.log(message, Project.MSG_WARN) - override fun error(message: String) = task.log(message, Project.MSG_ERR) + override fun warn(message: String) = task.log(message, Project.MSG_WARN).also { warningsCount++ } + override fun error(message: String) = task.log(message, Project.MSG_ERR).also { errorsCount++ } + override fun report() { + if (warningsCount > 0 || errorsCount > 0) { + task.log("Generation completed with $warningsCount warning" + + (if(warningsCount == 1) "" else "s") + + " and $errorsCount error" + + if(errorsCount == 1) "" else "s" + ) + } else { + task.log("generation completed successfully") + } + } } class AntSourceLinkDefinition(var path: String? = null, var url: String? = null, var lineSuffix: String? = null) diff --git a/runners/cli/src/main/kotlin/cli/main.kt b/runners/cli/src/main/kotlin/cli/main.kt index 2daac470..db8ddb01 100644 --- a/runners/cli/src/main/kotlin/cli/main.kt +++ b/runners/cli/src/main/kotlin/cli/main.kt @@ -196,9 +196,9 @@ object MainKt { val javaHome = System.getProperty("java.home") val default = File(javaHome, "../lib/tools.jar") val mac = File(javaHome, "../Classes/classes.jar") - when { - default.exists() -> return default - mac.exists() -> return mac + return when { + default.exists() -> default + mac.exists() -> mac else -> { throw Exception("tools.jar not found, please check it, also you can provide it manually, using -cp") } |