Skip to content

Commit 91f95dd

Browse files
committed
Prepare gradle for AGP 10
1 parent 6006280 commit 91f95dd

9 files changed

Lines changed: 65 additions & 91 deletions

File tree

.github/workflows/android.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Install Android Build Tools
2828
run: sdkmanager "build-tools;29.0.3"
2929
- name: Run unit tests
30-
run: bash ./gradlew :common:testDebugUnitTest :common:desktopTest --stacktrace
30+
run: bash ./gradlew :common:desktopTest --stacktrace
3131
- name: Build APK
3232
run: bash ./gradlew assembleRelease --stacktrace
3333
- name: Sign APK

android/build.gradle.kts

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2+
13
plugins {
24
alias(libs.plugins.android.application)
3-
alias(libs.plugins.kotlin.android)
45
alias(libs.plugins.compose.compiler)
56
}
67

78
group = "com.inspiredandroid.linuxcommandbibliotheca"
89

10+
kotlin {
11+
compilerOptions {
12+
jvmTarget.set(JvmTarget.JVM_17)
13+
}
14+
}
15+
916
dependencies {
1017
implementation(project(":common"))
1118
implementation(project(":composeApp"))
@@ -25,11 +32,20 @@ dependencies {
2532
}
2633

2734
android {
28-
compileSdk = 36
35+
compileSdk =
36+
libs.versions.android.compileSdk
37+
.get()
38+
.toInt()
2939
defaultConfig {
3040
applicationId = "com.inspiredandroid.linuxcommandbibliotheca"
31-
minSdk = 24
32-
targetSdk = 36
41+
minSdk =
42+
libs.versions.android.minSdk
43+
.get()
44+
.toInt()
45+
targetSdk =
46+
libs.versions.android.targetSdk
47+
.get()
48+
.toInt()
3349
versionCode =
3450
libs.versions.androidVersionCode
3551
.get()
@@ -67,7 +83,10 @@ android {
6783
}
6884
}
6985

70-
sourceSets["main"].assets.setSrcDirs(listOf("../assets"))
86+
sourceSets["main"].assets.directories.apply {
87+
clear()
88+
add("../assets")
89+
}
7190

7291
buildFeatures {
7392
compose = true
@@ -78,11 +97,6 @@ android {
7897
sourceCompatibility = JavaVersion.VERSION_17
7998
targetCompatibility = JavaVersion.VERSION_17
8099
}
81-
kotlin {
82-
compilerOptions {
83-
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
84-
}
85-
}
86100
lint {
87101
abortOnError = false
88102
}

build.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ plugins {
44
alias(libs.plugins.ben.manes.versions)
55
alias(libs.plugins.spotless)
66
alias(libs.plugins.kotlin.multiplatform) apply false
7-
alias(libs.plugins.kotlin.android) apply false
87
alias(libs.plugins.android.application) apply false
9-
alias(libs.plugins.android.library) apply false
108
alias(libs.plugins.compose.compiler) apply false
119
}
1210

common/build.gradle.kts

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,22 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
22

33
plugins {
44
alias(libs.plugins.kotlin.multiplatform)
5-
alias(libs.plugins.android.library)
5+
alias(libs.plugins.android.kotlin.multiplatform.library)
66
}
77

88
group = "com.linuxcommandlibrary"
99

1010
kotlin {
11-
androidTarget {
11+
android {
12+
namespace = "com.linuxcommandlibrary.shared"
13+
compileSdk =
14+
libs.versions.android.compileSdk
15+
.get()
16+
.toInt()
17+
minSdk =
18+
libs.versions.android.minSdk
19+
.get()
20+
.toInt()
1221
compilerOptions {
1322
jvmTarget.set(JvmTarget.JVM_17)
1423
}
@@ -56,16 +65,6 @@ kotlin {
5665
dependencies {
5766
}
5867
}
59-
val iosX64Main by getting
60-
val iosArm64Main by getting
61-
val iosSimulatorArm64Main by getting
62-
val iosMain by creating {
63-
dependsOn(commonMain.get())
64-
iosX64Main.dependsOn(this)
65-
iosArm64Main.dependsOn(this)
66-
iosSimulatorArm64Main.dependsOn(this)
67-
}
68-
6968
// Native CLI targets source sets
7069
val nativeCliMain by creating {
7170
dependsOn(commonMain.get())
@@ -104,24 +103,11 @@ val generateVersionFile by tasks.registering {
104103
}
105104

106105
// Make compilation depend on version generation
107-
tasks.matching { it.name.contains("compileKotlin") || (it.name.contains("Kotlin") && it.name.contains("compile")) }.configureEach {
108-
dependsOn(generateVersionFile)
109-
}
110-
111-
android {
112-
compileSdk = 36
113-
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
114-
defaultConfig {
115-
minSdk = 24
106+
tasks
107+
.matching {
108+
it.name.contains("compileKotlin") ||
109+
(it.name.contains("Kotlin") && it.name.contains("compile")) ||
110+
it.name == "compileAndroidMain"
111+
}.configureEach {
112+
dependsOn(generateVersionFile)
116113
}
117-
118-
compileOptions {
119-
sourceCompatibility = JavaVersion.VERSION_17
120-
targetCompatibility = JavaVersion.VERSION_17
121-
}
122-
123-
lint {
124-
abortOnError = false
125-
}
126-
namespace = "com.linuxcommandlibrary.shared"
127-
}

common/src/desktopTest/kotlin/DesktopTests.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class DesktopTests {
1414
?: error("Could not read commands from ${assetsDir.absolutePath}")
1515

1616
// Verify using index as ID produces no duplicates (mirrors CommandsRepository logic)
17-
val ids = commandNames.mapIndexed { index, _ -> index.toLong() }
17+
val ids = List(commandNames.size) { index -> index.toLong() }
1818
assertEquals(ids.size, ids.distinct().size, "Found duplicate IDs")
1919
}
2020
}

composeApp/build.gradle.kts

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
22

33
plugins {
44
alias(libs.plugins.kotlin.multiplatform)
5-
alias(libs.plugins.android.library)
5+
alias(libs.plugins.android.kotlin.multiplatform.library)
66
alias(libs.plugins.compose.multiplatform)
77
alias(libs.plugins.compose.compiler)
88
alias(libs.plugins.kotlin.serialization)
@@ -11,10 +11,22 @@ plugins {
1111
group = "com.linuxcommandlibrary"
1212

1313
kotlin {
14-
androidTarget {
14+
android {
15+
namespace = "com.linuxcommandlibrary.app"
16+
compileSdk =
17+
libs.versions.android.compileSdk
18+
.get()
19+
.toInt()
20+
minSdk =
21+
libs.versions.android.minSdk
22+
.get()
23+
.toInt()
1524
compilerOptions {
1625
jvmTarget.set(JvmTarget.JVM_17)
1726
}
27+
androidResources {
28+
enable = true
29+
}
1830
}
1931

2032
jvm("desktop") {
@@ -66,30 +78,7 @@ kotlin {
6678
implementation(compose.desktop.currentOs)
6779
}
6880
}
69-
70-
val iosX64Main by getting
71-
val iosArm64Main by getting
72-
val iosSimulatorArm64Main by getting
73-
val iosMain by creating {
74-
dependsOn(commonMain.get())
75-
iosX64Main.dependsOn(this)
76-
iosArm64Main.dependsOn(this)
77-
iosSimulatorArm64Main.dependsOn(this)
78-
}
79-
}
80-
}
81-
82-
android {
83-
compileSdk = 36
84-
namespace = "com.linuxcommandlibrary.app"
85-
defaultConfig {
86-
minSdk = 24
87-
}
88-
compileOptions {
89-
sourceCompatibility = JavaVersion.VERSION_17
90-
targetCompatibility = JavaVersion.VERSION_17
9181
}
92-
sourceSets["main"].assets.setSrcDirs(listOf("../assets"))
9382
}
9483

9584
composeCompiler {

gradle.properties

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@ kotlin.code.style=official
22
android.useAndroidX=true
33
org.gradle.jvmargs=-Xmx4608m
44
kotlin.mpp.androidSourceSetLayoutVersion=2
5-
android.nonTransitiveRClass=false
6-
android.nonFinalResIds=false
7-
android.defaults.buildfeatures.resvalues=true
8-
android.sdk.defaultTargetSdkToCompileSdkIfUnset=false
9-
android.enableAppCompileTimeRClass=false
10-
android.usesSdkInManifest.disallowed=false
11-
android.uniquePackageNames=false
125
android.dependency.useConstraints=true
13-
android.r8.strictFullModeForKeepRules=false
14-
android.r8.optimizedResourceShrinking=false
15-
android.builtInKotlin=false
16-
android.newDsl=false
6+
android.builtInKotlin=true
7+
android.newDsl=true

gradle/libs.versions.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
agp = "9.1.0"
33
appVersion = "3.7.4"
44
androidVersionCode = "150"
5+
android-compileSdk = "36"
6+
android-minSdk = "24"
7+
android-targetSdk = "36"
58
kotlin = "2.3.20"
69
composeMultiplatform = "1.10.3"
710
composeMaterial3 = "1.9.0"
@@ -50,8 +53,7 @@ kotlinx-collections-immutable = { module = "org.jetbrains.kotlinx:kotlinx-collec
5053

5154
[plugins]
5255
android-application = { id = "com.android.application", version.ref = "agp" }
53-
android-library = { id = "com.android.library", version.ref = "agp" }
54-
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
56+
android-kotlin-multiplatform-library = { id = "com.android.kotlin.multiplatform.library" }
5557
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
5658
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
5759
compose-multiplatform = { id = "org.jetbrains.compose", version.ref = "composeMultiplatform" }

websiteBuilder/build.gradle.kts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,7 @@ dependencies {
1212
implementation(libs.kotlinx.collections.immutable)
1313
}
1414

15-
kotlin {
16-
compilerOptions {
17-
sourceSets["main"].apply {
18-
resources.srcDirs("../assets")
19-
}
20-
}
21-
}
15+
sourceSets["main"].resources.srcDirs("../assets")
2216

2317
tasks.register<JavaExec>("runFdroidInfoBuilder") {
2418
classpath = sourceSets["main"].runtimeClasspath

0 commit comments

Comments
 (0)