Skip to content

Commit

Permalink
externalize configuration files
Browse files Browse the repository at this point in the history
  • Loading branch information
icrc-fdeniger committed Jul 23, 2024
1 parent c5fcb2c commit 9402081
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
24 changes: 21 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import com.android.build.api.dsl.VariantDimension
import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties

plugins {
Expand All @@ -16,6 +17,10 @@ android {
manifestPlaceholders["appAuthRedirectScheme"] = applicationId!!
buildFeatures.buildConfig = true
versionCode = 1
setResValue("fhir_base_url", "FHIR_BASE_URL",this)
setResValue("openmrs_rest_url", "OPENMRS_REST_URL",this)
setResValue("check_server_url", "CHECK_SERVER_URL",this)

}
buildTypes {
debug {
Expand All @@ -35,12 +40,12 @@ android {
}
kotlin { jvmToolchain(11) }
packaging { resources.excludes.addAll(listOf("META-INF/ASL-2.0.txt", "META-INF/LGPL-3.0.txt")) }
repositories{
repositories {
maven {
url = uri("https://maven.pkg.github.com/google/android-fhir")
credentials {
username = gradleLocalProperties(rootDir).getProperty("gpr.user") ?: System.getenv("USERNAME")
password = gradleLocalProperties(rootDir).getProperty("gpr.key") ?: System.getenv("TOKEN")
username = localPropertyOrEnv("gpr.user", "USERNAME")
password = localPropertyOrEnv("gpr.key", "TOKEN")
}
}
}
Expand Down Expand Up @@ -72,3 +77,16 @@ dependencies {
implementation("com.google.android.fhir:engine:1.0.0-SNAPSHOT")
implementation("com.google.android.fhir:data-capture:1.1.0-SNAPSHOT")
}

fun localPropertyOrEnv(propertyName: String, envName: String): String? =
gradleLocalProperties(rootDir).getProperty(propertyName) ?: System.getenv(envName)

fun setResValue(propertyName: String, envName: String,variants: VariantDimension) {
val prop=localPropertyOrEnv(propertyName,envName)
if(prop!=null){
variants.resValue("string", propertyName, prop)
}
}



6 changes: 6 additions & 0 deletions local.properties.default
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
sdk.dir=<path to Android SDK>
gpr.user=<Your GitHub Account>
gpr.key=<A GitHub token>


# Default values:
#fhir_base_url=http://127.0.0.1:8080/openmrs/ws/fhir2/R4/
#openmrs_rest_url=http://127.0.0.1:8080/openmrs/ws/rest/v1/
#check_server_url=http://127.0.0.1:8080/openmrs/ws/rest/v1/session

0 comments on commit 9402081

Please sign in to comment.