plugins {
    kotlin("jvm")
    `java-library`
}

// V3.5 — Cross-platform parity gate.
//
// This module compiles as a pure-JVM Kotlin library so CI can run the
// cross-platform vector tests without an Android SDK. The protocol code
// is JVM-safe (no `android.*` imports); only Tink + java.* are used.
//
// When KeystoreStorage and EncryptedSharedPreferences-backed adapters land
// (M-Cross 4 + V3.5 §Storage), they will live in a sibling Android Library
// module that depends on this one.

java {
    sourceCompatibility = JavaVersion.VERSION_17
    targetCompatibility = JavaVersion.VERSION_17
}

kotlin {
    compilerOptions {
        jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
    }
}

dependencies {
    // Google Tink for X25519, Ed25519, AES-GCM, HMAC, HKDF (JVM build).
    // The same `subtle.*` API as `tink-android` so the source compiles unchanged.
    implementation("com.google.crypto.tink:tink:1.15.0")

    // Bouncy Castle for scrypt + argon2id. Tink doesn't ship password
    // KDFs; @shade/storage-encrypted uses @noble/hashes for both. We
    // pin to the JDK18-on artifact so it works on JVM 17 + Android.
    implementation("org.bouncycastle:bcprov-jdk18on:1.78.1")

    // JSON serialization (session state + test-vector loader on JVM).
    implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3")

    // Coroutines (StorageProvider uses `suspend` functions).
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0")

    // org.json — bundled with Android but not present on the JVM classpath.
    implementation("org.json:json:20240303")

    testImplementation("junit:junit:4.13.2")
    testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0")
}

tasks.withType<Test>().configureEach {
    useJUnit()
    testLogging {
        events("passed", "failed", "skipped")
        showStandardStreams = false
    }
}
