Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency versions fix #2380

Merged
merged 6 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
183 changes: 98 additions & 85 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import org.gradle.api.artifacts.Configuration
import org.gradle.api.artifacts.DependencyConstraint
import org.gradle.kotlin.dsl.exclude

object Dependencies {
Expand Down Expand Up @@ -42,34 +43,53 @@ object Dependencies {
}

object HapiFhir {
const val fhirBase = "ca.uhn.hapi.fhir:hapi-fhir-base:${Versions.hapiFhir}"
const val fhirClient = "ca.uhn.hapi.fhir:hapi-fhir-client:${Versions.hapiFhir}"
const val structuresDstu2 = "ca.uhn.hapi.fhir:hapi-fhir-structures-dstu2:${Versions.hapiFhir}"
const val structuresDstu3 = "ca.uhn.hapi.fhir:hapi-fhir-structures-dstu3:${Versions.hapiFhir}"
const val structuresR4 = "ca.uhn.hapi.fhir:hapi-fhir-structures-r4:${Versions.hapiFhir}"
const val structuresR4b = "ca.uhn.hapi.fhir:hapi-fhir-structures-r4b:${Versions.hapiFhir}"
const val structuresR5 = "ca.uhn.hapi.fhir:hapi-fhir-structures-r5:${Versions.hapiFhir}"

const val validation = "ca.uhn.hapi.fhir:hapi-fhir-validation:${Versions.hapiFhir}"
const val validationDstu3 =
"ca.uhn.hapi.fhir:hapi-fhir-validation-resources-dstu3:${Versions.hapiFhir}"
const val validationR4 =
"ca.uhn.hapi.fhir:hapi-fhir-validation-resources-r4:${Versions.hapiFhir}"
const val validationR5 =
"ca.uhn.hapi.fhir:hapi-fhir-validation-resources-r5:${Versions.hapiFhir}"

const val fhirCoreDstu2 = "ca.uhn.hapi.fhir:org.hl7.fhir.dstu2:${Versions.hapiFhirCore}"
const val fhirCoreDstu2016 =
"ca.uhn.hapi.fhir:org.hl7.fhir.dstu2016may:${Versions.hapiFhirCore}"
const val fhirCoreDstu3 = "ca.uhn.hapi.fhir:org.hl7.fhir.dstu3:${Versions.hapiFhirCore}"
const val fhirCoreR4 = "ca.uhn.hapi.fhir:org.hl7.fhir.r4:${Versions.hapiFhirCore}"
const val fhirCoreR4b = "ca.uhn.hapi.fhir:org.hl7.fhir.r4b:${Versions.hapiFhirCore}"
const val fhirCoreR5 = "ca.uhn.hapi.fhir:org.hl7.fhir.r5:${Versions.hapiFhirCore}"
const val fhirCoreUtils = "ca.uhn.hapi.fhir:org.hl7.fhir.utilities:${Versions.hapiFhirCore}"
const val fhirCoreConvertors =
"ca.uhn.hapi.fhir:org.hl7.fhir.convertors:${Versions.hapiFhirCore}"

const val guavaCaching = "ca.uhn.hapi.fhir:hapi-fhir-caching-guava:${Versions.hapiFhir}"
const val fhirBaseModule = "ca.uhn.hapi.fhir:hapi-fhir-base"
const val fhirClientModule = "ca.uhn.hapi.fhir:hapi-fhir-client"
const val structuresDstu2Module = "ca.uhn.hapi.fhir:hapi-fhir-structures-dstu2"
const val structuresDstu3Module = "ca.uhn.hapi.fhir:hapi-fhir-structures-dstu3"
const val structuresR4Module = "ca.uhn.hapi.fhir:hapi-fhir-structures-r4"
const val structuresR4bModule = "ca.uhn.hapi.fhir:hapi-fhir-structures-r4b"
const val structuresR5Module = "ca.uhn.hapi.fhir:hapi-fhir-structures-r5"

const val validationModule = "ca.uhn.hapi.fhir:hapi-fhir-validation"
const val validationDstu3Module = "ca.uhn.hapi.fhir:hapi-fhir-validation-resources-dstu3"
const val validationR4Module = "ca.uhn.hapi.fhir:hapi-fhir-validation-resources-r4"
const val validationR5Module = "ca.uhn.hapi.fhir:hapi-fhir-validation-resources-r5"

const val fhirCoreDstu2Module = "ca.uhn.hapi.fhir:org.hl7.fhir.dstu2"
const val fhirCoreDstu2016Module = "ca.uhn.hapi.fhir:org.hl7.fhir.dstu2016may"
const val fhirCoreDstu3Module = "ca.uhn.hapi.fhir:org.hl7.fhir.dstu3"
const val fhirCoreR4Module = "ca.uhn.hapi.fhir:org.hl7.fhir.r4"
const val fhirCoreR4bModule = "ca.uhn.hapi.fhir:org.hl7.fhir.r4b"
const val fhirCoreR5Module = "ca.uhn.hapi.fhir:org.hl7.fhir.r5"
const val fhirCoreUtilsModule = "ca.uhn.hapi.fhir:org.hl7.fhir.utilities"
const val fhirCoreConvertorsModule = "ca.uhn.hapi.fhir:org.hl7.fhir.convertors"

const val guavaCachingModule = "ca.uhn.hapi.fhir:hapi-fhir-caching-guava"

const val fhirBase = "$fhirBaseModule:${Versions.hapiFhir}"
const val fhirClient = "$fhirClientModule:${Versions.hapiFhir}"
const val structuresDstu2 = "$structuresDstu2Module:${Versions.hapiFhir}"
const val structuresDstu3 = "$structuresDstu3Module:${Versions.hapiFhir}"
const val structuresR4 = "$structuresR4Module:${Versions.hapiFhir}"
const val structuresR4b = "$structuresR4bModule:${Versions.hapiFhir}"
const val structuresR5 = "$structuresR5Module:${Versions.hapiFhir}"

const val validation = "$validationModule:${Versions.hapiFhir}"
const val validationDstu3 = "$validationDstu3Module:${Versions.hapiFhir}"
const val validationR4 = "$validationR4Module:${Versions.hapiFhir}"
const val validationR5 = "$validationR5Module:${Versions.hapiFhir}"

const val fhirCoreDstu2 = "$fhirCoreDstu2Module:${Versions.hapiFhirCore}"
const val fhirCoreDstu2016 = "$fhirCoreDstu2016Module:${Versions.hapiFhirCore}"
const val fhirCoreDstu3 = "$fhirCoreDstu3Module:${Versions.hapiFhirCore}"
const val fhirCoreR4 = "$fhirCoreR4Module:${Versions.hapiFhirCore}"
const val fhirCoreR4b = "$fhirCoreR4bModule:${Versions.hapiFhirCore}"
const val fhirCoreR5 = "$fhirCoreR5Module:${Versions.hapiFhirCore}"
const val fhirCoreUtils = "$fhirCoreUtilsModule:${Versions.hapiFhirCore}"
const val fhirCoreConvertors = "$fhirCoreConvertorsModule:${Versions.hapiFhirCore}"

const val guavaCaching = "$guavaCachingModule:${Versions.hapiFhir}"
}

object Jackson {
Expand All @@ -79,13 +99,22 @@ object Dependencies {
private const val datatypeGroup = "$mainGroup.datatype"
private const val moduleGroup = "$mainGroup.module"

const val annotations = "$coreGroup:jackson-annotations:${Versions.jackson}"
const val bom = "$mainGroup:jackson-bom:${Versions.jackson}"
const val core = "$coreGroup:jackson-core:${Versions.jacksonCore}"
const val databind = "$coreGroup:jackson-databind:${Versions.jackson}"
const val dataformatXml = "$dataformatGroup:jackson-dataformat-xml:${Versions.jackson}"
const val jaxbAnnotations = "$moduleGroup:jackson-module-jaxb-annotations:${Versions.jackson}"
const val jsr310 = "$datatypeGroup:jackson-datatype-jsr310:${Versions.jackson}"
const val annotationsBase = "$coreGroup:jackson-annotations:${Versions.jackson}"
const val bomBase = "$mainGroup:jackson-bom:${Versions.jackson}"
const val coreBase = "$coreGroup:jackson-core:${Versions.jacksonCore}"
const val databindBase = "$coreGroup:jackson-databind:${Versions.jackson}"
const val dataformatXmlBase = "$dataformatGroup:jackson-dataformat-xml:${Versions.jackson}"
const val jaxbAnnotationsBase =
"$moduleGroup:jackson-module-jaxb-annotations:${Versions.jackson}"
const val jsr310Base = "$datatypeGroup:jackson-datatype-jsr310:${Versions.jackson}"

const val annotations = "$annotationsBase:${Versions.jackson}"
const val bom = "$bomBase:${Versions.jackson}"
const val core = "$coreBase:${Versions.jacksonCore}"
const val databind = "$databindBase:${Versions.jackson}"
const val dataformatXml = "$dataformatXmlBase:${Versions.jackson}"
const val jaxbAnnotations = "$jaxbAnnotationsBase:${Versions.jackson}"
const val jsr310 = "$jsr310Base:${Versions.jackson}"
vitorpamplona marked this conversation as resolved.
Show resolved Hide resolved
}

object Kotlin {
Expand Down Expand Up @@ -148,7 +177,10 @@ object Dependencies {
const val desugarJdkLibs = "com.android.tools:desugar_jdk_libs:${Versions.desugarJdkLibs}"
const val fhirUcum = "org.fhir:ucum:${Versions.fhirUcum}"
const val gson = "com.google.code.gson:gson:${Versions.gson}"
const val guava = "com.google.guava:guava:${Versions.guava}"

const val guavaModule = "com.google.guava:guava"
const val guava = "$guavaModule:${Versions.guava}"

const val httpInterceptor = "com.squareup.okhttp3:logging-interceptor:${Versions.http}"
const val http = "com.squareup.okhttp3:okhttp:${Versions.http}"
const val mockWebServer = "com.squareup.okhttp3:mockwebserver:${Versions.http}"
Expand Down Expand Up @@ -231,7 +263,7 @@ object Dependencies {
const val caffeine = "2.9.1"
const val fhirUcum = "1.0.3"
const val gson = "2.9.1"
const val guava = "32.1.2-android"
const val guava = "32.1.3-android"

const val hapiFhir = "6.8.0"
const val hapiFhirCore = "6.0.22"
Expand Down Expand Up @@ -294,57 +326,38 @@ object Dependencies {
exclude(group = "org.apache.httpcomponents")
exclude(group = "org.antlr", module = "antlr4")
exclude(group = "org.eclipse.persistence", module = "org.eclipse.persistence.moxy")
}

fun Configuration.forceGuava() {
// Removes caffeine
exclude(module = "hapi-fhir-caching-caffeine")
exclude(group = "com.github.ben-manes.caffeine", module = "caffeine")

resolutionStrategy {
force(guava)
force(HapiFhir.guavaCaching)
}
}

fun Configuration.forceHapiVersion() {
// Removes newer versions of caffeine and manually imports 2.9
// Removes newer versions of hapi and keeps on 6.0.1
// (newer versions don't work on Android)
resolutionStrategy {
force(HapiFhir.fhirBase)
force(HapiFhir.fhirClient)
force(HapiFhir.fhirCoreConvertors)

force(HapiFhir.fhirCoreDstu2)
force(HapiFhir.fhirCoreDstu2016)
force(HapiFhir.fhirCoreDstu3)
force(HapiFhir.fhirCoreR4)
force(HapiFhir.fhirCoreR4b)
force(HapiFhir.fhirCoreR5)
force(HapiFhir.fhirCoreUtils)

force(HapiFhir.structuresDstu2)
force(HapiFhir.structuresDstu3)
force(HapiFhir.structuresR4)
force(HapiFhir.structuresR5)

force(HapiFhir.validation)
force(HapiFhir.validationDstu3)
force(HapiFhir.validationR4)
force(HapiFhir.validationR5)
}
}

fun Configuration.forceJacksonVersion() {
resolutionStrategy {
force(Jackson.annotations)
force(Jackson.bom)
force(Jackson.core)
force(Jackson.databind)
force(Jackson.jaxbAnnotations)
force(Jackson.jsr310)
force(Jackson.dataformatXml)
}
fun hapiFhirConstraints(): Map<String, DependencyConstraint.() -> Unit> {
return mutableMapOf<String, DependencyConstraint.() -> Unit>(
guavaModule to { version { strictly(Versions.guava) } },
HapiFhir.fhirBaseModule to { version { strictly(Versions.hapiFhir) } },
HapiFhir.fhirClientModule to { version { strictly(Versions.hapiFhir) } },
HapiFhir.fhirCoreConvertorsModule to { version { strictly(Versions.hapiFhirCore) } },
HapiFhir.fhirCoreDstu2Module to { version { strictly(Versions.hapiFhirCore) } },
HapiFhir.fhirCoreDstu2016Module to { version { strictly(Versions.hapiFhirCore) } },
HapiFhir.fhirCoreDstu3Module to { version { strictly(Versions.hapiFhirCore) } },
HapiFhir.fhirCoreR4Module to { version { strictly(Versions.hapiFhirCore) } },
HapiFhir.fhirCoreR4bModule to { version { strictly(Versions.hapiFhirCore) } },
HapiFhir.fhirCoreR5Module to { version { strictly(Versions.hapiFhirCore) } },
HapiFhir.fhirCoreUtilsModule to { version { strictly(Versions.hapiFhirCore) } },
HapiFhir.structuresDstu2Module to { version { strictly(Versions.hapiFhir) } },
HapiFhir.structuresDstu3Module to { version { strictly(Versions.hapiFhir) } },
HapiFhir.structuresR4Module to { version { strictly(Versions.hapiFhir) } },
HapiFhir.structuresR5Module to { version { strictly(Versions.hapiFhir) } },
HapiFhir.validationModule to { version { strictly(Versions.hapiFhir) } },
HapiFhir.validationDstu3Module to { version { strictly(Versions.hapiFhir) } },
HapiFhir.validationR4Module to { version { strictly(Versions.hapiFhir) } },
HapiFhir.validationR5Module to { version { strictly(Versions.hapiFhir) } },
Jackson.annotationsBase to { version { strictly(Versions.jackson) } },
Jackson.bomBase to { version { strictly(Versions.jackson) } },
Jackson.coreBase to { version { strictly(Versions.jacksonCore) } },
Jackson.databindBase to { version { strictly(Versions.jackson) } },
Jackson.jaxbAnnotationsBase to { version { strictly(Versions.jackson) } },
Jackson.jsr310Base to { version { strictly(Versions.jackson) } },
Jackson.dataformatXmlBase to { version { strictly(Versions.jackson) } },
)
}
}
4 changes: 0 additions & 4 deletions catalog/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import Dependencies.forceGuava

plugins {
id(Plugins.BuildPlugins.application)
id(Plugins.BuildPlugins.kotlinAndroid)
Expand Down Expand Up @@ -42,8 +40,6 @@ android {
kotlin { jvmToolchain(11) }
}

configurations { all { forceGuava() } }

dependencies {
androidTestImplementation(Dependencies.AndroidxTest.extJunit)
androidTestImplementation(Dependencies.Espresso.espressoCore)
Expand Down
22 changes: 10 additions & 12 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Dependencies.removeIncompatibleDependencies

plugins {
id(Plugins.BuildPlugins.androidLib)
id(Plugins.BuildPlugins.kotlinAndroid)
Expand All @@ -17,20 +19,10 @@ android {
kotlin { jvmToolchain(11) }
}

configurations {
all {
exclude(module = "xpp3")
exclude(module = "hapi-fhir-caching-caffeine")
exclude(group = "com.github.ben-manes.caffeine", module = "caffeine")

resolutionStrategy { force("com.google.guava:guava:32.1.3-android") }
}
}
configurations { all { removeIncompatibleDependencies() } }

dependencies {
// REVERT to DEPENDENCIES LATER
api("ca.uhn.hapi.fhir:hapi-fhir-structures-r4:6.10.0")
api("ca.uhn.hapi.fhir:hapi-fhir-caching-guava:6.10.0")
api(Dependencies.HapiFhir.structuresR4)

implementation(Dependencies.fhirUcum)

Expand All @@ -39,4 +31,10 @@ dependencies {
testImplementation(Dependencies.junit)
testImplementation(Dependencies.robolectric)
testImplementation(Dependencies.truth)

constraints {
Dependencies.hapiFhirConstraints().forEach { (libName, constraints) ->
api(libName, constraints)
}
}
}
9 changes: 2 additions & 7 deletions contrib/barcode/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Dependencies.forceGuava
import Dependencies.removeIncompatibleDependencies

plugins {
id(Plugins.BuildPlugins.androidLib)
Expand Down Expand Up @@ -46,12 +46,7 @@ android {
kotlin { jvmToolchain(11) }
}

configurations {
all {
exclude(module = "xpp3")
forceGuava()
}
}
configurations { all { removeIncompatibleDependencies() } }

dependencies {
androidTestImplementation(Dependencies.AndroidxTest.core)
Expand Down
15 changes: 9 additions & 6 deletions datacapture/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import Dependencies.forceGuava
import Dependencies.forceHapiVersion
import Dependencies.forceJacksonVersion
import Dependencies.removeIncompatibleDependencies
import java.net.URL

plugins {
Expand Down Expand Up @@ -59,9 +57,7 @@ configurations {
all {
exclude(module = "xpp3")
exclude(group = "net.sf.saxon", module = "Saxon-HE")
forceGuava()
forceHapiVersion()
forceJacksonVersion()
removeIncompatibleDependencies()
}
}

Expand Down Expand Up @@ -108,6 +104,13 @@ dependencies {
testImplementation(Dependencies.mockitoKotlin)
testImplementation(Dependencies.robolectric)
testImplementation(Dependencies.truth)

constraints {
Dependencies.hapiFhirConstraints().forEach { (libName, constraints) ->
api(libName, constraints)
implementation(libName, constraints)
}
vitorpamplona marked this conversation as resolved.
Show resolved Hide resolved
}
}

tasks.dokkaHtml.configure {
Expand Down
4 changes: 0 additions & 4 deletions demo/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import Dependencies.forceGuava

plugins {
id(Plugins.BuildPlugins.application)
id(Plugins.BuildPlugins.kotlinAndroid)
Expand Down Expand Up @@ -40,8 +38,6 @@ android {
kotlin { jvmToolchain(11) }
}

configurations { all { forceGuava() } }

dependencies {
androidTestImplementation(Dependencies.AndroidxTest.extJunit)
androidTestImplementation(Dependencies.Espresso.espressoCore)
Expand Down
14 changes: 0 additions & 14 deletions engine/benchmark/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
import Dependencies.forceGuava
import Dependencies.forceHapiVersion
import Dependencies.forceJacksonVersion
import Dependencies.removeIncompatibleDependencies

plugins {
id(Plugins.BuildPlugins.androidLib)
id(Plugins.BuildPlugins.kotlinAndroid)
Expand Down Expand Up @@ -48,15 +43,6 @@ android {

afterEvaluate { configureFirebaseTestLabForMicroBenchmark() }

configurations {
all {
removeIncompatibleDependencies()
forceGuava()
forceHapiVersion()
forceJacksonVersion()
}
}

dependencies {
androidTestImplementation(Dependencies.Androidx.workRuntimeKtx)
androidTestImplementation(Dependencies.AndroidxTest.benchmarkJunit)
Expand Down
Loading
Loading