diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2026-11-07 11:00:16 +0100 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2026-11-07 11:00:16 +0100 |
| commit | e7ad22515e1d79f02f8cf2c88435e26854552a46 (patch) | |
| tree | e237ab8083b2919f8ddd18af762e9a03f01a1919 /test_project/app | |
| parent | 64223f61fc8413ad69ba0e814fbbc552a6c57c33 (diff) | |
Bump kotlin to 2.4.21
Support <clinit>
Diffstat (limited to 'test_project/app')
| -rw-r--r-- | test_project/app/build.gradle.kts | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/test_project/app/build.gradle.kts b/test_project/app/build.gradle.kts index 7a9492d..8938318 100644 --- a/test_project/app/build.gradle.kts +++ b/test_project/app/build.gradle.kts @@ -42,29 +42,44 @@ dependencies { } // ---- kotlin-proxy: force our compiler stub to the FRONT of the daemon classpath ---- -// KGP seeds the daemon classpath via `kotlinCompilerClasspath` using -// defaultDependencies (kotlin-compiler-embeddable + transitives). Adding ANY -// regular dependency suppresses those defaults - so we re-declare the real -// compiler modules as regular deps WITH our stub jar FIRST. The daemon then -// loads org.jetbrains.kotlin.cli.jvm.K2JVMCompiler from OUR stub, replacing -// the real compiler with our alternative. +// KGP seeds the daemon classpath with hidden defaultDependencies; adding ANY +// regular dependency suppresses those defaults - so we re-declare the same +// modules as regular deps WITH our stub jar FIRST. The daemon then loads +// org.jetbrains.kotlin.cli.jvm.K2JVMCompiler from OUR stub, replacing the +// real compiler with our alternative. +// +// KGP >= 2.3.20 runs JVM compilation through the Build Tools API by default: +// the daemon classpath is the resolved `kotlinBuildToolsApiClasspath` +// (defaults: kotlin-build-tools-compat + kotlin-build-tools-impl, whose +// closure IS the compiler). The older `kotlinCompilerClasspath` still +// feeds the legacy path (kotlin.compiler.runViaBuildToolsApi=false, +// deprecated, removed in KGP 2.5.0). We shadow both. val proxyStub = file("/home/the_jk/source/kotlin_proxy/dist/kotlin-proxy-compiler-stubs.jar") -val realCompilerJars = listOf( - "org.jetbrains.kotlin:kotlin-compiler-embeddable:2.2.10", - "org.jetbrains.kotlin:kotlin-stdlib:2.2.10", - "org.jetbrains.kotlin:kotlin-script-runtime:2.2.10", +val kotlinVersion = libs.versions.kotlin.get() +// legacy path: the kotlinCompilerClasspath default (kotlin-compiler-embeddable +// + its transitive deps). reflect stays at 1.6.10 - the POM pin. +val legacyCompilerJars = listOf( + "org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlinVersion", + "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion", + "org.jetbrains.kotlin:kotlin-script-runtime:$kotlinVersion", "org.jetbrains.kotlin:kotlin-reflect:1.6.10", - "org.jetbrains.kotlin:kotlin-daemon-embeddable:2.2.10", + "org.jetbrains.kotlin:kotlin-daemon-embeddable:$kotlinVersion", "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.8.0", "org.jetbrains:annotations:13.0", ) afterEvaluate { try { + val bta = configurations.getByName("kotlinBuildToolsApiClasspath") + bta.dependencies.add(dependencies.create(files(proxyStub))) + bta.dependencies.add(dependencies.create( + "org.jetbrains.kotlin:kotlin-build-tools-compat:$kotlinVersion")) + bta.dependencies.add(dependencies.create( + "org.jetbrains.kotlin:kotlin-build-tools-impl:$kotlinVersion")) val cfg = configurations.getByName("kotlinCompilerClasspath") cfg.dependencies.add(dependencies.create(files(proxyStub))) - realCompilerJars.forEach { cfg.dependencies.add(dependencies.create(it)) } + legacyCompilerJars.forEach { cfg.dependencies.add(dependencies.create(it)) } logger.lifecycle("kotlin-proxy: AGP stub present=" + proxyStub.exists() + - " ORDER=" + cfg.files.joinToString(",") { it.name }) + " BTA ORDER=" + bta.files.joinToString(",") { it.name }) } catch (t: Throwable) { logger.lifecycle("kotlin-proxy: AGP injection FAILED: " + t) } |
