Skip to content

Commit 9440c54

Browse files
authored
Migrate to kotlin v2 compiler (#2816)
* Migrate to kotlin v2 compiler also updates ksp and room to versions with support for k2 * Update compile sdk to API 36 * Run spotless * Fix lint error Error: Call requires API level 34 (current min is 26): java.util.stream.Stream#toList [NewApi] .toList() * Replace depracted toUpperCase() with uppercase() * Increase timeout for github ci build * Update ci actions to use jdk-21 * Update kokoro script and firebaseTestLab devices * Set api-33 as the target sdk
1 parent 480fd79 commit 9440c54

File tree

13 files changed

+49
-32
lines changed

13 files changed

+49
-32
lines changed

.github/actions/commonSetup/action.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ description: "Prepares the machine"
33
runs:
44
using: "composite"
55
steps:
6-
- name: Set up JDK 17
7-
uses: actions/setup-java@v2
6+
- name: Set up JDK 21
7+
uses: actions/setup-java@v4
88
with:
99
distribution: temurin
10-
java-version: "17"
10+
java-version: "21"
1111

1212
- name: "Setup Gradle"
1313
uses: gradle/gradle-build-action@v2

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
# Build will compile APK, test APK and run tests, lint, etc.
4646
build:
4747
runs-on: 'ubuntu-24.04-8core'
48-
timeout-minutes: 60
48+
timeout-minutes: 90
4949
permissions:
5050
actions: read
5151
contents: read

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,6 @@ site/
9494
# (which is slightly confusing, but helps mkdocs to validate links)
9595
# so we ignore that here, as it's a built artifact that should not be committed
9696
docs/use/api/*/**
97+
98+
# Kotlin 2.0
99+
.kotlin/

buildSrc/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repositories {
1111
dependencies {
1212
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.22.0")
1313

14-
implementation("com.android.tools.build:gradle:8.5.0")
14+
implementation("com.android.tools.build:gradle:8.9.2")
1515

1616
implementation("app.cash.licensee:licensee-gradle-plugin:1.8.0")
1717
implementation("com.osacky.flank.gradle:fladle:0.17.4")

buildSrc/src/main/kotlin/FirebaseTestLabConfig.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023 Google LLC
2+
* Copyright 2023-2025 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -43,7 +43,7 @@ fun Project.configureFirebaseTestLabForLibraries() {
4343
),
4444
mapOf(
4545
"model" to "MediumPhone.arm",
46-
"version" to "${project.extensions.getByType(LibraryExtension::class.java).compileSdk}",
46+
"version" to "33",
4747
"locale" to "en_US",
4848
),
4949
),
@@ -67,7 +67,7 @@ fun Project.configureFirebaseTestLabForMicroBenchmark() {
6767
listOf(
6868
mapOf(
6969
"model" to "panther",
70-
"version" to "${project.extensions.getByType(LibraryExtension::class.java).compileSdk}",
70+
"version" to "33",
7171
"locale" to "en_US",
7272
),
7373
),

buildSrc/src/main/kotlin/Plugins.kt

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 Google LLC
2+
* Copyright 2023-2025 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -35,17 +35,18 @@ object Plugins {
3535
const val androidGradlePlugin = "com.android.tools.build:gradle:${Versions.androidGradlePlugin}"
3636
const val benchmarkGradlePlugin =
3737
"androidx.benchmark:benchmark-gradle-plugin:${Versions.benchmarkPlugin}"
38-
const val kotlinGradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.22"
38+
const val kotlinGradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}"
3939
const val navSafeArgsGradlePlugin = "androidx.navigation:navigation-safe-args-gradle-plugin:2.6.0"
4040
const val rulerGradlePlugin = "com.spotify.ruler:ruler-gradle-plugin:1.2.1"
4141
const val flankGradlePlugin = "com.osacky.flank.gradle:fladle:0.17.4"
4242
const val kspGradlePlugin =
4343
"com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:${Versions.kspPlugin}"
4444

4545
object Versions {
46-
const val androidGradlePlugin = "8.5.0"
46+
const val androidGradlePlugin = "8.9.2"
4747
const val benchmarkPlugin = "1.1.0"
4848
const val dokka = "1.9.20"
49-
const val kspPlugin = "1.9.22-1.0.18"
49+
const val kspPlugin = "2.1.20-2.0.1"
50+
const val kotlin = "2.1.20"
5051
}
5152
}

buildSrc/src/main/kotlin/Sdk.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 Google LLC
2+
* Copyright 2023-2025 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,8 +15,8 @@
1515
*/
1616

1717
object Sdk {
18-
const val COMPILE_SDK = 33
19-
const val TARGET_SDK = 31
18+
const val COMPILE_SDK = 36
19+
const val TARGET_SDK = 33
2020

2121
// Engine and SDC must support API 24.
2222
// Remove desugaring when upgrading it to 26.

engine/src/main/java/com/google/android/fhir/db/impl/SQLCipherSupportHelper.kt

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 Google LLC
2+
* Copyright 2023-2025 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -74,7 +74,8 @@ internal class SQLCipherSupportHelper(
7474
}
7575
}
7676

77-
override val databaseName = standardHelper.databaseName
77+
override val databaseName
78+
get() = standardHelper.databaseName
7879

7980
override fun setWriteAheadLoggingEnabled(enabled: Boolean) {
8081
standardHelper.setWriteAheadLoggingEnabled(enabled)
@@ -119,7 +120,8 @@ internal class SQLCipherSupportHelper(
119120
throw lastException ?: DatabaseEncryptionException(Exception(), UNKNOWN)
120121
}
121122

122-
override val readableDatabase = writableDatabase
123+
override val readableDatabase
124+
get() = writableDatabase
123125

124126
override fun close() {
125127
standardHelper.close()

engine/src/main/java/com/google/android/fhir/testing/Utilities.kt

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 Google LLC
2+
* Copyright 2023-2025 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -131,7 +131,6 @@ internal open class TestDownloadManagerImpl(
131131

132132
override suspend fun getSummaryRequestUrls() =
133133
queries
134-
.stream()
135134
.map { ResourceType.fromCode(it.substringBefore("?")) to it.plus("?_summary=count") }
136135
.toList()
137136
.toMap()

engine/src/test/java/com/google/android/fhir/index/SearchParameterRepositoryGeneratedTest.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023 Google LLC
2+
* Copyright 2023-2025 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -43,7 +43,7 @@ class SearchParameterRepositoryGeneratedTest(private val resource: Resource) {
4343
.map {
4444
SearchParamDefinition(
4545
it.name,
46-
Enumerations.SearchParamType.valueOf(it.type.toUpperCase()),
46+
Enumerations.SearchParamType.valueOf(it.type.uppercase()),
4747
it.path,
4848
)
4949
}

gradle/libs.versions.toml

+5-6
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,16 @@ androidx-fragment = "1.6.0"
1616
androidx-lifecycle = "2.6.1"
1717
androidx-navigation = "2.6.0"
1818
androidx-recyclerview = "1.3.2"
19-
androidx-room = "2.5.2"
20-
androidx-sqlite = "2.3.1"
19+
androidx-room = "2.7.1"
20+
androidx-sqlite = "2.5.0"
2121
androidx-test-core = "1.6.1"
2222
androidx-test-ext-junit = "1.1.5"
2323
androidx-test-rules = "1.5.0"
2424
androidx-test-runner = "1.5.0"
2525
androidx-work = "2.8.1"
2626
glide = "4.16.0"
2727
junit = "4.13.2"
28-
kotlin-stdlib = "1.9.22"
29-
kotlin-test = "1.9.22"
28+
kotlin = "2.1.20"
3029
kotlinx-coroutines = "1.8.1"
3130
logback-android = "3.0.0"
3231
opencds-cqf-fhir = "3.8.0"
@@ -68,8 +67,8 @@ androidx-work-runtime = { module = "androidx.work:work-runtime-ktx", version.ref
6867
androidx-work-testing = { module = "androidx.work:work-testing", version.ref = "androidx-work" }
6968
glide = { module = "com.github.bumptech.glide:glide", version.ref = "glide" }
7069
junit = { module = "junit:junit", version.ref = "junit" }
71-
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin-stdlib" }
72-
kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin-test" }
70+
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
71+
kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" }
7372
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinx-coroutines" }
7473
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
7574
kotlinx-coroutines-playservices = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-play-services", version.ref = "kotlinx-coroutines" }
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
44
networkTimeout=10000
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

kokoro/gcp_ubuntu/kokoro_build.sh

+16-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ set -e
3535
# Code under repo is checked out to ${KOKORO_ARTIFACTS_DIR}/git.
3636
# The final directory name in this path is determined by the scm name specified
3737
# in the job configuration.
38-
export JAVA_HOME="/usr/lib/jvm/java-1.17.0-openjdk-amd64"
38+
#export JAVA_HOME="/usr/lib/jvm/java-1.17.0-openjdk-amd64"
3939
export ANDROID_HOME=${HOME}/android_sdk
40-
export PATH=$PATH:$JAVA_HOME/bin:${ANDROID_HOME}/cmdline-tools/latest/bin
40+
#export PATH=$PATH:$JAVA_HOME/bin:${ANDROID_HOME}/cmdline-tools/latest/bin
41+
export PATH=$PATH:${ANDROID_HOME}/cmdline-tools/latest/bin
4142
export GCS_BUCKET="android-fhir-build-artifacts"
4243

4344
# Uploads files generated from builds and tests to GCS when this script exits.
@@ -56,6 +57,17 @@ function zip_artifacts() {
5657
| sed 's|gs://|https://storage.googleapis.com/|'
5758
}
5859

60+
function installJdk21() {
61+
wget --quiet https://download.java.net/openjdk/jdk21/ri/openjdk-21+35_linux-x64_bin.tar.gz
62+
tar xvf openjdk-21+35_linux-x64_bin.tar.gz
63+
sudo mv jdk-21/ /opt/jdk-21/
64+
echo 'export JAVA_HOME=/opt/jdk-21' | sudo tee /etc/profile.d/java21.sh
65+
echo 'export PATH=$JAVA_HOME/bin:$PATH'|sudo tee -a /etc/profile.d/java21.sh
66+
source /etc/profile.d/java21.sh
67+
# echo $JAVA_HOME
68+
java --version
69+
}
70+
5971
# Installs dependencies to run CI pipeline. Dependencies are:
6072
# 1. npm to run spotlessApply
6173
# 2. Android Command Line tools, accepting its licenses
@@ -64,7 +76,8 @@ function setup() {
6476
sudo npm cache clean -f
6577
sudo npm install -g n
6678
sudo n 16.18.0
67-
sudo apt install -y openjdk-17-jdk openjdk-17-jre
79+
installJdk21
80+
# sudo apt install -y openjdk-17-jdk
6881

6982
gcloud components update --quiet
7083

0 commit comments

Comments
 (0)