Skip to content

Commit

Permalink
Migrate kapt to ksp (#2471)
Browse files Browse the repository at this point in the history
* support for openmrs

* Add support to be able to configure FHIR Urls, user/pwd and query

* Revert "Add support to be able to configure FHIR Urls, user/pwd and query"

This reverts commit 4804f0d.

* Add support to be able to configure FHIR Urls, user/pwd and query

* Add support to be able to configure FHIR Urls, user/pwd and query

* Migrate the knowledge module to ksp

* update gradle Dependencies

* update gradle Dependencies

* update gradle Dependencies

* update gradle Dependencies

* fix unit tests

---------

Co-authored-by: Jing Tang <[email protected]>
  • Loading branch information
icrc-fdeniger and jingtang10 committed Mar 25, 2024
1 parent a4f5f0f commit d1d0086
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 12 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ buildscript {
}
dependencies {
classpath(Plugins.androidGradlePlugin)
classpath(Plugins.kspGradlePlugin)
classpath(Plugins.benchmarkGradlePlugin)
classpath(Plugins.flankGradlePlugin)
classpath(Plugins.kotlinGradlePlugin)
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ object Dependencies {

object Kotlin {
const val kotlinCoroutinesCore = "1.7.2"
const val stdlib = "1.8.20"
const val stdlib = "1.9.22"
}

const val androidFhirCommon = "0.1.0-alpha05"
Expand Down
6 changes: 4 additions & 2 deletions buildSrc/src/main/kotlin/Plugins.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ object Plugins {
const val androidLib = "com.android.library"
const val application = "com.android.application"
const val benchmark = "androidx.benchmark"
const val jetbrainsKotlinAndroid = "org.jetbrains.kotlin.android"
const val dokka = "org.jetbrains.dokka"
const val kotlin = "kotlin"
const val kotlinAndroid = "kotlin-android"
const val kotlinKapt = "kotlin-kapt"
const val kotlinKsp = "com.google.devtools.ksp"
const val mavenPublish = "maven-publish"
const val fladle = "com.osacky.fladle"
const val navSafeArgs = "androidx.navigation.safeargs.kotlin"
Expand All @@ -42,10 +41,13 @@ object Plugins {
"androidx.navigation:navigation-safe-args-gradle-plugin:${Dependencies.Versions.Androidx.navigation}"
const val rulerGradlePlugin = "com.spotify.ruler:ruler-gradle-plugin:1.2.1"
const val flankGradlePlugin = "com.osacky.flank.gradle:fladle:0.17.4"
const val kspGradlePlugin =
"com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin:${Versions.kspPlugin}"

object Versions {
const val androidGradlePlugin = "8.0.2"
const val benchmarkPlugin = "1.1.0"
const val dokka = "1.9.20"
const val kspPlugin = "1.9.22-1.0.18"
}
}
1 change: 0 additions & 1 deletion demo/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
plugins {
id(Plugins.BuildPlugins.application)
id(Plugins.BuildPlugins.kotlinAndroid)
id(Plugins.BuildPlugins.kotlinKapt)
id(Plugins.BuildPlugins.navSafeArgs)
}

Expand Down
4 changes: 2 additions & 2 deletions engine/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import java.net.URL
plugins {
id(Plugins.BuildPlugins.androidLib)
id(Plugins.BuildPlugins.kotlinAndroid)
id(Plugins.BuildPlugins.kotlinKapt)
id(Plugins.BuildPlugins.kotlinKsp)
id(Plugins.BuildPlugins.mavenPublish)
jacoco
id(Plugins.BuildPlugins.dokka).version(Plugins.Versions.dokka)
Expand Down Expand Up @@ -134,7 +134,7 @@ dependencies {
implementation(Dependencies.timber)
implementation(Dependencies.truth)

kapt(Dependencies.Room.compiler)
ksp(Dependencies.Room.compiler)

testImplementation(Dependencies.AndroidxTest.archCore)
testImplementation(Dependencies.AndroidxTest.core)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,18 @@ import androidx.work.ListenableWorker
import androidx.work.WorkerParameters
import androidx.work.testing.TestListenableWorkerBuilder
import com.google.android.fhir.FhirEngine
import com.google.android.fhir.FhirEngineConfiguration
import com.google.android.fhir.FhirEngineProvider
import com.google.android.fhir.sync.upload.UploadStrategy
import com.google.android.fhir.testing.TestDataSourceImpl
import com.google.android.fhir.testing.TestDownloadManagerImpl
import com.google.android.fhir.testing.TestFailingDatasource
import com.google.android.fhir.testing.TestFhirEngineImpl
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.runBlocking
import org.junit.After
import org.junit.Before
import org.junit.BeforeClass
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
Expand Down Expand Up @@ -85,11 +89,26 @@ class FhirSyncWorkerTest {
override fun getUploadStrategy(): UploadStrategy = UploadStrategy.AllChangesSquashedBundlePut
}

companion object {
@BeforeClass
@JvmStatic
fun setupConfiguration() {
// activate testMode
FhirEngineProvider.init(FhirEngineConfiguration(testMode = true))
}
}

@Before
fun setUp() {
context = ApplicationProvider.getApplicationContext()
}

@After
fun tearDown() {
// cleaning database
FhirEngineProvider.forceCleanup()
}

@Test
fun fhirSyncWorker_successfulTask_resultSuccess() {
// In a ListenableWorker, runAttemptCount starts from 0. But in a TestListenableWorkerBuilder,
Expand Down
4 changes: 2 additions & 2 deletions knowledge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import java.net.URL
plugins {
id(Plugins.BuildPlugins.androidLib)
id(Plugins.BuildPlugins.kotlinAndroid)
id(Plugins.BuildPlugins.kotlinKapt)
id(Plugins.BuildPlugins.kotlinKsp)
id(Plugins.BuildPlugins.mavenPublish)
jacoco
id(Plugins.BuildPlugins.dokka).version(Plugins.Versions.dokka)
Expand Down Expand Up @@ -92,7 +92,7 @@ dependencies {
implementation(Dependencies.HapiFhir.fhirCoreConvertors)
implementation(Dependencies.apacheCommonsCompress)

kapt(Dependencies.Room.compiler)
ksp(Dependencies.Room.compiler)

testImplementation(Dependencies.AndroidxTest.archCore)
testImplementation(Dependencies.AndroidxTest.core)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Google LLC
* Copyright 2023-2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -63,7 +63,7 @@ abstract class KnowledgeDao {
@Query(
"DELETE from ResourceMetadataEntity WHERE resourceMetadataId NOT IN (SELECT DISTINCT resourceMetadataId from ImplementationGuideResourceMetadataEntity)",
)
internal abstract suspend fun deleteOrphanedResources()
internal abstract suspend fun deleteOrphanedResources(): Int

@Query("SELECT * from ImplementationGuideEntity")
internal abstract suspend fun getImplementationGuides(): List<ImplementationGuideEntity>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Google LLC
* Copyright 2023-2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -34,7 +34,7 @@ class NpmFileManagerTest {
val packageFolder = npmFileManager.getPackageDir(PACKAGE_ID, VERSION)

assertThat(packageFolder.absolutePath)
.isEqualTo("${testDataFolder.absolutePath}/$PACKAGE_ID#$VERSION")
.isEqualTo("${testDataFolder.absolutePath}${File.separator}$PACKAGE_ID#$VERSION")
}

@Test
Expand Down

0 comments on commit d1d0086

Please sign in to comment.