diff options
Diffstat (limited to 'test_project/app/build.gradle.kts')
| -rw-r--r-- | test_project/app/build.gradle.kts | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/test_project/app/build.gradle.kts b/test_project/app/build.gradle.kts new file mode 100644 index 0000000..7a9492d --- /dev/null +++ b/test_project/app/build.gradle.kts @@ -0,0 +1,71 @@ +plugins { + id("com.android.application") +} + +android { + namespace = "org.the_jk.testproject" + compileSdk { + version = release(37) + } + + defaultConfig { + applicationId = "org.the_jk.testproject" + minSdk = 26 + targetSdk = 37 + versionCode = 1 + versionName = "1.0" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + optimization { + enable = true + packageScope = setOf("androidx.**", "kotlin.**", "kotlinx.**") + } + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } +} + +dependencies { + implementation(libs.androidx.appcompat) + implementation(libs.androidx.core.ktx) + implementation(libs.material) + testImplementation(libs.junit) + androidTestImplementation(libs.androidx.espresso.core) + androidTestImplementation(libs.androidx.junit) +} + +// ---- 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. +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", + "org.jetbrains.kotlin:kotlin-reflect:1.6.10", + "org.jetbrains.kotlin:kotlin-daemon-embeddable:2.2.10", + "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.8.0", + "org.jetbrains:annotations:13.0", +) +afterEvaluate { + try { + val cfg = configurations.getByName("kotlinCompilerClasspath") + cfg.dependencies.add(dependencies.create(files(proxyStub))) + realCompilerJars.forEach { cfg.dependencies.add(dependencies.create(it)) } + logger.lifecycle("kotlin-proxy: AGP stub present=" + proxyStub.exists() + + " ORDER=" + cfg.files.joinToString(",") { it.name }) + } catch (t: Throwable) { + logger.lifecycle("kotlin-proxy: AGP injection FAILED: " + t) + } +} |
