2016-06-24 17:48:11 +02:00
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
2018-01-10 23:31:31 +01:00
jcenter ( )
2016-06-24 17:48:11 +02:00
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
2019-05-16 13:57:37 +02:00
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.4'
2019-05-16 15:54:29 +02:00
classpath 'de.undercouch:gradle-download-task:3.4.3'
2016-06-24 17:48:11 +02:00
}
}
2019-05-16 00:56:00 +02:00
apply plugin: 'com.android.application'
2019-04-10 00:33:05 +02:00
apply plugin: 'kotlin-android'
2019-05-16 19:00:44 +02:00
apply plugin: 'kotlin-android-extensions'
2019-04-04 17:15:45 +02:00
apply plugin: 'com.google.gms.google-services'
2019-05-16 00:56:00 +02:00
apply plugin: 'io.fabric'
apply plugin: 'jacoco-android'
2019-05-16 15:54:29 +02:00
apply plugin: 'de.undercouch.download'
2018-01-13 21:34:38 +01:00
2019-05-16 13:57:37 +02:00
jacoco {
toolVersion = "0.8.3"
}
2018-01-13 21:34:38 +01:00
ext {
2019-05-15 23:39:11 +02:00
supportLibraryVersion = "28.0.0"
2018-01-13 21:34:38 +01:00
ormLiteVersion = "4.46"
powermockVersion = "1.7.3"
dexmakerVersion = "1.2"
}
2016-06-24 17:48:11 +02:00
repositories {
maven { url 'https://maven.fabric.io/public' }
2018-03-26 13:25:53 +02:00
jcenter { url "https://jcenter.bintray.com/" }
2019-04-10 00:33:05 +02:00
mavenCentral ( )
2016-06-24 17:48:11 +02:00
}
2016-11-08 19:10:25 +01:00
def generateGitBuild = { - >
2019-07-26 23:21:01 +02:00
StringBuilder stringBuilder = new StringBuilder ( )
2016-11-08 19:10:25 +01:00
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' )
2016-11-08 19:10:25 +01:00
}
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 ( )
2018-05-13 12:32:45 +02:00
stringBuilder . append ( ( new Date ( ) ) . format ( 'yyyy.MM.dd-HH:mm' ) )
2016-11-08 19:10:25 +01:00
return stringBuilder . toString ( )
}
2016-06-04 17:28:05 +02:00
2019-04-16 11:15:40 +02:00
def isMaster = { - >
return ! version . contains ( '-' )
}
def allCommited = { - >
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
}
String commitObject = stdout . toString ( ) . trim ( )
stringBuilder . append ( commitObject )
} 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-25 18:59:10 +02:00
2019-04-16 11:15:40 +02:00
}
2018-04-20 17:27:31 +02:00
tasks . matching { it instanceof Test } . all {
2018-04-11 16:23:35 +02:00
testLogging . events = [ "failed" , "skipped" , "started" ]
2018-03-21 07:41:03 +01:00
testLogging . exceptionFormat = "full"
}
2016-06-04 17:28:05 +02:00
android {
2019-05-15 23:26:07 +02:00
compileSdkVersion 28
2016-06-04 17:28:05 +02:00
defaultConfig {
2019-06-19 16:41:20 +02:00
minSdkVersion 23
2019-05-15 23:26:07 +02:00
targetSdkVersion 28
2017-10-15 02:52:57 +02:00
multiDexEnabled true
2017-06-04 22:37:58 +02:00
versionCode 1500
2020-05-04 17:36:37 +02:00
version "2.6.1.4"
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 ( ) + '"'
2019-05-16 13:57:37 +02:00
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2019-03-22 23:08:13 +01:00
// if you change minSdkVersion to less than 11, you need to change executeTask for wear
2017-09-13 00:35:03 +02:00
ndk {
moduleName "BleCommandUtil"
}
2016-06-04 17:28:05 +02:00
}
2019-04-10 00:33:05 +02:00
kotlinOptions {
jvmTarget = '1.8'
}
2016-10-21 22:16:20 +02:00
lintOptions {
2018-01-26 15:56:07 +01:00
// TODO remove once wear dependency com.google.android.gms:play-services-wearable:7.3.0
// has been upgraded (requiring significant code changes), which currently fails release
// build with a deprecation warning
2019-03-22 23:08:13 +01:00
// abortOnError false
2018-01-26 15:56:07 +01:00
// (disabled entirely to avoid reports on the error, which would still be displayed
// and it's easy to overlook that it's ignored)
checkReleaseBuilds false
2016-10-21 22:16:20 +02:00
disable 'MissingTranslation'
2018-01-11 14:14:53 +01:00
disable 'ExtraTranslation'
2016-10-21 22:16:20 +02:00
}
2016-06-04 17:28:05 +02:00
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile ( 'proguard-android.txt' ) , 'proguard-rules.pro'
}
2018-01-10 23:31:31 +01:00
debug {
2019-03-30 11:11:44 +01:00
testCoverageEnabled ( project . hasProperty ( 'coverage' ) )
2018-01-10 23:31:31 +01:00
}
2019-08-01 21:20:17 +02:00
firebaseDisable {
System . setProperty ( "disableFirebase" , "true" )
}
2016-06-04 17:28:05 +02:00
}
2016-07-15 23:53:14 +02:00
productFlavors {
2017-10-12 18:24:48 +02:00
flavorDimensions "standard"
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"
2017-02-23 20:00:33 +01:00
resValue "string" , "app_name" , "AndroidAPS"
versionName version
2018-06-14 19:39:00 +02:00
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"
2018-06-14 19:39:00 +02:00
]
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"
2018-06-14 19:39:00 +02:00
manifestPlaceholders = [
2019-04-16 11:15:40 +02:00
appIcon : "@mipmap/ic_pumpcontrol" ,
2018-06-14 19:43:16 +02:00
appIconRound: "@null"
2018-06-14 19:39:00 +02:00
]
2016-07-15 23:53:14 +02:00
}
2017-02-23 20:00:33 +01:00
nsclient {
2018-08-07 21:07:43 +02:00
applicationId "info.nightscout.nsclient"
2016-11-26 05:31:23 +01:00
dimension "standard"
2017-02-23 20:00:33 +01:00
resValue "string" , "app_name" , "NSClient"
versionName version + "-nsclient"
2018-06-14 19:39:00 +02:00
manifestPlaceholders = [
2019-04-16 11:15:40 +02:00
appIcon : "@mipmap/ic_yellowowl" ,
2018-06-14 19:43:16 +02:00
appIconRound: "@null"
2018-06-14 19:39:00 +02:00
]
2018-08-07 21:07:43 +02:00
}
nsclient2 {
applicationId "info.nightscout.nsclient2"
dimension "standard"
resValue "string" , "app_name" , "NSClient2"
versionName version + "-nsclient"
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
compileOptions {
sourceCompatibility JavaVersion . VERSION_1_8
targetCompatibility JavaVersion . VERSION_1_8
}
testOptions {
2019-05-18 09:40:06 +02:00
unitTests {
returnDefaultValues = true
includeAndroidResources = true
all {
maxParallelForks = 10
forkEvery = 20
}
}
2018-02-15 21:00:09 +01:00
}
2018-08-01 23:03:01 +02:00
2019-04-16 11:15:40 +02:00
useLibrary "org.apache.http.legacy"
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 {
jcenter ( )
flatDir {
dirs 'libs'
}
2018-09-25 00:00:09 +02:00
maven { url 'https://jitpack.io' }
2017-01-29 13:00:21 +01:00
}
}
2016-06-04 17:28:05 +02:00
dependencies {
2017-10-12 18:01:10 +02:00
wearApp project ( ':wear' )
2017-02-13 01:55:35 +01:00
2018-03-30 21:26:07 +02:00
implementation fileTree ( include: [ '*.jar' ] , dir: 'libs' )
2019-07-13 16:16:43 +02:00
implementation 'com.google.android.gms:play-services-wearable:17.0.0'
2019-12-02 21:36:39 +01:00
implementation 'com.google.firebase:firebase-core:17.2.1'
2019-12-08 19:07:35 +01:00
implementation 'com.google.firebase:firebase-auth:19.2.0'
implementation 'com.google.firebase:firebase-database:19.2.0'
2019-12-02 21:36:39 +01:00
implementation ( 'com.crashlytics.sdk.android:crashlytics:2.10.1@aar' ) {
2016-07-02 23:58:57 +02:00
transitive = true ;
}
2017-01-29 13:00:21 +01:00
2019-09-15 18:56:54 +02:00
implementation 'androidx.appcompat:appcompat:1.1.0'
2019-05-16 13:57:37 +02:00
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
2019-12-02 22:24:12 +01:00
implementation 'androidx.recyclerview:recyclerview:1.1.0'
2019-05-16 13:57:37 +02:00
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.percentlayout:percentlayout:1.0.0'
2019-12-02 22:16:20 +01:00
implementation 'com.wdullaer:materialdatetimepicker:4.2.3'
2019-06-07 12:50:59 +02:00
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
2018-03-30 21:26:07 +02:00
implementation "com.j256.ormlite:ormlite-core:${ormLiteVersion}"
implementation "com.j256.ormlite:ormlite-android:${ormLiteVersion}"
implementation ( "com.github.tony19:logback-android-classic:1.1.1-6" ) {
2018-01-13 21:34:38 +01:00
exclude group: "com.google.android" , module: "android"
2016-12-27 16:21:04 +01:00
}
2019-12-03 19:03:17 +01:00
implementation "org.apache.commons:commons-lang3:3.9"
implementation "org.slf4j:slf4j-api:1.7.29"
2019-04-04 17:15:45 +02:00
// Graphview cannot be upgraded
2018-03-30 21:26:07 +02:00
implementation "com.jjoe64:graphview:4.0.1"
2019-12-02 22:27:09 +01:00
implementation "com.joanzapata.iconify:android-iconify-fontawesome:2.2.2"
2019-05-16 13:57:37 +02:00
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
2018-03-30 21:26:07 +02:00
implementation ( name: "android-edittext-validator-v1.3.4-mod" , ext: "aar" )
2019-03-19 19:08:46 +01:00
implementation 'com.madgag.spongycastle:core:1.58.0.0'
2018-01-24 15:18:31 +01:00
2018-03-30 21:26:07 +02:00
implementation ( "com.google.android:flexbox:0.3.0" ) {
2018-01-13 21:34:38 +01:00
exclude group: "com.android.support"
2017-06-30 17:43:10 +02:00
}
2018-05-02 18:49:40 +02:00
implementation ( "io.socket:socket.io-client:1.0.0" ) {
2017-02-17 13:18:36 +01:00
// excluding org.json which is provided by Android
2018-01-13 21:34:38 +01:00
exclude group: "org.json" , module: "json"
2017-02-17 13:18:36 +01:00
}
2019-12-02 22:50:17 +01:00
implementation "com.google.code.gson:gson:2.8.6"
2019-12-11 23:15:36 +01:00
implementation ( "com.google.guava:guava:24.1-jre" ) {
exclude group: "com.google.code.findbugs" , module: "jsr305"
}
implementation 'com.google.code.findbugs:jsr305:3.0.2'
2018-01-13 21:34:38 +01:00
2019-12-02 22:50:17 +01:00
implementation "net.danlew:android.joda:2.10.3"
2018-01-13 21:34:38 +01:00
2019-12-03 19:03:17 +01:00
implementation 'org.mozilla:rhino:1.7.11'
2018-02-04 07:27:02 +01:00
2019-07-28 20:07:31 +02:00
implementation 'com.github.DavidProdinger:weekdays-selector:1.1.0'
2018-09-25 00:00:09 +02:00
2018-03-30 21:26:07 +02:00
testImplementation "junit:junit:4.12"
2019-12-02 22:50:17 +01:00
testImplementation "org.json:json:20190722"
2019-03-30 11:11:44 +01:00
testImplementation "org.mockito:mockito-core:2.8.47"
2018-03-30 21:26:07 +02:00
testImplementation "org.powermock:powermock-api-mockito2:${powermockVersion}"
testImplementation "org.powermock:powermock-module-junit4-rule-agent:${powermockVersion}"
testImplementation "org.powermock:powermock-module-junit4-rule:${powermockVersion}"
testImplementation "org.powermock:powermock-module-junit4:${powermockVersion}"
2019-12-03 18:56:43 +01:00
testImplementation "joda-time:joda-time:2.10.5"
2019-06-09 17:58:23 +02:00
testImplementation ( "com.google.truth:truth:0.39" ) {
exclude group: "com.google.guava" , module: "guava"
2019-12-11 23:15:36 +01:00
exclude group: "com.google.code.findbugs" , module: "jsr305"
2019-06-09 17:58:23 +02:00
}
2018-03-30 21:26:07 +02:00
testImplementation "org.skyscreamer:jsonassert:1.5.0"
2019-05-04 21:34:46 +02:00
testImplementation "org.hamcrest:hamcrest-all:1.3"
2019-10-01 00:00:22 +02:00
/ *
2019-06-09 17:58:23 +02:00
testImplementation ( "uk.org.lidalia:slf4j-test:1.2.0" ) {
exclude group: "com.google.guava" , module: "guava"
}
2019-10-01 00:00:22 +02:00
* /
2017-01-29 13:00:21 +01:00
2019-04-10 00:33:05 +02:00
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
2019-06-14 18:04:52 +02:00
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
2019-06-01 00:48:37 +02:00
2019-06-02 16:24:51 +02:00
2019-06-03 22:07:38 +02:00
// new for tidepool
2020-05-20 21:49:01 +02:00
implementation 'com.squareup.okhttp3:okhttp:4.5.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.5.0'
implementation "com.squareup.retrofit2:retrofit:2.8.1"
implementation "com.squareup.retrofit2:adapter-rxjava2:2.8.1"
implementation "com.squareup.retrofit2:converter-gson:2.8.1"
2019-06-02 16:24:51 +02:00
2020-01-15 19:56:57 +01:00
// Phone checker
implementation 'com.scottyab:rootbeer-lib:0.0.7'
2019-12-11 23:15:36 +01:00
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha03'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test:rules:1.3.0-alpha03'
androidTestImplementation 'com.google.code.findbugs:jsr305:3.0.2'
2020-02-09 22:16:48 +01:00
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
2020-05-20 21:49:01 +02:00
//WorkManager
implementation 'androidx.work:work-runtime:2.3.4'
implementation 'androidx.work:work-runtime-ktx:2.3.4'
implementation 'androidx.work:work-rxjava2:2.3.4'
implementation 'com.google.androidbrowserhelper:androidbrowserhelper:1.1.0'
implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
2017-07-21 16:49:43 +02:00
}
2018-01-31 21:46:30 +01:00
2019-05-16 15:54:29 +02:00
task downloadZipFile ( type: Download ) {
src 'https://github.com/MilosKozak/danars-support-lib/archive/master.zip'
dest new File ( buildDir , 'danars.zip' )
}
2018-01-31 21:46:30 +01:00
2019-05-16 15:54:29 +02:00
task downloadAndUnzipFile ( dependsOn: downloadZipFile , type: Copy ) {
from zipTree ( downloadZipFile . dest )
def outputDir = file ( "${buildDir}/unpacked/dist" )
2018-01-31 21:46:30 +01:00
into outputDir
2018-02-01 21:11:28 +01:00
}
2018-01-31 21:46:30 +01:00
2019-05-16 15:54:29 +02:00
task copyLibs ( dependsOn: downloadAndUnzipFile , type: Copy ) {
2018-02-01 21:25:37 +01:00
def src = file ( "${buildDir}/unpacked/dist/danars-support-lib-master" )
2018-02-01 21:11:28 +01:00
def target = file ( "src/main/jniLibs/" )
2018-01-31 21:46:30 +01:00
from src
into target
}
task full_clean ( type: Delete ) {
delete file ( "src/main/jniLibs" )
}
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
* /
2018-01-31 21:46:30 +01:00
clean . dependsOn full_clean
2018-04-20 17:27:31 +02:00
preBuild . dependsOn copyLibs
2019-04-16 11:15:40 +02:00
printf ( '--------------\n' )
printf ( 'isMaster: %s\n' , isMaster ( ) . toString ( ) )
printf ( 'allCommited: %s\n' , allCommited ( ) . toString ( ) )
printf ( '--------------\n' )
if ( isMaster ( ) & & ! allCommited ( ) ) {
throw new GradleException ( 'There are uncommitted changes or git system is not available. Clone sources again as described in wiki and do not allow gradle update' )
}