Skip to content

Commit 08a1fb4

Browse files
authored
ADFA-3365: include Kotlin analysis api as dependency (#1098)
* fix: add ability to re-write class name references in desugar plugin * feat: integrate Kotlin analysis API * fix: update kotlin-android to latest version fixes duplicate class errors for org.antrl.v4.* classes * fix: remove UnsafeImpl It is now included in the embeddable JAR (named UnsafeAndroid) with proper relocations. * fix: update kotlin-android to latest version * fix: update to the latest kotlin-android version * fix: bring-back license headers * fix: organize imports * fix: remove unused class Signed-off-by: Akash Yadav <akashyadav@appdevforall.org>
1 parent d97edf7 commit 08a1fb4

File tree

21 files changed

+265
-252
lines changed

21 files changed

+265
-252
lines changed

annotation-processors/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717

1818
import com.itsaky.androidide.build.config.BuildConfig
19+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
1920
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2021

2122
plugins {
@@ -45,5 +46,5 @@ dependencies {
4546
}
4647

4748
tasks.withType<KotlinCompile> {
48-
kotlinOptions.jvmTarget = "17"
49+
compilerOptions.jvmTarget.set(JvmTarget.JVM_17)
4950
}

app/build.gradle.kts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,29 @@ android {
153153

154154
packaging {
155155
resources {
156-
excludes.add("META-INF/DEPENDENCIES")
157-
excludes.add("META-INF/gradle/incremental.annotation.processors")
156+
excludes += "META-INF/DEPENDENCIES"
157+
excludes += "META-INF/gradle/incremental.annotation.processors"
158+
159+
pickFirsts += "kotlin/internal/internal.kotlin_builtins"
160+
pickFirsts += "kotlin/reflect/reflect.kotlin_builtins"
161+
pickFirsts += "kotlin/kotlin.kotlin_builtins"
162+
pickFirsts += "kotlin/coroutines/coroutines.kotlin_builtins"
163+
pickFirsts += "kotlin/ranges/ranges.kotlin_builtins"
164+
pickFirsts += "kotlin/concurrent/atomics/atomics.kotlin_builtins"
165+
pickFirsts += "kotlin/collections/collections.kotlin_builtins"
166+
pickFirsts += "kotlin/annotation/annotation.kotlin_builtins"
167+
168+
pickFirsts += "META-INF/FastDoubleParser-LICENSE"
169+
pickFirsts += "META-INF/thirdparty-LICENSE"
170+
pickFirsts += "META-INF/FastDoubleParser-NOTICE"
171+
pickFirsts += "META-INF/thirdparty-NOTICE"
158172
}
159173

160174
jniLibs {
161175
useLegacyPackaging = false
162176
}
163177
}
178+
164179
compileOptions {
165180
sourceCompatibility = JavaVersion.VERSION_17
166181
targetCompatibility = JavaVersion.VERSION_17
@@ -197,6 +212,10 @@ configurations.matching { it.name.contains("AndroidTest") }.configureEach {
197212
exclude(group = "com.google.protobuf", module = "protobuf-lite")
198213
}
199214

215+
configurations.configureEach {
216+
exclude(group = "org.jetbrains.kotlin", module = "kotlin-android-extensions-runtime")
217+
}
218+
200219
dependencies {
201220
debugImplementation(libs.common.leakcanary)
202221

@@ -278,6 +297,7 @@ dependencies {
278297
implementation(projects.gradlePluginConfig)
279298
implementation(projects.subprojects.aaptcompiler)
280299
implementation(projects.subprojects.javacServices)
300+
implementation(projects.subprojects.kotlinAnalysisApi)
281301
implementation(projects.subprojects.shizukuApi)
282302
implementation(projects.subprojects.shizukuManager)
283303
implementation(projects.subprojects.shizukuProvider)

composite-builds/build-deps/java-compiler/build.gradle.kts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@
1616
*/
1717

1818
plugins {
19-
id("java-library")
19+
id("java-library")
2020
}
2121

2222
java {
23-
sourceCompatibility = JavaVersion.VERSION_1_8
24-
targetCompatibility = JavaVersion.VERSION_1_8
25-
}
23+
sourceCompatibility = JavaVersion.VERSION_1_8
24+
targetCompatibility = JavaVersion.VERSION_1_8
25+
}
26+
27+
dependencies {
28+
annotationProcessor(libs.google.auto.service)
29+
implementation(libs.google.auto.service.annotations)
30+
}

composite-builds/build-deps/java-compiler/src/main/java/javac/internal/jrtfs/JrtFileSystemProvider.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
package javac.internal.jrtfs;
2727

28+
import com.google.auto.service.AutoService;
29+
2830
import java.io.*;
2931
import java.net.MalformedURLException;
3032
import java.net.URL;
@@ -53,6 +55,7 @@
5355
* but also compiled and delivered as part of the jrtfs.jar to support access
5456
* to the jimage file provided by the shipped JDK by tools running on JDK 8.
5557
*/
58+
@AutoService(FileSystemProvider.class)
5659
public final class JrtFileSystemProvider extends FileSystemProvider {
5760

5861
private volatile FileSystem theFileSystem;
Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
2+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
3+
14
/*
25
* This file is part of AndroidIDE.
36
*
@@ -16,26 +19,34 @@
1619
*/
1720

1821
plugins {
19-
`kotlin-dsl`
22+
`kotlin-dsl`
2023
}
2124

2225
dependencies {
23-
implementation(gradleApi())
24-
implementation(libs.composite.desugaringCore)
26+
implementation(gradleApi())
27+
implementation(libs.composite.desugaringCore)
2528

26-
compileOnly(libs.android.gradle.plugin)
29+
compileOnly(libs.android.gradle.plugin)
2730

28-
testImplementation(libs.tests.junit)
29-
testImplementation(libs.tests.google.truth)
31+
testImplementation(libs.tests.junit)
32+
testImplementation(libs.tests.google.truth)
3033
}
3134

3235
gradlePlugin {
33-
plugins {
34-
create("desugaring") {
35-
id = "com.itsaky.androidide.desugaring"
36-
implementationClass = "com.itsaky.androidide.desugaring.DesugarGradlePlugin"
37-
displayName = "AndroidIDE Method Desugaring Plugin"
38-
description = "Gradle plugin for method desugaring in Android projects."
39-
}
40-
}
36+
plugins {
37+
create("desugaring") {
38+
id = "com.itsaky.androidide.desugaring"
39+
implementationClass = "com.itsaky.androidide.desugaring.DesugarGradlePlugin"
40+
displayName = "AndroidIDE Method Desugaring Plugin"
41+
description = "Gradle plugin for method desugaring in Android projects."
42+
}
43+
}
44+
}
45+
46+
tasks.withType<KotlinCompile> {
47+
compilerOptions {
48+
apiVersion.set(KotlinVersion.KOTLIN_2_1)
49+
languageVersion.set(KotlinVersion.KOTLIN_2_1)
50+
}
4151
}
52+

composite-builds/build-logic/desugaring/src/main/java/com/itsaky/androidide/desugaring/DesugarClassVisitor.kt

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* You should have received a copy of the GNU General Public License
1515
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
1616
*/
17+
1718
package com.itsaky.androidide.desugaring
1819

1920
import com.android.build.api.instrumentation.ClassContext
@@ -24,19 +25,6 @@ import org.objectweb.asm.MethodVisitor
2425
/**
2526
* [ClassVisitor] implementation for desugaring.
2627
*
27-
* Applies two transformations to every method body, in priority order:
28-
*
29-
* 1. **[DesugarMethodVisitor]** (outermost / highest priority) — fine-grained
30-
* per-method-call replacement defined via [DesugarReplacementsContainer.replaceMethod].
31-
* Its output flows into the next layer.
32-
*
33-
* 2. **[ClassRefReplacingMethodVisitor]** (innermost) — bulk class-reference
34-
* replacement defined via [DesugarReplacementsContainer.replaceClass].
35-
* Handles every site where a class name can appear in a method body.
36-
*
37-
* Class references that appear in field and method *declarations* (descriptors
38-
* and generic signatures at the class-structure level) are also rewritten here.
39-
*
4028
* @author Akash Yadav
4129
*/
4230
class DesugarClassVisitor(

composite-builds/build-logic/plugins/build.gradle.kts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,12 @@ gradlePlugin {
9797
}
9898
}
9999
}
100+
101+
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
102+
compilerOptions {
103+
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_1)
104+
languageVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_1)
105+
106+
compilerOptions.freeCompilerArgs.add("-Xuse-fir-lt=false")
107+
}
108+
}

git-core/build.gradle.kts

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,10 @@
11
plugins {
2-
alias(libs.plugins.android.library)
3-
alias(libs.plugins.kotlin.android)
2+
alias(libs.plugins.android.library)
3+
alias(libs.plugins.kotlin.android)
44
}
55

66
android {
7-
namespace = "com.itsaky.androidide.git.core"
8-
compileSdk = 35
9-
10-
defaultConfig {
11-
minSdk = 27
12-
13-
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
14-
consumerProguardFiles("consumer-rules.pro")
15-
}
16-
17-
buildTypes {
18-
release {
19-
isMinifyEnabled = false
20-
proguardFiles(
21-
getDefaultProguardFile("proguard-android-optimize.txt"),
22-
"proguard-rules.pro"
23-
)
24-
}
25-
}
26-
compileOptions {
27-
sourceCompatibility = JavaVersion.VERSION_17
28-
targetCompatibility = JavaVersion.VERSION_17
29-
isCoreLibraryDesugaringEnabled = true
30-
}
31-
kotlinOptions {
32-
jvmTarget = "17"
33-
}
7+
namespace = "com.itsaky.androidide.git.core"
348
}
359

3610
dependencies {
@@ -44,7 +18,7 @@ dependencies {
4418
implementation(libs.androidx.lifecycle.viewmodel.ktx)
4519
implementation(libs.androidx.security.crypto)
4620

47-
testImplementation(libs.tests.junit)
48-
androidTestImplementation(libs.tests.androidx.junit)
49-
androidTestImplementation(libs.tests.androidx.espresso.core)
21+
testImplementation(libs.tests.junit)
22+
androidTestImplementation(libs.tests.androidx.junit)
23+
androidTestImplementation(libs.tests.androidx.espresso.core)
5024
}

gradle.properties

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,24 @@
1-
## For more details on how to configure your build environment visit
2-
# http://www.gradle.org/docs/current/userguide/build_environment.html
3-
#
4-
# Specifies the JVM arguments used for the daemon process.
5-
# The setting is particularly useful for tweaking memory settings.
6-
# Default value: -Xmx1024m -XX:MaxPermSize=256m
7-
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
8-
#
9-
# When configured, Gradle will run in incubating parallel mode.
10-
# This option should only be used with decoupled projects. More details, visit
11-
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
12-
# org.gradle.parallel=true
13-
#Wed Feb 02 13:50:55 IST 2022
14-
15-
org.gradle.jvmargs=-Xmx8G -Dkotlin.daemon.jvm.options="-Xmx4096M" -XX:+HeapDumpOnOutOfMemoryError --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED
16-
17-
# Increase memory for aapt2 to prevent Java heap space issues during asset compression
18-
android.aapt2.daemonHeapSize=8192M
19-
# For CI builds, set worker max to limit memory usage
20-
org.gradle.workers.max=2
21-
# Use less memory per worker during asset compression
22-
org.gradle.vfs.watch=true
23-
org.gradle.parallel=false
24-
org.gradle.configureondemand=true
25-
org.gradle.caching=true
26-
android.useAndroidX=true
27-
android.enableJetifier=false
28-
android.jetifier.ignorelist=common-30.2.2.jar
29-
30-
# TODO : Migrate
31-
android.nonTransitiveRClass=false
1+
## For more details on how to configure your build environment visit
2+
# http://www.gradle.org/docs/current/userguide/build_environment.html
3+
#
4+
# Specifies the JVM arguments used for the daemon process.
5+
# The setting is particularly useful for tweaking memory settings.
6+
# Default value: -Xmx1024m -XX:MaxPermSize=256m
7+
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
8+
#
9+
# When configured, Gradle will run in incubating parallel mode.
10+
# This option should only be used with decoupled projects. For more details, visit
11+
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
12+
# org.gradle.parallel=true
13+
#Fri Mar 13 16:37:43 IST 2026
14+
android.aapt2.daemonHeapSize=8192M
15+
android.enableJetifier=false
16+
android.jetifier.ignorelist=common-30.2.2.jar
17+
android.nonTransitiveRClass=false
18+
android.useAndroidX=true
19+
org.gradle.caching=true
20+
org.gradle.configureondemand=true
21+
org.gradle.jvmargs=-Xmx8192M -Dkotlin.daemon.jvm.options\="-Xmx8192M" -XX\:+HeapDumpOnOutOfMemoryError --add-opens java.base/java.lang\=ALL-UNNAMED --add-opens java.base/java.util\=ALL-UNNAMED --add-opens java.base/java.io\=ALL-UNNAMED
22+
org.gradle.parallel=true
23+
org.gradle.vfs.watch=true
24+
org.gradle.workers.max=30

gradle/libs.versions.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ gson = "2.10.1"
2020
junit-jupiter = "5.10.2"
2121
anroidx-test-core = "2.2.0"
2222
koinAndroid = "4.1.1"
23-
kotlin = "2.1.21"
23+
kotlin = "2.3.0"
2424
kotlin-coroutines = "1.9.0"
2525
kotlinxCoroutinesCore = "1.10.2"
2626
kotlinxSerializationJson = "1.9.0"
@@ -35,15 +35,15 @@ editor = "0.23.6"
3535
glide = "4.16.0"
3636
androidx-vectordrawable = "1.2.0"
3737
androidx-navigation = "2.7.7"
38-
ksp = "2.1.21-2.0.2"
38+
ksp = "2.3.6"
3939
antlr4 = "4.13.1"
4040
androidx-work = "2.10.0"
4141
androidx-espresso = "3.5.1"
4242
retrofit = "2.11.0"
4343
markwon = "4.6.2"
4444
maven-publish-plugin = "0.27.0"
4545
logback = "1.5.3"
46-
room = "2.7.2"
46+
room = "2.8.4"
4747
utilcodex = "1.31.1"
4848
viewpager2 = "1.1.0-beta02"
4949
zoomage = "1.3.1"
@@ -242,8 +242,8 @@ androidx-work-ktx = { module = "androidx.work:work-runtime-ktx", version.ref = "
242242
google-material = { module = "com.google.android.material:material", version = "1.12.0" }
243243
google-gson = { module = "com.google.code.gson:gson", version = "2.12.1" }
244244
google-guava = { module = "com.google.guava:guava", version = "33.4.0-android" }
245-
google-auto-value-annotations = { module = "com.google.auto.value:auto-value-annotations", version = "1.10.4" }
246-
google-auto-value-ap = { module = "com.google.auto.value:auto-value", version = "1.10.4" }
245+
google-auto-value-annotations = { module = "com.google.auto.value:auto-value-annotations", version = "1.11.0" }
246+
google-auto-value-ap = { module = "com.google.auto.value:auto-value", version = "1.11.0" }
247247
google-auto-service-annotations = { module = "com.google.auto.service:auto-service-annotations", version = "1.1.1" }
248248
google-auto-service = { module = "com.google.auto.service:auto-service", version = "1.1.1" }
249249
google-protobuf-java = { module = "com.google.protobuf:protobuf-javalite", version.ref = "protobuf" }

0 commit comments

Comments
 (0)