Skip to content

Commit eb277e2

Browse files
kikosodkhawk
andauthored
build: updated to Kotlin 2.2.20, and fixed the Compose usage warning (#763)
Co-authored-by: Dale Hawkins <[email protected]>
1 parent e3685c6 commit eb277e2

File tree

8 files changed

+61
-36
lines changed

8 files changed

+61
-36
lines changed

gradle/libs.versions.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[versions]
2-
activitycompose = "1.10.1"
2+
activitycompose = "1.11.0"
33
agp = "8.13.0"
44
androidCore = "1.7.0"
55
androidx-core = "1.17.0"
@@ -11,7 +11,7 @@ gradleMavenPublishPlugin = "0.34.0"
1111
jacoco-plugin = "0.2.1"
1212
junit = "4.13.2"
1313
junitktx = "1.3.0"
14-
kotlin = "2.2.10"
14+
kotlin = "2.2.20"
1515
kotlinxCoroutines = "1.10.2"
1616
leakcanaryAndroid = "2.14"
1717
mapsecrets = "2.0.1"
@@ -22,7 +22,7 @@ screenshot = "0.0.1-alpha11"
2222
constraintlayout = "2.2.1"
2323
material = "1.13.0"
2424
robolectric = "4.16"
25-
truth = "1.4.4"
25+
truth = "1.4.5"
2626

2727
[libraries]
2828
android-gradle-plugin = { module = "com.android.tools.build:gradle", version.ref = "agp" }

maps-app/build.gradle.kts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2+
13
plugins {
24
id("com.android.application")
35
id("kotlin-android")
@@ -8,7 +10,7 @@ plugins {
810

911
android {
1012
lint {
11-
sarifOutput = file("$buildDir/reports/lint-results.sarif")
13+
sarifOutput = layout.buildDirectory.file("reports/lint-results.sarif").get().asFile
1214
}
1315

1416
buildTypes {
@@ -43,9 +45,14 @@ android {
4345
compose = true
4446
}
4547

46-
kotlinOptions {
47-
jvmTarget = "1.8"
48-
freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
48+
49+
kotlin {
50+
compilerOptions {
51+
jvmTarget.set(JvmTarget.JVM_1_8)
52+
freeCompilerArgs.addAll(
53+
"-opt-in=kotlin.RequiresOptIn"
54+
)
55+
}
4956
}
5057

5158
experimentalProperties["android.experimental.enableScreenshotTest"] = true

maps-app/src/main/java/com/google/maps/android/compose/markerexamples/AdvancedMarkersActivity.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ class AdvancedMarkersActivity : ComponentActivity(), OnMapsSdkInitializedCallbac
183183
when (renderer) {
184184
MapsInitializer.Renderer.LATEST -> Log.d("MapsDemo", "The latest version of the renderer is used.")
185185
MapsInitializer.Renderer.LEGACY -> Log.d("MapsDemo", "The legacy version of the renderer is used.")
186-
else -> {}
187186
}
188187
}
189188
}

maps-compose-utils/build.gradle.kts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2+
13
plugins {
24
id("kotlin-android")
35
alias(libs.plugins.compose.compiler)
@@ -6,7 +8,7 @@ plugins {
68

79
android {
810
lint {
9-
sarifOutput = file("$buildDir/reports/lint-results.sarif")
11+
sarifOutput = layout.buildDirectory.file("reports/lint-results.sarif").get().asFile
1012
}
1113

1214
namespace = "com.google.maps.android.compose.utils"
@@ -26,10 +28,14 @@ android {
2628
compose = true
2729
}
2830

29-
kotlinOptions {
30-
jvmTarget = "1.8"
31-
freeCompilerArgs += "-Xexplicit-api=strict"
32-
freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
31+
kotlin {
32+
compilerOptions {
33+
jvmTarget.set(JvmTarget.JVM_1_8)
34+
freeCompilerArgs.addAll(
35+
"-Xexplicit-api=strict",
36+
"-Xopt-in=kotlin.RequiresOptIn"
37+
)
38+
}
3339
}
3440
}
3541

maps-compose-widgets/build.gradle.kts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2+
13
plugins {
24
id("kotlin-android")
35
alias (libs.plugins.compose.compiler)
@@ -6,7 +8,7 @@ plugins {
68

79
android {
810
lint {
9-
sarifOutput = file("$buildDir/reports/lint-results.sarif")
11+
sarifOutput = layout.buildDirectory.file("reports/lint-results.sarif").get().asFile
1012
}
1113

1214
namespace = "com.google.maps.android.compose.widgets"
@@ -26,12 +28,14 @@ android {
2628
compose = true
2729
}
2830

29-
kotlinOptions {
30-
jvmTarget = "1.8"
31-
freeCompilerArgs += listOf(
32-
"-Xexplicit-api=strict",
33-
"-Xopt-in=kotlin.RequiresOptIn"
34-
)
31+
kotlin {
32+
compilerOptions {
33+
jvmTarget.set(JvmTarget.JVM_1_8)
34+
freeCompilerArgs.addAll(
35+
"-Xexplicit-api=strict",
36+
"-Xopt-in=kotlin.RequiresOptIn"
37+
)
38+
}
3539
}
3640
}
3741

maps-compose/build.gradle.kts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import org.gradle.kotlin.dsl.sourceSets
2+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
23

34
plugins {
45
id("org.jetbrains.kotlin.android")
@@ -8,7 +9,7 @@ plugins {
89

910
android {
1011
lint {
11-
sarifOutput = file("$buildDir/reports/lint-results.sarif")
12+
sarifOutput = layout.buildDirectory.file("reports/lint-results.sarif").get().asFile
1213
}
1314

1415
namespace = "com.google.maps.android.compose"
@@ -28,20 +29,24 @@ android {
2829
compose = true
2930
}
3031

31-
kotlinOptions {
32-
jvmTarget = "1.8"
33-
freeCompilerArgs += listOf(
34-
"-Xexplicit-api=strict",
35-
"-Xopt-in=kotlin.RequiresOptIn",
36-
)
32+
kotlin {
33+
compilerOptions {
34+
jvmTarget.set(JvmTarget.JVM_1_8)
35+
freeCompilerArgs.addAll(
36+
"-Xexplicit-api=strict",
37+
"-Xopt-in=kotlin.RequiresOptIn"
38+
)
39+
}
3740
}
3841

3942
sourceSets["main"].java.srcDir("build/generated/source/artifactId")
4043
}
4144

4245
composeCompiler {
43-
stabilityConfigurationFile =
44-
layout.projectDirectory.file("compose_compiler_stability_config.conf")
46+
stabilityConfigurationFiles.set(
47+
listOf(layout.projectDirectory.file("compose_compiler_stability_config.conf"))
48+
)
49+
4550
if (findProperty("composeCompilerReports") == "true") {
4651
reportsDestination = layout.buildDirectory.dir("compose_compiler")
4752
}
@@ -50,6 +55,7 @@ composeCompiler {
5055
}
5156
}
5257

58+
5359
dependencies {
5460
implementation(platform(libs.androidx.compose.bom))
5561
implementation(libs.androidx.core)

maps-compose/src/main/java/com/google/maps/android/compose/GoogleMap.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ import kotlinx.coroutines.Dispatchers
5959
import kotlinx.coroutines.Job
6060
import kotlinx.coroutines.awaitCancellation
6161
import kotlinx.coroutines.launch
62-
import kotlinx.coroutines.withContext
6362

6463
/**
6564
* A compose container for a [MapView].
@@ -170,7 +169,10 @@ public fun GoogleMap(
170169
val componentCallbacks = object : ComponentCallbacks2 {
171170
override fun onConfigurationChanged(newConfig: Configuration) {}
172171

173-
@Deprecated("Deprecated in Java", ReplaceWith("onTrimMemory(level)"))
172+
@Deprecated(
173+
"Deprecated in Java",
174+
ReplaceWith("onTrimMemory(level)")
175+
)
174176
override fun onLowMemory() {
175177
mapView.onLowMemory()
176178
}

maps-compose/src/main/java/com/google/maps/android/compose/Marker.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import androidx.compose.runtime.saveable.Saver
2929
import androidx.compose.runtime.saveable.rememberSaveable
3030
import androidx.compose.runtime.setValue
3131
import androidx.compose.runtime.snapshots.StateFactoryMarker
32+
import androidx.compose.ui.UiComposable
3233
import androidx.compose.ui.geometry.Offset
3334
import com.google.android.gms.maps.model.AdvancedMarkerOptions
3435
import com.google.android.gms.maps.model.BitmapDescriptor
@@ -337,7 +338,7 @@ public fun MarkerComposable(
337338
onInfoWindowClick: (Marker) -> Unit = {},
338339
onInfoWindowClose: (Marker) -> Unit = {},
339340
onInfoWindowLongClick: (Marker) -> Unit = {},
340-
content: @Composable () -> Unit,
341+
content: @UiComposable @Composable () -> Unit,
341342
) {
342343
val icon = rememberComposeBitmapDescriptor(*keys) { content() }
343344

@@ -411,7 +412,7 @@ public fun MarkerInfoWindow(
411412
onInfoWindowClick: (Marker) -> Unit = {},
412413
onInfoWindowClose: (Marker) -> Unit = {},
413414
onInfoWindowLongClick: (Marker) -> Unit = {},
414-
content: (@Composable (Marker) -> Unit)? = null
415+
content: (@UiComposable @Composable (Marker) -> Unit)? = null
415416
) {
416417
MarkerImpl(
417418
state = state,
@@ -484,8 +485,8 @@ public fun MarkerInfoWindowComposable(
484485
onInfoWindowClick: (Marker) -> Unit = {},
485486
onInfoWindowClose: (Marker) -> Unit = {},
486487
onInfoWindowLongClick: (Marker) -> Unit = {},
487-
infoContent: (@Composable (Marker) -> Unit)? = null,
488-
content: @Composable () -> Unit,
488+
infoContent: (@UiComposable @Composable (Marker) -> Unit)? = null,
489+
content: @UiComposable @Composable () -> Unit,
489490
) {
490491
val icon = rememberComposeBitmapDescriptor(*keys) { content() }
491492

@@ -557,7 +558,7 @@ public fun MarkerInfoWindowContent(
557558
onInfoWindowClick: (Marker) -> Unit = {},
558559
onInfoWindowClose: (Marker) -> Unit = {},
559560
onInfoWindowLongClick: (Marker) -> Unit = {},
560-
content: (@Composable (Marker) -> Unit)? = null
561+
content: (@UiComposable @Composable (Marker) -> Unit)? = null
561562
) {
562563
MarkerImpl(
563564
state = state,

0 commit comments

Comments
 (0)