diff --git a/.gitignore b/.gitignore index dd5de987f1..7d2b8cb57c 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ /venv /*.secrets.yml /gradle.deps +.kotlin/ diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 6e516f4776..b03420203b 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,6 +1,7 @@ import java.io.ByteArrayOutputStream import java.text.SimpleDateFormat import java.util.Date +import org.jetbrains.kotlin.gradle.dsl.JvmTarget plugins { id("com.android.application") @@ -8,6 +9,7 @@ plugins { kotlin("kapt") id("kotlinx-serialization") id("dagger.hilt.android.plugin") + alias(libs.plugins.kotlin.compose.compiler) } apply(from = "${project.rootDir}/jacoco/jacoco.gradle.kts") @@ -74,7 +76,6 @@ android { defaultConfig { applicationId = "com.dhis2" minSdk = libs.versions.minSdk.get().toInt() - targetSdk = libs.versions.sdk.get().toInt() versionCode = libs.versions.vCode.get().toInt() versionName = libs.versions.vName.get() testInstrumentationRunner = "org.dhis2.Dhis2Runner" @@ -216,19 +217,18 @@ android { } } - kotlinOptions { - jvmTarget = "17" - } - - composeOptions { - kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExtensionVersion.get() - } lint { abortOnError = false checkReleaseBuilds = false } } +kotlin { + compilerOptions { + jvmTarget.set(JvmTarget.JVM_17) + } +} + dependencies { implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) implementation(project(":viewpagerdotsindicator")) diff --git a/app/src/androidTest/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/EventInitialTest.kt b/app/src/androidTest/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/EventInitialTest.kt index 91deea4baa..ed75935cf7 100644 --- a/app/src/androidTest/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/EventInitialTest.kt +++ b/app/src/androidTest/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/EventInitialTest.kt @@ -63,21 +63,6 @@ class EventInitialTest { val date: Date? = dateFormat.parse(dateString) - private val eventDetailsRepository: EventDetailsRepository = mock { - on { getProgramStage() } doReturn programStage - on { catCombo() } doReturn catCombo - on { getEvent() } doReturn null - on { getObjectStyle() } doReturn style - on { getOrganisationUnit(ORG_UNIT_UID) } doReturn orgUnit - on { getGeometryModel() } doReturn geometryModel - on { getCatOptionCombos(CAT_COMBO_UID) } doReturn listOf(categoryOptionCombo) - on { getEditableStatus() } doReturn EventEditableStatus.Editable() - on { getEnrollmentDate(ENROLLMENT_UID) } doReturn date - on { getStageLastDate(ENROLLMENT_UID) } doReturn DateUtils.uiDateFormat() - .parse("20/8/2023")!! - - } - private val metadataIconProvider:MetadataIconProvider = mock{ on { invoke(any()) }doReturn MetadataIconData.defaultIcon() } @@ -118,6 +103,20 @@ class EventInitialTest { on { provideDueDate() } doReturn "Due date" } + private val eventDetailsRepository: EventDetailsRepository = mock { + on { getProgramStage() } doReturn programStage + on { catCombo() } doReturn catCombo + on { getEvent() } doReturn null + on { getObjectStyle() } doReturn style + on { getOrganisationUnit(ORG_UNIT_UID) } doReturn orgUnit + on { getGeometryModel() } doReturn geometryModel + on { getCatOptionCombos(CAT_COMBO_UID) } doReturn listOf(categoryOptionCombo) + on { getEditableStatus() } doReturn EventEditableStatus.Editable() + on { getEnrollmentDate(ENROLLMENT_UID) } doReturn date + on { getStageLastDate(ENROLLMENT_UID) } doReturn DateUtils.uiDateFormat() + .parse("20/8/2023")!! + } + private fun createConfigureEventTemp(eventCreationType: EventCreationType) = ConfigureEventTemp( creationType = eventCreationType, ) diff --git a/build.gradle.kts b/build.gradle.kts index b1783fea56..217ad01b25 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,3 +1,5 @@ +import java.util.Locale + // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { @@ -43,7 +45,7 @@ sonarqube { val isNonStable: (String) -> Boolean = { version -> val stableKeyword = - listOf("RELEASE", "FINAL", "GA").any { it -> version.toUpperCase().contains(it) } + listOf("RELEASE", "FINAL", "GA").any { it -> version.uppercase().contains(it) } val regex = """^[0-9,.v-]+(-r)?$""".toRegex() !stableKeyword && !(version matches regex) } @@ -113,7 +115,7 @@ allprojects { } tasks.register("clean", Delete::class) { - delete(rootProject.buildDir) + delete(rootProject.layout.buildDirectory) } diff --git a/commons/build.gradle.kts b/commons/build.gradle.kts index f37d81da59..e0ffe2bca1 100644 --- a/commons/build.gradle.kts +++ b/commons/build.gradle.kts @@ -1,8 +1,11 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget + plugins { id("com.android.library") kotlin("android") kotlin("kapt") id("kotlin-parcelize") + alias(libs.plugins.kotlin.compose.compiler) } apply(from = "${project.rootDir}/jacoco/jacoco.gradle.kts") @@ -17,7 +20,7 @@ android { defaultConfig { minSdk = libs.versions.minSdk.get().toInt() - targetSdk = libs.versions.sdk.get().toInt() + testOptions.targetSdk = libs.versions.sdk.get().toInt() vectorDrawables.useSupportLibrary = true testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" @@ -48,19 +51,17 @@ android { dataBinding = true } - kotlinOptions { - jvmTarget = "17" - } - - composeOptions { - kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExtensionVersion.get() - } - configurations.all { resolutionStrategy.cacheDynamicVersionsFor(0, TimeUnit.SECONDS) } } +kotlin { + compilerOptions { + jvmTarget.set(JvmTarget.JVM_17) + } +} + dependencies { implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) api(project(":ui-components")) diff --git a/compose-table/build.gradle.kts b/compose-table/build.gradle.kts index 304d7821e8..0d8159c902 100644 --- a/compose-table/build.gradle.kts +++ b/compose-table/build.gradle.kts @@ -1,7 +1,10 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget + plugins { id("com.android.library") kotlin("android") id("kotlinx-serialization") + alias(libs.plugins.kotlin.compose.compiler) } apply(from = "${project.rootDir}/jacoco/jacoco.gradle.kts") @@ -11,7 +14,7 @@ android { defaultConfig { minSdk = libs.versions.minSdk.get().toInt() - targetSdk = libs.versions.sdk.get().toInt() + testOptions.targetSdk = libs.versions.sdk.get().toInt() testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles("consumer-rules.pro") @@ -38,13 +41,11 @@ android { buildFeatures { compose = true } +} - kotlinOptions { - jvmTarget = "17" - } - - composeOptions { - kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExtensionVersion.get() +kotlin { + compilerOptions { + jvmTarget.set(JvmTarget.JVM_17) } } diff --git a/compose-table/src/androidTest/java/org/dhis2/composetable/CellTableTest.kt b/compose-table/src/androidTest/java/org/dhis2/composetable/CellTableTest.kt index 24555222c3..48281b05ac 100644 --- a/compose-table/src/androidTest/java/org/dhis2/composetable/CellTableTest.kt +++ b/compose-table/src/androidTest/java/org/dhis2/composetable/CellTableTest.kt @@ -47,7 +47,9 @@ class CellTableTest { ) val firstId = fakeModel.first().id!! clickOnCell(firstId, 1, 0) + composeTestRule.waitForIdle() typeOnInputComponent("check") + composeTestRule.waitForIdle() assertCellHasText(firstId, 1, 0, "check") } } diff --git a/dhis2-mobile-program-rules/build.gradle.kts b/dhis2-mobile-program-rules/build.gradle.kts index a43e52b776..70744274a4 100644 --- a/dhis2-mobile-program-rules/build.gradle.kts +++ b/dhis2-mobile-program-rules/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget + plugins { id("com.android.library") kotlin("android") @@ -30,8 +32,11 @@ android { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } - kotlinOptions { - jvmTarget = "17" +} + +kotlin { + compilerOptions { + jvmTarget.set(JvmTarget.JVM_17) } } diff --git a/dhis2_android_maps/build.gradle.kts b/dhis2_android_maps/build.gradle.kts index 4ab7cb5974..b14bcbe293 100644 --- a/dhis2_android_maps/build.gradle.kts +++ b/dhis2_android_maps/build.gradle.kts @@ -1,7 +1,10 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget + plugins { id("com.android.library") kotlin("android") kotlin("kapt") + alias(libs.plugins.kotlin.compose.compiler) } apply(from = "${project.rootDir}/jacoco/jacoco.gradle.kts") @@ -11,7 +14,7 @@ android { defaultConfig { minSdk = libs.versions.minSdk.get().toInt() - targetSdk = libs.versions.sdk.get().toInt() + testOptions.targetSdk = libs.versions.sdk.get().toInt() vectorDrawables.useSupportLibrary = true testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" @@ -40,13 +43,11 @@ android { dataBinding = true } flavorDimensions += listOf("default") +} - kotlinOptions { - jvmTarget = "17" - } - - composeOptions { - kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExtensionVersion.get() +kotlin { + compilerOptions { + jvmTarget.set(JvmTarget.JVM_17) } } diff --git a/dhis_android_analytics/build.gradle.kts b/dhis_android_analytics/build.gradle.kts index 712b4e29c2..409a55a178 100644 --- a/dhis_android_analytics/build.gradle.kts +++ b/dhis_android_analytics/build.gradle.kts @@ -1,7 +1,10 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget + plugins { id("com.android.library") kotlin("android") kotlin("kapt") + alias(libs.plugins.kotlin.compose.compiler) } apply(from = "${project.rootDir}/jacoco/jacoco.gradle.kts") @@ -16,7 +19,7 @@ android { defaultConfig { minSdk = libs.versions.minSdk.get().toInt() - targetSdk = libs.versions.sdk.get().toInt() + testOptions.targetSdk = libs.versions.sdk.get().toInt() vectorDrawables.useSupportLibrary = true testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" @@ -46,12 +49,11 @@ android { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } - kotlinOptions { - jvmTarget = "17" - } +} - composeOptions { - kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExtensionVersion.get() +kotlin { + compilerOptions { + jvmTarget.set(JvmTarget.JVM_17) } } diff --git a/form/build.gradle.kts b/form/build.gradle.kts index 9b7f7de06d..6adf2fdd84 100644 --- a/form/build.gradle.kts +++ b/form/build.gradle.kts @@ -1,7 +1,10 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget + plugins { id("com.android.library") kotlin("android") kotlin("kapt") + alias(libs.plugins.kotlin.compose.compiler) } apply(from = "${project.rootDir}/jacoco/jacoco.gradle.kts") @@ -15,7 +18,7 @@ android { defaultConfig { minSdk = libs.versions.minSdk.get().toInt() - targetSdk = libs.versions.sdk.get().toInt() + testOptions.targetSdk = libs.versions.sdk.get().toInt() vectorDrawables.useSupportLibrary = true testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" @@ -46,14 +49,6 @@ android { dataBinding = true } - kotlinOptions { - jvmTarget = "17" - } - - composeOptions { - kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExtensionVersion.get() - } - testOptions { unitTests { isReturnDefaultValues = true @@ -61,6 +56,12 @@ android { } } +kotlin { + compilerOptions { + jvmTarget.set(JvmTarget.JVM_17) + } +} + dependencies { implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 272fa47ba4..653ae90168 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,8 +5,8 @@ minSdk = "21" vCode = "130" vName = "3.0" kotlinCompilerExtensionVersion = "1.5.6" -gradle = "8.2.2" -kotlin = '1.9.21' +gradle = "8.4.2" +kotlin = '2.0.0' hilt = '2.47' jacoco = '0.8.10' designSystem = "0.3.0-SNAPSHOT" @@ -84,7 +84,7 @@ androidx_test = "1.5.0" dexmaker-mockito-inline = "2.28.1" hamcrest = "2.2" kotlinxserialization = "1.5.1" -desugar_jdk_libs = "2.0.3" +desugar_jdk_libs = "2.0.4" google_truth = "1.1.2" kotlinxcoroutines = "1.6.4" rxrelay = "2.1.1" @@ -213,6 +213,8 @@ dispatcher-dispatchCore = { group = "com.rickbusarow.dispatch", name = "dispatch dispatcher-dispatchEspresso = { group = "com.rickbusarow.dispatch", name = "dispatch-android-espresso", version = "1.0.0-beta10" } deprecated-autoValueParcel = { group = "com.ryanharter.auto.value", name = "auto-value-parcel", version.ref = "autovalueparcel" } #TODO: Remove alongside AutoValue [plugins] +kotlin-compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } + [bundles] uicomponents-implementation = ["androidx-coreKtx", "androidx-material3", "google-material", "lottie-compose", "dhis2-mobile-designsystem"] uicomponents-api = ["dhis2-mobile-designsystem", "androidx-compose-constraintlayout", "androidx-compose-preview", "androidx-compose-ui", "google-material-themeadapter", "google-material3-themeadapter"] diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b0d1b0f4d8..7e7a9963bd 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Aug 09 13:28:11 CEST 2023 +#Wed Jun 26 12:02:53 CEST 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/stock-usecase/build.gradle.kts b/stock-usecase/build.gradle.kts index 1e391afcc1..f2f8b3d30e 100644 --- a/stock-usecase/build.gradle.kts +++ b/stock-usecase/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget + plugins { id("com.android.library") kotlin("android") @@ -5,6 +7,7 @@ plugins { id("kotlin-parcelize") id("dagger.hilt.android.plugin") id("kotlinx-serialization") + alias(libs.plugins.kotlin.compose.compiler) } apply(from = "${project.rootDir}/jacoco/jacoco.gradle.kts") @@ -22,7 +25,7 @@ android { defaultConfig { minSdk = libs.versions.minSdk.get().toInt() - targetSdk = libs.versions.sdk.get().toInt() + testOptions.targetSdk = libs.versions.sdk.get().toInt() multiDexEnabled = true javaCompileOptions { @@ -73,13 +76,11 @@ android { ) } } +} - composeOptions { - kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExtensionVersion.get() - } - - kotlinOptions { - jvmTarget = "17" +kotlin { + compilerOptions { + jvmTarget.set(JvmTarget.JVM_17) } } diff --git a/ui-components/build.gradle.kts b/ui-components/build.gradle.kts index e6d8cbc3b9..1021429abc 100644 --- a/ui-components/build.gradle.kts +++ b/ui-components/build.gradle.kts @@ -1,8 +1,11 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget + plugins { id("com.android.library") kotlin("android") id("kotlin-parcelize") id("kotlinx-serialization") + alias(libs.plugins.kotlin.compose.compiler) } apply(from = "${project.rootDir}/jacoco/jacoco.gradle.kts") @@ -12,7 +15,7 @@ android { defaultConfig { minSdk = libs.versions.minSdk.get().toInt() - targetSdk = libs.versions.sdk.get().toInt() + testOptions.targetSdk = libs.versions.sdk.get().toInt() testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles("consumer-rules.pro") @@ -42,13 +45,11 @@ android { buildFeatures { compose = true } +} - kotlinOptions { - jvmTarget = "17" - } - - composeOptions { - kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExtensionVersion.get() +kotlin { + compilerOptions { + jvmTarget.set(JvmTarget.JVM_17) } } diff --git a/ui-components/src/main/java/org/dhis2/ui/inputs/FileInput.kt b/ui-components/src/main/java/org/dhis2/ui/inputs/FileInput.kt index e5f93a9036..2d4b0d2659 100644 --- a/ui-components/src/main/java/org/dhis2/ui/inputs/FileInput.kt +++ b/ui-components/src/main/java/org/dhis2/ui/inputs/FileInput.kt @@ -63,7 +63,7 @@ fun BoxedInput( ) { val (leadingIconRef, contentRef, trailingIconsRef) = createRefs() leadingIcon( - modifier = Modifier.constrainAs(leadingIconRef) { + Modifier.constrainAs(leadingIconRef) { start.linkTo(parent.start) top.linkTo(parent.top) bottom.linkTo(parent.bottom) @@ -71,7 +71,7 @@ fun BoxedInput( }, ) content( - modifier = Modifier.constrainAs(contentRef) { + Modifier.constrainAs(contentRef) { start.linkTo(leadingIconRef.end, 8.dp) top.linkTo(parent.top) bottom.linkTo(parent.bottom) diff --git a/viewpagerdotsindicator/build.gradle.kts b/viewpagerdotsindicator/build.gradle.kts index 5604b59249..d197597c30 100644 --- a/viewpagerdotsindicator/build.gradle.kts +++ b/viewpagerdotsindicator/build.gradle.kts @@ -8,7 +8,7 @@ android { defaultConfig { minSdk = libs.versions.minSdk.get().toInt() - targetSdk = libs.versions.sdk.get().toInt() + testOptions.targetSdk = libs.versions.sdk.get().toInt() } namespace = "com.tbuonomo.viewpagerdotsindicator" buildTypes {