AndroidAPS/app/build.gradle.kts

236 lines
8.2 KiB
Text
Raw Normal View History

2023-09-27 14:52:36 +02:00
import java.io.ByteArrayOutputStream
import java.text.SimpleDateFormat
import java.util.Date
plugins {
id("com.android.application")
id("kotlin-android")
id("kotlin-kapt")
id("com.google.gms.google-services")
id("com.google.firebase.crashlytics")
id("android-app-dependencies")
2023-10-20 18:32:29 +02:00
id("test-app-dependencies")
2023-10-20 10:49:54 +02:00
id("jacoco-app-dependencies")
2023-09-27 14:52:36 +02:00
}
repositories {
mavenCentral()
google()
}
2023-10-11 14:19:56 +02:00
fun generateGitBuild(): String {
val stringBuilder: StringBuilder = StringBuilder()
2023-09-27 14:52:36 +02:00
try {
2023-10-11 14:19:56 +02:00
val stdout = ByteArrayOutputStream()
exec {
commandLine("git", "describe", "--always")
standardOutput = stdout
2023-09-27 14:52:36 +02:00
}
2023-10-11 14:19:56 +02:00
val commitObject = stdout.toString().trim()
stringBuilder.append(commitObject)
2023-09-27 14:52:36 +02:00
} catch (ignored: Exception) {
2023-10-11 14:19:56 +02:00
stringBuilder.append("NoGitSystemAvailable")
2023-09-27 14:52:36 +02:00
}
2023-10-11 14:19:56 +02:00
return stringBuilder.toString()
}
2023-09-27 14:52:36 +02:00
2023-10-11 14:19:56 +02:00
fun generateGitRemote(): String {
val stringBuilder: StringBuilder = StringBuilder()
2023-09-27 14:52:36 +02:00
try {
2023-10-11 14:19:56 +02:00
val stdout = ByteArrayOutputStream()
exec {
commandLine("git", "remote", "get-url", "origin")
standardOutput = stdout
2023-09-27 14:52:36 +02:00
}
2023-10-11 14:19:56 +02:00
val commitObject: String = stdout.toString().trim()
stringBuilder.append(commitObject)
2023-09-27 14:52:36 +02:00
} catch (ignored: Exception) {
2023-10-11 14:19:56 +02:00
stringBuilder.append("NoGitSystemAvailable")
2023-09-27 14:52:36 +02:00
}
2023-10-11 14:19:56 +02:00
return stringBuilder.toString()
}
2023-09-27 14:52:36 +02:00
2023-10-11 14:19:56 +02:00
fun generateDate(): String {
val stringBuilder: StringBuilder = StringBuilder()
2023-09-27 14:52:36 +02:00
// showing only date prevents app to rebuild everytime
2023-10-11 14:19:56 +02:00
stringBuilder.append(SimpleDateFormat("yyyy.MM.dd").format(Date()))
return stringBuilder.toString()
}
2023-09-27 14:52:36 +02:00
fun isMaster(): Boolean = !Versions.appVersion.contains("-")
2023-10-11 14:19:56 +02:00
fun gitAvailable(): Boolean {
val stringBuilder: StringBuilder = StringBuilder()
2023-09-27 14:52:36 +02:00
try {
2023-10-11 14:19:56 +02:00
val stdout = ByteArrayOutputStream()
exec {
commandLine("git", "--version")
standardOutput = stdout
2023-09-27 14:52:36 +02:00
}
2023-10-11 14:19:56 +02:00
val commitObject = stdout.toString().trim()
stringBuilder.append(commitObject)
2023-09-27 14:52:36 +02:00
} catch (ignored: Exception) {
2023-10-11 14:19:56 +02:00
return false // NoGitSystemAvailable
2023-09-27 14:52:36 +02:00
}
2023-10-12 13:58:17 +02:00
return stringBuilder.toString().isNotEmpty()
2023-10-11 14:19:56 +02:00
}
2023-09-27 14:52:36 +02:00
2023-10-11 14:19:56 +02:00
fun allCommitted(): Boolean {
val stringBuilder: StringBuilder = StringBuilder()
2023-09-27 14:52:36 +02:00
try {
2023-10-11 14:19:56 +02:00
val stdout = ByteArrayOutputStream()
exec {
commandLine("git", "status", "-s")
standardOutput = stdout
2023-09-27 14:52:36 +02:00
}
2023-10-11 14:19:56 +02:00
// ignore all changes done in .idea/codeStyles
val cleanedList: String = stdout.toString().replace("/(?m)^\\s*(M|A|D|\\?\\?)\\s*.*?\\.idea\\/codeStyles\\/.*?\\s*\$/", "")
// ignore all files added to project dir but not staged/known to GIT
.replace("/(?m)^\\s*(\\?\\?)\\s*.*?\\s*\$/", "")
stringBuilder.append(cleanedList.trim())
2023-09-27 14:52:36 +02:00
} catch (ignored: Exception) {
2023-10-11 14:19:56 +02:00
return false // NoGitSystemAvailable
2023-09-27 14:52:36 +02:00
}
2023-10-11 14:19:56 +02:00
return stringBuilder.toString().isEmpty()
}
2023-09-27 14:52:36 +02:00
android {
2023-10-11 14:19:56 +02:00
namespace = "app.aaps"
2023-09-27 14:52:36 +02:00
ndkVersion = Versions.ndkVersion
defaultConfig {
2023-10-16 15:20:50 +02:00
minSdk = Versions.minSdk
targetSdk = Versions.targetSdk
2023-10-11 14:19:56 +02:00
buildConfigField("String", "VERSION", "\"$version\"")
buildConfigField("String", "BUILDVERSION", "\"${generateGitBuild()}-${generateDate()}\"")
buildConfigField("String", "REMOTE", "\"${generateGitRemote()}\"")
buildConfigField("String", "HEAD", "\"${generateGitBuild()}\"")
buildConfigField("String", "COMMITTED", "\"${allCommitted()}\"")
2023-09-27 14:52:36 +02:00
}
2023-10-11 14:19:56 +02:00
flavorDimensions.add("standard")
2023-09-27 14:52:36 +02:00
productFlavors {
create("full") {
2023-10-14 22:19:45 +02:00
isDefault = true
2023-09-27 14:52:36 +02:00
applicationId = "info.nightscout.androidaps"
2023-10-11 14:19:56 +02:00
dimension = "standard"
2023-09-27 14:52:36 +02:00
resValue("string", "app_name", "AAPS")
versionName = Versions.appVersion
manifestPlaceholders["appIcon"] = "@mipmap/ic_launcher"
manifestPlaceholders["appIconRound"] = "@mipmap/ic_launcher_round"
}
create("pumpcontrol") {
applicationId = "info.nightscout.aapspumpcontrol"
2023-10-11 14:19:56 +02:00
dimension = "standard"
2023-09-27 14:52:36 +02:00
resValue("string", "app_name", "Pumpcontrol")
versionName = Versions.appVersion + "-pumpcontrol"
manifestPlaceholders["appIcon"] = "@mipmap/ic_pumpcontrol"
manifestPlaceholders["appIconRound"] = "@null"
}
create("aapsclient") {
applicationId = "info.nightscout.aapsclient"
2023-10-11 14:19:56 +02:00
dimension = "standard"
2023-09-27 14:52:36 +02:00
resValue("string", "app_name", "AAPSClient")
versionName = Versions.appVersion + "-aapsclient"
manifestPlaceholders["appIcon"] = "@mipmap/ic_yellowowl"
manifestPlaceholders["appIconRound"] = "@mipmap/ic_yellowowl"
}
create("aapsclient2") {
applicationId = "info.nightscout.aapsclient2"
2023-10-11 14:19:56 +02:00
dimension = "standard"
2023-09-27 14:52:36 +02:00
resValue("string", "app_name", "AAPSClient2")
versionName = Versions.appVersion + "-aapsclient"
manifestPlaceholders["appIcon"] = "@mipmap/ic_blueowl"
manifestPlaceholders["appIconRound"] = "@mipmap/ic_blueowl"
}
}
2023-10-11 14:19:56 +02:00
useLibrary("org.apache.http.legacy")
//Deleting it causes a binding error
2023-10-23 20:50:56 +02:00
buildFeatures {
dataBinding = true
2023-12-01 14:13:19 +01:00
buildConfig = true
2023-10-23 20:50:56 +02:00
}
2023-10-11 14:19:56 +02:00
}
allprojects {
repositories {
2023-09-27 14:52:36 +02:00
}
}
dependencies {
2023-10-11 14:19:56 +02:00
wearApp(project(":wear"))
2023-09-27 14:52:36 +02:00
// in order to use internet"s versions you"d need to enable Jetifier again
// https://github.com/nightscout/graphview.git
// https://github.com/nightscout/iconify.git
2023-10-11 14:19:56 +02:00
implementation(project(":shared:impl"))
2023-09-27 14:52:36 +02:00
implementation(project(":core:main"))
implementation(project(":core:graphview"))
implementation(project(":core:interfaces"))
implementation(project(":core:libraries"))
2023-10-11 14:19:56 +02:00
implementation(project(":core:nssdk"))
2023-09-27 14:52:36 +02:00
implementation(project(":core:utils"))
implementation(project(":core:ui"))
implementation(project(":core:validators"))
implementation(project(":ui"))
implementation(project(":plugins:aps"))
implementation(project(":plugins:automation"))
implementation(project(":plugins:configuration"))
implementation(project(":plugins:constraints"))
implementation(project(":plugins:insulin"))
implementation(project(":plugins:main"))
implementation(project(":plugins:sensitivity"))
implementation(project(":plugins:smoothing"))
implementation(project(":plugins:source"))
implementation(project(":plugins:sync"))
implementation(project(":implementation"))
implementation(project(":database:entities"))
implementation(project(":database:impl"))
implementation(project(":pump:combo"))
implementation(project(":pump:combov2"))
implementation(project(":pump:dana"))
implementation(project(":pump:danars"))
implementation(project(":pump:danar"))
implementation(project(":pump:diaconn"))
implementation(project(":pump:eopatch"))
implementation(project(":pump:medtrum"))
implementation(project(":insight"))
implementation(project(":pump:medtronic"))
implementation(project(":pump:pump-common"))
implementation(project(":pump:omnipod-common"))
implementation(project(":pump:omnipod-eros"))
implementation(project(":pump:omnipod-dash"))
implementation(project(":pump:rileylink"))
implementation(project(":pump:virtual"))
implementation(project(":workflow"))
2023-10-11 14:19:56 +02:00
testImplementation(project(":shared:tests"))
2023-09-27 14:52:36 +02:00
/* Dagger2 - We are going to use dagger.android which includes
* support for Activity and fragment injection so we need to include
* the following dependencies */
2023-10-11 14:19:56 +02:00
kapt(Libs.Dagger.androidProcessor)
2023-09-27 14:52:36 +02:00
kapt(Libs.Dagger.compiler)
// MainApp
api(Libs.Rx.rxDogTag)
}
2023-10-11 14:19:56 +02:00
println("-------------------")
2023-09-27 14:52:36 +02:00
println("isMaster: ${isMaster()}")
println("gitAvailable: ${gitAvailable()}")
println("allCommitted: ${allCommitted()}")
2023-10-11 14:19:56 +02:00
println("-------------------")
2023-09-27 14:52:36 +02:00
if (isMaster() && !gitAvailable()) {
throw GradleException("GIT system is not available. On Windows try to run Android Studio as an Administrator. Check if GIT is installed and Studio have permissions to use it")
}
if (isMaster() && !allCommitted()) {
throw GradleException("There are uncommitted changes. Clone sources again as described in wiki and do not allow gradle update")
}
2023-10-11 14:19:56 +02:00