Skip to content

develop: compileCommonMainKotlinMetadata and compileKotlinJs fail on basic stdlib references #105

@michalharakal

Description

@michalharakal

Summary

Building from origin/develop (HEAD 52ff395), compileCommonMainKotlinMetadata and compileKotlinJs for :llm-api, :llm-core, and :llm-performance fail with fundamental stdlib references unresolved in commonMainUnit, String, Int, Long, AutoCloseable, JvmOverloads, JvmField, emptyList, listOf, firstOrNull, etc.

compileKotlinJvm works fine. The metadata + JS targets behave as if the Kotlin commonMain stdlib is not on their compile classpath at all.

Effect: publishKotlinMultiplatformPublicationToMavenLocal (and Maven Central) cannot complete, so the unsuffixed root multiplatform artifacts (skainet-transformers-api, skainet-transformers-core, skainet-transformers-inference-bert) cannot be produced. Only *-jvm per-target artifacts get published. Downstream Gradle consumers depending on skainet-transformers-api:0.23.0 (no suffix) cannot resolve.

Reproducer

git checkout develop
./gradlew :llm-api:compileCommonMainKotlinMetadata --no-daemon

Output (truncated):

e: …/llm-api/src/commonMain/kotlin/sk/ainet/llm/api/ChatModel.kt:17:30 Unresolved reference 'AutoCloseable'.
e: …/llm-api/src/commonMain/kotlin/sk/ainet/llm/api/ChatOptions.kt:3:15 Unresolved reference 'jvm'.
e: …/llm-api/src/commonMain/kotlin/sk/ainet/llm/api/ChatOptions.kt:13:32 Unresolved reference 'JvmOverloads'.
e: …/llm-api/src/commonMain/kotlin/sk/ainet/llm/api/ChatOptions.kt:14:23 Unresolved reference 'String'.
e: …/llm-api/src/commonMain/kotlin/sk/ainet/llm/api/ChatOptions.kt:16:22 Unresolved reference 'Int'.
e: …/llm-api/src/commonMain/kotlin/sk/ainet/llm/api/ChatOptions.kt:19:31 Unresolved reference 'List'.
… (~50 similar lines across all .kt files in commonMain)

Same symptom in :llm-core and :llm-performance.

Likely cause

llm-api/build.gradle.kts:53, llm-core/build.gradle.kts:46, and llm-performance/build.gradle.kts:55 all use:

commonMain.dependencies {
    api(kotlin("stdlib-common"))
    ...
}

In Kotlin 2.x (this repo pins kotlin = "2.3.21" in libs.versions.toml), kotlin-stdlib-common was unified into kotlin-stdlib. The kotlin("stdlib-common") artifact now resolves to a stub or empty classpath, leaving commonMain without its stdlib. The kotlin-multiplatform Gradle plugin would normally add kotlin-stdlib to commonMain automatically — except the explicit api(kotlin("stdlib-common")) overrides/replaces that.

(Patching the three call sites to api(kotlin("stdlib")) did not fix the metadata compile in my local test, so there may be a second issue with how the metadata classpath is constructed — but the deprecated stdlib-common is the obvious starting point.)

Suggested fix

  1. Replace api(kotlin("stdlib-common")) with api(kotlin("stdlib")) in the three modules above. Or remove the explicit dependency entirely — the kotlin-multiplatform plugin auto-adds the stdlib.
  2. Add a CI job that runs ./gradlew publishToMavenLocal (or at minimum compileCommonMainKotlinMetadata for every multiplatform module) so this kind of regression catches before release.

Workaround for downstream

Publish only JVM publications and bypass the multiplatform metadata module:

./gradlew \
  :llm-bom:publishToMavenLocal \
  :llm-api:publishJvmPublicationToMavenLocal \
  :llm-core:publishJvmPublicationToMavenLocal \
  :llm-agent:publishJvmPublicationToMavenLocal \
  :llm-providers:publishMavenPublicationToMavenLocal \
  :llm-inference:bert:publishJvmPublicationToMavenLocal \
  -PVERSION_NAME=0.23.0 -PsignAllPublications=false
# strip stale Gradle metadata so consumers fall back to POMs
find ~/.m2/repository/sk/ainet/transformers -name "*-0.23.0.module" -delete

Consumer then depends on skainet-transformers-api-jvm etc. directly. Verified working end-to-end in michalharakal/SKaiNET-leaf-cli (built shadow JAR, CLI runs).

Why this matters

A real Maven Central release of 0.23.0 cannot be cut while this is broken. The unsuffixed root multiplatform artifacts are what consumers reference (e.g., implementation("sk.ainet.transformers:skainet-transformers-api:0.23.0")); without them, every downstream needs the workaround above.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions