Skip to content

Commit 39ecb2c

Browse files
authored
Refactor gradle dependencies and plugins management (#2903)
* Refactor gradle dependencies to use toml file Signed-off-by: Elly Kitoto <[email protected]> * Migrate gradle plugins to toml file Signed-off-by: Elly Kitoto <[email protected]> * Order dependencies declarations lexographically Signed-off-by: Elly Kitoto <[email protected]> * Restore necessary comment Signed-off-by: Elly Kitoto <[email protected]> --------- Signed-off-by: Elly Kitoto <[email protected]>
1 parent 209c682 commit 39ecb2c

File tree

23 files changed

+284
-339
lines changed

23 files changed

+284
-339
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,5 @@ docs/use/api/*/**
100100

101101
# Synthea
102102
synthea
103+
104+
.vscode

.vscode/extensions.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 0 additions & 32 deletions
This file was deleted.

build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ buildscript {
77
}
88
dependencies {
99
classpath(Plugins.androidGradlePlugin)
10-
classpath(Plugins.kspGradlePlugin)
1110
classpath(Plugins.benchmarkGradlePlugin)
1211
classpath(Plugins.flankGradlePlugin)
12+
classpath(Plugins.kotlinComposePlugin)
1313
classpath(Plugins.kotlinGradlePlugin)
14+
classpath(Plugins.kotlinSerializationPlugin)
15+
classpath(Plugins.kspGradlePlugin)
1416
classpath(Plugins.navSafeArgsGradlePlugin)
1517
classpath(Plugins.rulerGradlePlugin)
16-
classpath(Plugins.kotlinComposePlugin)
17-
classpath(Plugins.kotlinSerializationPlugin)
1818
}
1919
}
2020

buildSrc/src/main/kotlin/Dependencies.kt

Lines changed: 1 addition & 89 deletions
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.
@@ -41,16 +41,7 @@ object Dependencies {
4141
const val fhirCoreUtilsModule = "ca.uhn.hapi.fhir:org.hl7.fhir.utilities"
4242
const val fhirCoreConvertorsModule = "ca.uhn.hapi.fhir:org.hl7.fhir.convertors"
4343

44-
const val guavaCachingModule = "ca.uhn.hapi.fhir:hapi-fhir-caching-guava"
45-
46-
const val structuresR4 = "$structuresR4Module:${Versions.hapiFhir}"
47-
4844
const val validation = "$validationModule:${Versions.hapiFhir}"
49-
const val validationR4 = "$validationR4Module:${Versions.hapiFhir}"
50-
51-
const val fhirCoreConvertors = "$fhirCoreConvertorsModule:${Versions.hapiFhirCore}"
52-
53-
const val guavaCaching = "$guavaCachingModule:${Versions.hapiFhir}"
5445
}
5546

5647
object Jackson {
@@ -70,102 +61,23 @@ object Dependencies {
7061
const val jsr310Base = "$datatypeGroup:jackson-datatype-jsr310:${Versions.jackson}"
7162
}
7263

73-
object Retrofit {
74-
const val coreRetrofit = "com.squareup.retrofit2:retrofit:${Versions.retrofit}"
75-
const val gsonConverter = "com.squareup.retrofit2:converter-gson:${Versions.retrofit}"
76-
}
77-
78-
object Mlkit {
79-
const val barcodeScanning =
80-
"com.google.mlkit:barcode-scanning:${Versions.Mlkit.barcodeScanning}"
81-
const val objectDetection =
82-
"com.google.mlkit:object-detection:${Versions.Mlkit.objectDetection}"
83-
const val objectDetectionCustom =
84-
"com.google.mlkit:object-detection-custom:${Versions.Mlkit.objectDetectionCustom}"
85-
}
86-
87-
const val playServicesLocation =
88-
"com.google.android.gms:play-services-location:${Versions.playServicesLocation}"
89-
90-
const val apacheCommonsCompress =
91-
"org.apache.commons:commons-compress:${Versions.apacheCommonsCompress}"
92-
93-
const val desugarJdkLibs = "com.android.tools:desugar_jdk_libs:${Versions.desugarJdkLibs}"
94-
const val fhirUcum = "org.fhir:ucum:${Versions.fhirUcum}"
95-
9664
const val guavaModule = "com.google.guava:guava"
97-
const val guava = "$guavaModule:${Versions.guava}"
98-
99-
const val httpInterceptor = "com.squareup.okhttp3:logging-interceptor:${Versions.http}"
100-
const val http = "com.squareup.okhttp3:okhttp:${Versions.http}"
101-
const val mockWebServer = "com.squareup.okhttp3:mockwebserver:${Versions.http}"
102-
103-
const val jsonToolsPatch = "com.github.java-json-tools:json-patch:${Versions.jsonToolsPatch}"
104-
const val sqlcipher = "net.zetetic:android-database-sqlcipher:${Versions.sqlcipher}"
105-
const val timber = "com.jakewharton.timber:timber:${Versions.timber}"
106-
const val woodstox = "com.fasterxml.woodstox:woodstox-core:${Versions.woodstox}"
107-
const val xerces = "xerces:xercesImpl:${Versions.xerces}"
108-
109-
const val zxing = "com.google.zxing:core:${Versions.zxing}"
110-
const val nimbus = "com.nimbusds:nimbus-jose-jwt:${Versions.nimbus}"
111-
112-
const val androidBenchmarkRunner = "androidx.benchmark.junit4.AndroidBenchmarkRunner"
113-
const val androidJunitRunner = "androidx.test.runner.AndroidJUnitRunner"
114-
115-
// Makes Json assertions where the order of elements, tabs/whitespaces are not important.
116-
const val jsonAssert = "org.skyscreamer:jsonassert:${Versions.jsonAssert}"
117-
const val mockitoKotlin = "org.mockito.kotlin:mockito-kotlin:${Versions.mockitoKotlin}"
118-
const val mockitoInline = "org.mockito:mockito-inline:${Versions.mockitoInline}"
119-
const val robolectric = "org.robolectric:robolectric:${Versions.robolectric}"
120-
121-
// Makes XML assertions where the order of elements, tabs/whitespaces are not important.
122-
const val xmlUnit = "org.xmlunit:xmlunit-core:${Versions.xmlUnit}"
12365

12466
object Versions {
125-
const val apacheCommonsCompress = "1.21"
126-
const val desugarJdkLibs = "2.0.3"
127-
const val caffeine = "2.9.1"
128-
const val fhirUcum = "1.0.3"
12967
const val guava = "32.1.3-android"
13068

13169
const val hapiFhir = "6.8.0"
13270
const val hapiFhirCore = "6.0.22"
13371

134-
const val http = "4.11.0"
135-
13672
// Maximum Jackson libraries (excluding core) version that supports Android API Level 24:
13773
// https://github.com/FasterXML/jackson-databind/issues/3658
13874
const val jackson = "2.13.5"
13975

14076
// Maximum Jackson Core library version that supports Android API Level 24:
14177
const val jacksonCore = "2.15.2"
14278

143-
const val jsonToolsPatch = "1.13"
144-
const val jsonAssert = "1.5.1"
145-
const val retrofit = "2.9.0"
146-
const val gsonConverter = "2.1.0"
147-
const val sqlcipher = "4.5.4"
148-
const val timber = "5.0.1"
149-
const val woodstox = "6.5.1"
150-
const val xerces = "2.12.2"
151-
const val xmlUnit = "2.9.1"
152-
153-
const val zxing = "3.4.1"
154-
const val nimbus = "9.31"
155-
15679
// Test dependencies
15780
const val jacoco = "0.8.10"
158-
const val mockitoKotlin = "3.2.0"
159-
const val mockitoInline = "4.0.0"
160-
const val robolectric = "4.10.3"
161-
162-
object Mlkit {
163-
const val barcodeScanning = "16.1.1"
164-
const val objectDetection = "16.2.3"
165-
const val objectDetectionCustom = "16.3.1"
166-
}
167-
168-
const val playServicesLocation = "21.0.1"
16981
}
17082

17183
fun Configuration.removeIncompatibleDependencies() {

buildSrc/src/main/kotlin/Plugins.kt

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,9 @@
1717
object Plugins {
1818

1919
object BuildPlugins {
20-
const val androidLib = "com.android.library"
21-
const val application = "com.android.application"
22-
const val benchmark = "androidx.benchmark"
23-
const val dokka = "org.jetbrains.dokka"
24-
const val kotlin = "kotlin"
25-
const val kotlinAndroid = "kotlin-android"
26-
const val kotlinCompose = "org.jetbrains.kotlin.plugin.compose"
27-
const val kotlinKsp = "com.google.devtools.ksp"
28-
const val kotlinSerialization = "org.jetbrains.kotlin.plugin.serialization"
29-
const val mavenPublish = "maven-publish"
3020
const val fladle = "com.osacky.fladle"
31-
const val navSafeArgs = "androidx.navigation.safeargs.kotlin"
3221
const val ruler = "com.spotify.ruler"
3322
const val spotless = "com.diffplug.spotless"
34-
const val androidTest = "com.android.test"
3523
}
3624

3725
// classpath plugins
@@ -52,7 +40,6 @@ object Plugins {
5240
object Versions {
5341
const val androidGradlePlugin = "8.9.2"
5442
const val benchmarkPlugin = "1.4.0-rc01"
55-
const val dokka = "1.9.20"
5643
const val kspPlugin = "2.1.20-2.0.1"
5744
const val kotlin = "2.1.20"
5845
}

catalog/build.gradle.kts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
plugins {
2-
id(Plugins.BuildPlugins.application)
3-
id(Plugins.BuildPlugins.kotlinAndroid)
4-
id(Plugins.BuildPlugins.navSafeArgs)
2+
alias(libs.plugins.android.application)
3+
alias(libs.plugins.kotlin.android)
4+
alias(libs.plugins.androidx.navigation.safeargs)
55
}
66

77
configureRuler()
@@ -15,7 +15,7 @@ android {
1515
targetSdk = Sdk.TARGET_SDK
1616
versionCode = Releases.Catalog.versionCode
1717
versionName = Releases.Catalog.versionName
18-
testInstrumentationRunner = Dependencies.androidJunitRunner
18+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
1919
}
2020

2121
buildFeatures { viewBinding = true }
@@ -44,7 +44,7 @@ dependencies {
4444
androidTestImplementation(libs.androidx.test.espresso.core)
4545
androidTestImplementation(libs.androidx.test.ext.junit)
4646

47-
coreLibraryDesugaring(Dependencies.desugarJdkLibs)
47+
coreLibraryDesugaring(libs.desugar.jdk.libs)
4848

4949
implementation(libs.androidx.appcompat)
5050
implementation(libs.androidx.constraintlayout)
@@ -54,11 +54,10 @@ dependencies {
5454
implementation(libs.androidx.navigation.ui)
5555
implementation(libs.kotlin.stdlib)
5656
implementation(libs.material)
57-
58-
implementation(project(path = ":datacapture"))
59-
implementation(project(path = ":engine"))
6057
implementation(project(path = ":contrib:barcode"))
6158
implementation(project(path = ":contrib:locationwidget"))
59+
implementation(project(path = ":datacapture"))
60+
implementation(project(path = ":engine"))
6261

6362
testImplementation(libs.junit)
6463
}

common/build.gradle.kts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import Dependencies.removeIncompatibleDependencies
22

33
plugins {
4-
id(Plugins.BuildPlugins.androidLib)
5-
id(Plugins.BuildPlugins.kotlinAndroid)
6-
id(Plugins.BuildPlugins.mavenPublish)
4+
alias(libs.plugins.android.library)
5+
alias(libs.plugins.kotlin.android)
6+
alias(libs.plugins.dokka)
7+
`maven-publish`
78
jacoco
89
}
910

@@ -22,14 +23,14 @@ android {
2223
configurations { all { removeIncompatibleDependencies() } }
2324

2425
dependencies {
25-
api(Dependencies.HapiFhir.structuresR4)
26+
api(libs.hapi.fhir.structures.r4)
2627

27-
implementation(Dependencies.fhirUcum)
28+
implementation(libs.fhir.ucum)
2829

29-
testImplementation(Dependencies.robolectric)
3030
testImplementation(libs.androidx.test.core)
3131
testImplementation(libs.junit)
3232
testImplementation(libs.kotlin.test.junit)
33+
testImplementation(libs.robolectric)
3334
testImplementation(libs.truth)
3435

3536
constraints {

contrib/barcode/build.gradle.kts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import Dependencies.removeIncompatibleDependencies
22

33
plugins {
4-
id(Plugins.BuildPlugins.androidLib)
5-
id(Plugins.BuildPlugins.kotlinAndroid)
6-
id(Plugins.BuildPlugins.mavenPublish)
4+
alias(libs.plugins.android.library)
5+
alias(libs.plugins.kotlin.android)
6+
`maven-publish`
77
jacoco
8+
alias(libs.plugins.dokka)
89
}
910

1011
publishArtifact(Releases.Contrib.Barcode)
@@ -16,7 +17,7 @@ android {
1617
compileSdk = Sdk.COMPILE_SDK
1718
defaultConfig {
1819
minSdk = Sdk.MIN_SDK
19-
testInstrumentationRunner = Dependencies.androidJunitRunner
20+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
2021
// Need to specify this to prevent junit runner from going deep into our dependencies
2122
testInstrumentationRunnerArguments["package"] = "com.google.android.fhir.datacapture"
2223
}
@@ -55,33 +56,33 @@ android {
5556
configurations { all { removeIncompatibleDependencies() } }
5657

5758
dependencies {
58-
androidTestImplementation(Dependencies.mockitoInline)
5959
androidTestImplementation(libs.androidx.fragment.testing)
6060
androidTestImplementation(libs.androidx.test.core)
6161
androidTestImplementation(libs.androidx.test.ext.junit)
6262
androidTestImplementation(libs.androidx.test.ext.junit.ktx)
6363
androidTestImplementation(libs.androidx.test.rules)
6464
androidTestImplementation(libs.androidx.test.runner)
65+
androidTestImplementation(libs.mockito.inline)
6566
androidTestImplementation(libs.truth)
6667

67-
coreLibraryDesugaring(Dependencies.desugarJdkLibs)
68+
coreLibraryDesugaring(libs.desugar.jdk.libs)
6869

69-
implementation(project(":datacapture"))
70-
implementation(Dependencies.Mlkit.barcodeScanning)
71-
implementation(Dependencies.Mlkit.objectDetection)
72-
implementation(Dependencies.Mlkit.objectDetectionCustom)
73-
implementation(Dependencies.timber)
7470
implementation(libs.androidx.appcompat)
7571
implementation(libs.androidx.core)
7672
implementation(libs.androidx.fragment)
7773
implementation(libs.material)
74+
implementation(libs.mlkit.barcode.scanning)
75+
implementation(libs.mlkit.obj.detection)
76+
implementation(libs.mlkit.obj.detection.custom)
77+
implementation(libs.timber)
78+
implementation(project(":datacapture"))
7879

79-
testImplementation(Dependencies.mockitoInline)
80-
testImplementation(Dependencies.mockitoKotlin)
81-
testImplementation(Dependencies.robolectric)
8280
testImplementation(libs.androidx.fragment.testing)
8381
testImplementation(libs.androidx.test.core)
8482
testImplementation(libs.junit)
8583
testImplementation(libs.kotlin.test.junit)
84+
testImplementation(libs.mockito.inline)
85+
testImplementation(libs.mockito.kotlin)
86+
testImplementation(libs.robolectric)
8687
testImplementation(libs.truth)
8788
}

0 commit comments

Comments
 (0)