Skip to content

Commit

Permalink
Closes #17: NoClassDefFoundError: kotlin.time.DurationKt
Browse files Browse the repository at this point in the history
  • Loading branch information
asarkar authored and Abhijit Sarkar committed Aug 5, 2020
2 parents 70052f8 + ed35c82 commit c7edcc5
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ tasks.withType<Test> {

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict", "-Xopt-in=kotlin.time.ExperimentalTime")
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "1.8"
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pluginImplementationClass = org.asarkar.gradle.BuildTimeTrackerPlugin
pluginDeclarationName = buildTimeTrackerPlugin

projectGroup = org.asarkar.gradle
projectVersion = 2.0.2
projectVersion = 2.0.3

jUnit5Version = 5.6.2
assertJVersion = 3.16.1
Expand Down
8 changes: 2 additions & 6 deletions src/main/kotlin/org/asarkar/gradle/ConsolePrinter.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package org.asarkar.gradle

import java.io.PrintStream
import java.time.Duration
import kotlin.math.round
import kotlin.time.DurationUnit
import kotlin.time.ExperimentalTime
import kotlin.time.toDuration

class ConsolePrinter(private val out: PrintStream = System.out) : Printer {
@ExperimentalTime
override fun print(input: PrinterInput) {
// find the maxes needed for formatting
val (maxLabelLen, maxDuration, maxFormattedDurationLen) = input.taskDurations.fold(
Expand Down Expand Up @@ -47,10 +44,9 @@ class ConsolePrinter(private val out: PrintStream = System.out) : Printer {
const val BLOCK_STR = "\u2588"

private fun Long.percentOf(buildDuration: Long): Int = round(this / buildDuration.toDouble() * 100).toInt()
@ExperimentalTime
internal fun Long.format(): String {
val separators = setOf('P', 'D', 'T')
return this.toDuration(DurationUnit.SECONDS).toIsoString()
return Duration.ofSeconds(this).toString()
.filterNot { it in separators }
}
private fun Int.format(): String = String.format("%d%%", this)
Expand Down
2 changes: 1 addition & 1 deletion src/test/kotlin/org/asarkar/gradle/ConsolePrinterTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ class ConsolePrinterTest {
arguments(3900, "1H5M"),
arguments(61, "1M1S"),
arguments(172800, "48H"),
arguments(172859, "48H0M59S")
arguments(172859, "48H59S")
)
}
}
Expand Down

0 comments on commit c7edcc5

Please sign in to comment.