AndroidAPS/app/build.gradle

285 lines
9.8 KiB
Groovy
Raw Normal View History

plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'kotlin-allopen'
id 'com.hiya.jacoco-android'
id 'kotlinx-serialization'
id 'com.google.gms.google-services'
id 'com.google.firebase.crashlytics'
2022-11-24 10:42:08 +01:00
id 'com.vanniktech.dependency.graph.generator'
}
2018-01-13 21:34:38 +01:00
2022-11-09 13:30:48 +01:00
apply from: "${project.rootDir}/core/core-main/android_dependencies.gradle"
apply from: "${project.rootDir}/core/core-main/jacoco_global.gradle"
2021-02-18 00:04:44 +01:00
2016-06-24 17:48:11 +02:00
repositories {
2019-04-10 00:33:05 +02:00
mavenCentral()
google()
2016-06-24 17:48:11 +02:00
}
2021-08-16 13:47:14 +02:00
allOpen {
// allows mocking for classes w/o directly opening them for release builds
annotation 'info.nightscout.androidaps.annotations.OpenForTesting'
}
def generateGitBuild = { ->
2019-07-26 23:21:01 +02:00
StringBuilder stringBuilder = new StringBuilder()
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--always'
standardOutput = stdout
}
String commitObject = stdout.toString().trim()
stringBuilder.append(commitObject)
} catch (ignored) {
2016-11-08 22:55:08 +01:00
stringBuilder.append('NoGitSystemAvailable')
}
2018-08-27 20:19:30 +02:00
return stringBuilder.toString()
}
2019-04-11 10:16:52 +02:00
def generateGitRemote = { ->
2019-08-21 11:08:23 +02:00
StringBuilder stringBuilder = new StringBuilder()
2019-04-11 10:16:52 +02:00
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'remote', 'get-url', 'origin'
standardOutput = stdout
}
String commitObject = stdout.toString().trim()
stringBuilder.append(commitObject)
} catch (ignored) {
stringBuilder.append('NoGitSystemAvailable')
}
return stringBuilder.toString()
}
2018-08-27 20:19:30 +02:00
def generateDate = { ->
2019-08-21 11:08:23 +02:00
StringBuilder stringBuilder = new StringBuilder()
2022-11-17 18:06:03 +01:00
// showing only date prevents app to rebuild everytime
stringBuilder.append((new Date()).format('yyyy.MM.dd'))
return stringBuilder.toString()
}
2016-06-04 17:28:05 +02:00
2019-04-16 11:15:40 +02:00
def isMaster = { ->
return !version.contains('-')
}
2020-04-24 12:00:31 +02:00
def gitAvailable = { ->
StringBuilder stringBuilder = new StringBuilder()
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', '--version'
standardOutput = stdout
}
String commitObject = stdout.toString().trim()
stringBuilder.append(commitObject)
} catch (ignored) {
return false // NoGitSystemAvailable
}
return !stringBuilder.toString().isEmpty()
}
2021-01-22 11:34:28 +01:00
def allCommitted = { ->
2019-08-21 11:08:23 +02:00
StringBuilder stringBuilder = new StringBuilder()
2019-04-16 11:15:40 +02:00
try {
def stdout = new ByteArrayOutputStream()
exec {
2019-04-25 20:42:34 +02:00
commandLine 'git', 'status', '-s'
2019-04-16 11:15:40 +02:00
standardOutput = stdout
}
// ignore all changes done in .idea/codeStyles
String cleanedList = stdout.toString().replaceAll(/(?m)^\s*(M|A|D|\?\?)\s*.*?\.idea\/codeStyles\/.*?\s*$/, "")
// ignore all files added to project dir but not staged/known to GIT
cleanedList = cleanedList.replaceAll(/(?m)^\s*(\?\?)\s*.*?\s*$/, "")
stringBuilder.append(cleanedList.trim())
2019-04-16 11:15:40 +02:00
} catch (ignored) {
2019-08-21 11:08:23 +02:00
return false // NoGitSystemAvailable
2019-04-16 11:15:40 +02:00
}
2019-04-25 20:42:34 +02:00
return stringBuilder.toString().isEmpty()
2019-04-16 11:15:40 +02:00
}
2016-06-04 17:28:05 +02:00
android {
2022-06-06 10:25:08 +02:00
namespace 'info.nightscout.androidaps'
2020-04-25 21:52:20 +02:00
ndkVersion "21.1.6352462"
2016-06-04 17:28:05 +02:00
defaultConfig {
2017-10-15 02:52:57 +02:00
multiDexEnabled true
2017-06-04 22:37:58 +02:00
versionCode 1500
2022-11-28 22:34:55 +01:00
version "3.1.0.3-dev-d"
2017-02-23 20:00:33 +01:00
buildConfigField "String", "VERSION", '"' + version + '"'
2018-08-27 20:19:30 +02:00
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
2019-04-16 11:15:40 +02:00
buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"'
2018-08-27 20:19:30 +02:00
buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"'
2021-01-22 11:34:28 +01:00
buildConfigField "String", "COMMITTED", '"' + allCommitted() + '"'
2017-09-13 00:35:03 +02:00
2016-06-04 17:28:05 +02:00
}
2021-02-18 22:33:14 +01:00
2021-02-04 12:43:14 +01:00
flavorDimensions "standard"
2016-07-15 23:53:14 +02:00
productFlavors {
2017-02-10 16:53:39 +01:00
full {
2018-08-07 21:07:43 +02:00
applicationId "info.nightscout.androidaps"
2016-11-26 05:31:23 +01:00
dimension "standard"
resValue "string", "app_name", "AAPS"
2017-02-23 20:00:33 +01:00
versionName version
manifestPlaceholders = [
2019-04-16 11:15:40 +02:00
appIcon : "@mipmap/ic_launcher",
2018-06-14 19:43:16 +02:00
appIconRound: "@mipmap/ic_launcher_round"
]
2016-09-05 09:11:30 +02:00
}
2017-02-23 20:00:33 +01:00
pumpcontrol {
2019-03-22 23:08:13 +01:00
applicationId "info.nightscout.aapspumpcontrol"
2016-11-26 05:31:23 +01:00
dimension "standard"
2019-03-22 23:08:13 +01:00
resValue "string", "app_name", "Pumpcontrol"
versionName version + "-pumpcontrol"
manifestPlaceholders = [
2019-04-16 11:15:40 +02:00
appIcon : "@mipmap/ic_pumpcontrol",
2018-06-14 19:43:16 +02:00
appIconRound: "@null"
]
2016-07-15 23:53:14 +02:00
}
aapsclient {
applicationId "info.nightscout.aapsclient"
2016-11-26 05:31:23 +01:00
dimension "standard"
resValue "string", "app_name", "AAPSClient"
versionName version + "-aapsclient"
manifestPlaceholders = [
2019-04-16 11:15:40 +02:00
appIcon : "@mipmap/ic_yellowowl",
2018-06-14 19:43:16 +02:00
appIconRound: "@null"
]
2018-08-07 21:07:43 +02:00
}
aapsclient2 {
applicationId "info.nightscout.aapsclient2"
2018-08-07 21:07:43 +02:00
dimension "standard"
resValue "string", "app_name", "AAPSClient2"
versionName version + "-aapsclient"
2018-08-07 21:07:43 +02:00
manifestPlaceholders = [
2019-04-16 11:15:40 +02:00
appIcon : "@mipmap/ic_yellowowl",
2018-08-07 21:07:43 +02:00
appIconRound: "@null"
]
2016-07-15 23:53:14 +02:00
}
}
2018-02-15 21:00:09 +01:00
2019-04-16 11:15:40 +02:00
useLibrary "org.apache.http.legacy"
2022-03-04 09:46:56 +01:00
dataBinding { //Deleting it causes a binding error
enabled = true
}
2018-04-20 17:27:31 +02:00
}
2016-06-04 17:28:05 +02:00
2017-01-29 13:00:21 +01:00
allprojects {
repositories {
}
}
2016-06-04 17:28:05 +02:00
dependencies {
2022-11-14 23:14:37 +01:00
implementation project(path: ':plugins:aps')
2017-10-12 18:01:10 +02:00
wearApp project(':wear')
2022-10-27 16:41:07 +02:00
// in order to use internet's versions you'd need to enable Jetifier again
2022-10-27 10:16:49 +02:00
// https://github.com/nightscout/graphview.git
2022-10-27 16:41:07 +02:00
// https://github.com/nightscout/iconify.git
2022-11-06 12:28:35 +01:00
implementation project(':app-wear-shared:shared')
implementation project(':app-wear-shared:shared-impl')
2022-11-09 13:30:48 +01:00
implementation project(':core:core-main')
2022-11-22 21:39:19 +01:00
implementation project(':core:graph')
2022-11-25 22:14:46 +01:00
implementation project(':core:graphview')
implementation project(':core:interfaces')
implementation project(':core:libraries')
implementation project(':core:ns-sdk')
2022-11-21 20:26:06 +01:00
implementation project(':core:utils')
2022-11-14 10:58:59 +01:00
implementation project(':core:ui')
2022-11-26 17:28:08 +01:00
implementation project(':core:validators')
2022-10-31 20:20:41 +01:00
implementation project(':ui')
2022-11-14 23:14:37 +01:00
implementation project(':plugins:aps')
2022-11-14 23:21:03 +01:00
implementation project(':plugins:automation')
2022-11-21 20:26:06 +01:00
implementation project(':plugins:configuration')
2022-11-14 19:04:09 +01:00
implementation project(':plugins:main')
2022-11-14 23:21:03 +01:00
implementation project(':plugins:openhumans')
2022-11-21 20:26:06 +01:00
implementation project(':plugins:sensitivity')
2022-11-26 23:45:20 +01:00
implementation project(':plugins:support')
2022-11-28 09:25:19 +01:00
implementation project(':plugins:sync')
2022-10-31 20:20:41 +01:00
implementation project(':implementation')
2022-11-09 23:28:48 +01:00
implementation project(':database:entities')
2022-11-09 16:49:36 +01:00
implementation project(':database:impl')
2022-11-02 11:56:54 +01:00
implementation project(':pump:combo')
implementation project(':pump:combov2')
2022-11-02 11:56:54 +01:00
implementation project(':pump:dana')
implementation project(':pump:danars')
implementation project(':pump:danar')
implementation project(':pump:diaconn')
2022-11-03 14:24:53 +01:00
implementation project(':pump:eopatch')
2021-02-21 18:03:26 +01:00
implementation project(':insight')
2022-11-02 11:56:54 +01:00
implementation project(':pump:medtronic')
implementation project(':pump:pump-common')
implementation project(':pump:pump-core')
2022-11-02 11:56:54 +01:00
implementation project(':pump:rileylink')
implementation project(':pump:omnipod-common')
implementation project(':pump:omnipod-eros')
implementation project(':pump:omnipod-dash')
2020-05-03 21:27:42 +02:00
2018-03-30 21:26:07 +02:00
implementation fileTree(include: ['*.jar'], dir: 'libs')
2020-04-24 12:00:31 +02:00
/* Dagger2 - We are going to use dagger.android which includes
2021-02-18 18:54:01 +01:00
* support for Activity and fragment injection so we need to include
* the following dependencies */
2020-05-04 21:37:03 +02:00
kapt "com.google.dagger:dagger-android-processor:$dagger_version"
kapt "com.google.dagger:dagger-compiler:$dagger_version"
2022-11-09 12:20:03 +01:00
// MainApp
api "com.uber.rxdogtag2:rxdogtag:2.0.1"
2017-07-21 16:49:43 +02:00
}
2022-11-09 13:30:48 +01:00
apply from: "${project.rootDir}/core/core-main/test_dependencies.gradle"
2021-02-18 18:54:01 +01:00
2020-02-25 21:30:44 +01:00
/*
2020-02-11 17:06:30 +01:00
// Run 'adb' shell command to clear application data of main app for 'debug' variant
task clearMainAppData(type: Exec) {
// we have to iterate to find the 'debug' variant to obtain a variant reference
android.applicationVariants.all { variant ->
if (variant.name == "fullDebug") {
def applicationId = [variant.mergedFlavor.applicationId, variant.buildType.applicationIdSuffix].findAll().join()
def clearDataCommand = ['adb', 'shell', 'pm', 'clear', applicationId]
println "Clearing application data of ${variant.name} variant: [${clearDataCommand}]"
def stdout = new ByteArrayOutputStream()
exec {
commandLine clearDataCommand
standardOutput = stdout
}
String result = stdout.toString().trim()
if (!result.startsWith("Success")) {
println result
throw new GradleException(clearDataCommand.join(" "))
}
}
}
}
// Clear Application Data (once) before running instrumentation test
tasks.whenTaskAdded { task ->
// Both of these targets are equivalent today, although in future connectedCheck
// will also include connectedUiAutomatorTest (not implemented yet)
if(task.name == "connectedAndroidTest" || task.name == "connectedCheck"){
task.dependsOn(clearMainAppData)
}
}
2020-02-25 21:30:44 +01:00
*/
2019-04-16 11:15:40 +02:00
printf('--------------\n')
printf('isMaster: %s\n', isMaster().toString())
2020-04-24 12:00:31 +02:00
printf('gitAvailable: %s\n', gitAvailable().toString())
2021-01-22 11:34:28 +01:00
printf('allCommitted: %s\n', allCommitted().toString())
2019-04-16 11:15:40 +02:00
printf('--------------\n')
2020-04-24 12:00:31 +02:00
if (isMaster() && !gitAvailable()) {
throw new 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')
}
2021-01-22 11:34:28 +01:00
if (isMaster() && !allCommitted()) {
2021-05-26 17:04:47 +02:00
throw new GradleException('There are uncommitted changes. Clone sources again as described in wiki and do not allow gradle update')
2019-04-16 11:15:40 +02:00
}