The best way to control Claude Code, Codex and more from any computer or phone
| 1 | plugins { id 'java' } |
| 2 | |
| 3 | repositories { |
| 4 | mavenCentral() |
| 5 | google() |
| 6 | } |
| 7 | |
| 8 | configurations { |
| 9 | compiler |
| 10 | androidTestAars |
| 11 | } |
| 12 | |
| 13 | dependencies { |
| 14 | compiler 'org.jetbrains.kotlin:kotlin-compiler-embeddable:2.2.21' |
| 15 | testImplementation 'org.jetbrains.kotlin:kotlin-stdlib:2.2.21' |
| 16 | testImplementation 'junit:junit:4.13.2' |
| 17 | testImplementation('org.robolectric:robolectric:4.16.1') { |
| 18 | exclude group: 'androidx.test', module: 'monitor' |
| 19 | exclude group: 'androidx.test.espresso', module: 'espresso-idling-resource' |
| 20 | } |
| 21 | // Compile against the same API used by @Config(sdk = [35]), without a local Android SDK. |
| 22 | testImplementation 'org.robolectric:android-all:15-robolectric-12650502' |
| 23 | androidTestAars 'androidx.test:monitor:1.8.0@aar' |
| 24 | androidTestAars 'androidx.test.espresso:espresso-idling-resource:3.7.0@aar' |
| 25 | testImplementation files(layout.buildDirectory.dir('android-test-jars').map { |
| 26 | fileTree(it) { include '**/*.jar' } |
| 27 | }) |
| 28 | } |
| 29 | |
| 30 | // The JVM plugin cannot load classes.jar inside AndroidX AAR dependencies. |
| 31 | tasks.register('extractAndroidTestJars') { |
| 32 | inputs.files configurations.androidTestAars |
| 33 | outputs.dir layout.buildDirectory.dir('android-test-jars') |
| 34 | doLast { |
| 35 | configurations.androidTestAars.each { aar -> |
| 36 | copy { |
| 37 | from zipTree(aar) |
| 38 | include 'classes.jar' |
| 39 | filePermissions { unix('644') } |
| 40 | into layout.buildDirectory.dir("android-test-jars/${aar.name}") |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | def moduleRoot = file('../..') |
| 47 | // Count decoder entry without replacing the production executor, parser, or lifecycle. |
| 48 | def instrumentedView = layout.buildDirectory.file('token-fixture/T3ReviewDiffView.kt') |
| 49 | tasks.register('instrumentTokenFixture') { |
| 50 | def original = file("${moduleRoot}/android/src/main/java/expo/modules/t3reviewdiff/T3ReviewDiffView.kt") |
| 51 | inputs.file original |
| 52 | outputs.file instrumentedView |
| 53 | doLast { |
| 54 | def source = original.text |
| 55 | def decode = ' val decodedTokens = parseTokensObject(value)' |
| 56 | def publish = ' canvasView.tokensByRowId = decodedTokens' |
| 57 | assert source.count(decode) == 1 |
| 58 | assert source.count(publish) == 1 |
| 59 | source = source.replace(decode, ' TokenDecodeProbe.enter()\n' + decode) |
| 60 | source = source.replace(publish, publish + '\n TokenDecodeProbe.publish()') |
| 61 | def destination = instrumentedView.get().asFile |
| 62 | destination.parentFile.mkdirs() |
| 63 | destination.text = source |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | def sources = files( |
| 68 | instrumentedView, |
| 69 | fileTree('stubs') { include '**/*.kt' }, |
| 70 | fileTree('src/test/kotlin') { include '**/*.kt' }, |
| 71 | fileTree("${moduleRoot}/android/src/test/java") { include '**/*.kt' }, |
| 72 | fileTree("${moduleRoot}/android/src/main/java/expo/modules/t3reviewdiff") { |
| 73 | include '**/*.kt' |
| 74 | exclude '**/T3ReviewDiffModule.kt', '**/T3ReviewDiffView.kt' |
| 75 | }, |
| 76 | ) |
| 77 | |
| 78 | tasks.register('compileRegression', JavaExec) { |
| 79 | dependsOn 'extractAndroidTestJars', 'instrumentTokenFixture' |
| 80 | classpath = configurations.compiler |
| 81 | mainClass = 'org.jetbrains.kotlin.cli.jvm.K2JVMCompiler' |
| 82 | inputs.files sources, configurations.testCompileClasspath |
| 83 | outputs.dir layout.buildDirectory.dir('regression') |
| 84 | doFirst { |
| 85 | args = [ |
| 86 | '-no-stdlib', '-no-reflect', '-jvm-target', '17', |
| 87 | '-classpath', configurations.testCompileClasspath.asPath, |
| 88 | '-d', layout.buildDirectory.dir('regression').get().asFile.absolutePath, |
| 89 | ] + sources.files.collect { it.absolutePath } |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | test { |
| 94 | dependsOn 'compileRegression' |
| 95 | testClassesDirs = files(layout.buildDirectory.dir('regression')) |
| 96 | classpath = files(testClassesDirs, configurations.testRuntimeClasspath) |
| 97 | testLogging { events 'passed', 'failed'; exceptionFormat 'full' } |
| 98 | } |