is Klock supported in Kotlin 1.4 M2 ? I've added i...
# korge
j
is Klock supported in Kotlin 1.4 M2 ? I've added it to build.gradle.kts
Copy code
val commonMain by getting {
            dependencies {
                implementation(kotlin("stdlib-common"))
                implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serializationVersion")
                implementation("com.soywiz.korlibs.klock:klock:1.10.3")
settings.gradle.kts
Copy code
enableFeaturePreview("GRADLE_METADATA")
when i use this snippet to test it
Copy code
import com.soywiz.klock.DateTimeTz

fun main() {

    val local = DateTimeTz.nowLocal()
    println(local)
    println(local.toString("yyyy-MM-dd"))
gradle build complains about
Unresolved reference: soywiz
d
Not yet. Planned to start a -M2 version this week or next week as much for all the libraries
j
awesome, thanks Carlos!
d
Not sure if when I start that there is the next milestone or the RC
but that could take a few weeks still. So when I start I will target M2 if RC is not ready yet by then
j
i'm happy to wait, hopefully by the time my applications goes into production, 1.4 is out will put in date time functionality last, mostly using it for validation and some cosmetic things
will do server-side-only validation for now
i'm checking out the other Kor Libs and Korge, looks amazing!
d
nice 🙂 you should be able to use the current version as long as you are not using Kotlin/Native
j
only JVM/JS for now, Native and Android early next year only
d
And 1.11.12 doesn't work?
have you jcenter included?
j
let me try 1.11.12, i have jcenter included already
got carried away making a hybrid Delegates.observable fused with a Delegates.vetoable
Copy code
public inline fun <T> Delegates.validatable(
    initialValue: T,
    crossinline validate: (property: KProperty<*>, oldValue: T, newValue: T) -> Boolean,
    crossinline onChange: (property: KProperty<*>, oldValue: T, newValue: T) -> Unit,
): ReadWriteProperty<Any?, T> = object : ObservableProperty<T>(initialValue) {

    override fun beforeChange(property: KProperty<*>, oldValue: T, newValue: T): Boolean {
        return validate(property, oldValue, newValue)
    }

    override fun afterChange(property: KProperty<*>, oldValue: T, newValue: T) {
        return onChange(property, oldValue, newValue)
    }

}
same error on 1.11.12
Copy code
sourceSets {

        val serializationVersion = "0.20.0-1.4-M2"
        val klockVersion = "1.11.12"

        val commonMain by getting {
            dependencies {
                implementation(kotlin("stdlib-common"))
                implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serializationVersion")
                implementation("com.soywiz.korlibs.klock:klock:$klockVersion")
Unresolved reference: soywiz
this import is in
src/commonMain
Copy code
import com.soywiz.klock.DateTimeTz
d
and in the external libraries panel is there the klock library?
would work?
Copy code
implementation("com.soywiz.korlibs.klock:klock-metadata:$klockVersion")
j
yep, i do see it there, JVM and JS
d
then I don't know
j
i'll try turning it off and on again 😄
I'll dig tomorrow when i'm fresh, it's pass midnight and i'm probably missing something small somewhere
if i manually add klock-metadata, it gives me a little more to work with
Copy code
* What went wrong:
Could not determine the dependencies of task ':jsPackageJson'.
> Could not resolve all dependencies for configuration ':jsNpm'.
   > Could not resolve com.soywiz.korlibs.klock:klock-metadata:1.11.12.
     Required by:
         project :
      > No matching variant of com.soywiz.korlibs.klock:klock-metadata:1.11.12 was found. The consumer was configured to find a usage of 'kotlin-runtime' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js', attribute 'org.jetbrains.kotlin.js.compiler' with value 'ir' but:
          - Variant 'metadata-api' capability com.soywiz.korlibs.klock:klock-metadata:1.11.12:
              - Incompatible because this component declares a usage of 'kotlin-api' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common' and the consumer needed a usage of 'kotlin-runtime' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js'
              - Other compatible attribute:
                  - Doesn't say anything about org.jetbrains.kotlin.js.compiler (required 'ir')
in case it's relevant, i'm using IR mode which is new in Kotlin 1.4
Copy code
kotlin {
    jvm {
        compilations.all {
            kotlinOptions.jvmTarget = "11"
        }
    }
    js(IR) {
        browser {
            binaries.executable()
            webpackTask {
                output.libraryTarget = UMD
                //output.libraryTarget = COMMONJS
                //output.libraryTarget = AMD
            }
        }
    }
d
ohh, yeah, I will have to compile klock in both mode
so it supports ir too
a
Kotlin 1.4 is not binary compatible with 1.3, so all libs have to be compiled with the kotlin 1.4 compiler