325 lines
11 KiB
Groovy
325 lines
11 KiB
Groovy
buildscript {
|
|
repositories {
|
|
jcenter()
|
|
maven { url "https://plugins.gradle.org/m2/" } // jacoco 0.2
|
|
}
|
|
|
|
dependencies {
|
|
//classpath 'com.dicedmelon.gradle:jacoco-android:0.1.4'
|
|
classpath 'com.hiya:jacoco-android:0.2'
|
|
}
|
|
}
|
|
apply plugin: 'com.android.application'
|
|
apply plugin: 'kotlin-android'
|
|
apply plugin: 'kotlin-android-extensions'
|
|
apply plugin: 'kotlin-kapt'
|
|
apply plugin: 'com.google.gms.google-services'
|
|
//apply plugin: 'jacoco-android'
|
|
apply plugin: 'com.hiya.jacoco-android'
|
|
apply plugin: 'com.google.firebase.crashlytics'
|
|
|
|
jacoco {
|
|
toolVersion = "0.8.3"
|
|
}
|
|
|
|
repositories {
|
|
jcenter { url "https://jcenter.bintray.com/" }
|
|
mavenCentral()
|
|
google()
|
|
}
|
|
|
|
def generateGitBuild = { ->
|
|
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) {
|
|
stringBuilder.append('NoGitSystemAvailable')
|
|
}
|
|
return stringBuilder.toString()
|
|
}
|
|
|
|
def generateGitRemote = { ->
|
|
StringBuilder stringBuilder = new StringBuilder()
|
|
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()
|
|
}
|
|
|
|
def generateDate = { ->
|
|
StringBuilder stringBuilder = new StringBuilder()
|
|
stringBuilder.append((new Date()).format('yyyy.MM.dd-HH:mm'))
|
|
return stringBuilder.toString()
|
|
}
|
|
|
|
def isMaster = { ->
|
|
return !version.contains('-')
|
|
}
|
|
|
|
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()
|
|
|
|
}
|
|
|
|
def allCommited = { ->
|
|
StringBuilder stringBuilder = new StringBuilder()
|
|
try {
|
|
def stdout = new ByteArrayOutputStream()
|
|
exec {
|
|
commandLine 'git', 'status', '-s'
|
|
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())
|
|
} catch (ignored) {
|
|
return false // NoGitSystemAvailable
|
|
}
|
|
return stringBuilder.toString().isEmpty()
|
|
}
|
|
|
|
tasks.matching { it instanceof Test }.all {
|
|
testLogging.events = ["failed", "skipped", "started"]
|
|
testLogging.exceptionFormat = "full"
|
|
}
|
|
|
|
android {
|
|
compileSdkVersion 28
|
|
ndkVersion "21.1.6352462"
|
|
|
|
defaultConfig {
|
|
minSdkVersion 24
|
|
targetSdkVersion 28
|
|
multiDexEnabled true
|
|
versionCode 1500
|
|
version "2.8.0-dev-omnipod"
|
|
buildConfigField "String", "VERSION", '"' + version + '"'
|
|
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
|
|
buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"'
|
|
buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"'
|
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
// if you change minSdkVersion to less than 11, you need to change executeTask for wear
|
|
|
|
ndk {
|
|
moduleName "BleCommandUtil"
|
|
}
|
|
}
|
|
kotlinOptions {
|
|
jvmTarget = '1.8'
|
|
}
|
|
buildFeatures {
|
|
viewBinding true
|
|
}
|
|
lintOptions {
|
|
checkReleaseBuilds false
|
|
disable 'MissingTranslation'
|
|
disable 'ExtraTranslation'
|
|
}
|
|
buildTypes {
|
|
release {
|
|
minifyEnabled false
|
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
}
|
|
debug {
|
|
testCoverageEnabled(project.hasProperty('coverage'))
|
|
}
|
|
firebaseDisable {
|
|
System.setProperty("disableFirebase", "true")
|
|
ext.enableCrashlytics = false
|
|
}
|
|
}
|
|
productFlavors {
|
|
flavorDimensions "standard"
|
|
full {
|
|
applicationId "info.nightscout.androidaps"
|
|
dimension "standard"
|
|
resValue "string", "app_name", "AndroidAPS"
|
|
versionName version
|
|
manifestPlaceholders = [
|
|
appIcon : "@mipmap/ic_launcher",
|
|
appIconRound: "@mipmap/ic_launcher_round"
|
|
]
|
|
}
|
|
pumpcontrol {
|
|
applicationId "info.nightscout.aapspumpcontrol"
|
|
dimension "standard"
|
|
resValue "string", "app_name", "Pumpcontrol"
|
|
versionName version + "-pumpcontrol"
|
|
manifestPlaceholders = [
|
|
appIcon : "@mipmap/ic_pumpcontrol",
|
|
appIconRound: "@null"
|
|
]
|
|
}
|
|
nsclient {
|
|
applicationId "info.nightscout.nsclient"
|
|
dimension "standard"
|
|
resValue "string", "app_name", "NSClient"
|
|
versionName version + "-nsclient"
|
|
manifestPlaceholders = [
|
|
appIcon : "@mipmap/ic_yellowowl",
|
|
appIconRound: "@null"
|
|
]
|
|
}
|
|
nsclient2 {
|
|
applicationId "info.nightscout.nsclient2"
|
|
dimension "standard"
|
|
resValue "string", "app_name", "NSClient2"
|
|
versionName version + "-nsclient"
|
|
manifestPlaceholders = [
|
|
appIcon : "@mipmap/ic_yellowowl",
|
|
appIconRound: "@null"
|
|
]
|
|
}
|
|
}
|
|
compileOptions {
|
|
sourceCompatibility JavaVersion.VERSION_1_8
|
|
targetCompatibility JavaVersion.VERSION_1_8
|
|
}
|
|
|
|
testOptions {
|
|
unitTests {
|
|
returnDefaultValues = true
|
|
includeAndroidResources = true
|
|
|
|
all {
|
|
maxParallelForks = 10
|
|
forkEvery = 20
|
|
}
|
|
}
|
|
}
|
|
|
|
useLibrary "org.apache.http.legacy"
|
|
|
|
configurations.all {
|
|
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
|
|
}
|
|
}
|
|
|
|
allprojects {
|
|
repositories {
|
|
flatDir {
|
|
dirs 'libs'
|
|
}
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
wearApp project(':wear')
|
|
|
|
implementation project(':core')
|
|
implementation project(':dana')
|
|
implementation project(':danars')
|
|
implementation project(':danar')
|
|
implementation project(':rileylink')
|
|
implementation project(':medtronic')
|
|
implementation project(':omnipod')
|
|
|
|
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
|
|
|
testImplementation "junit:junit:$junit_version"
|
|
testImplementation 'org.json:json:20200518'
|
|
testImplementation "org.mockito:mockito-core:${mockitoVersion}"
|
|
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}"
|
|
testImplementation 'joda-time:joda-time:2.10.6'
|
|
testImplementation('com.google.truth:truth:1.0.1') {
|
|
exclude group: "com.google.guava", module: "guava"
|
|
exclude group: "com.google.code.findbugs", module: "jsr305"
|
|
}
|
|
testImplementation "org.skyscreamer:jsonassert:1.5.0"
|
|
testImplementation "org.hamcrest:hamcrest-all:1.3"
|
|
|
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha03'
|
|
androidTestImplementation "androidx.test.ext:junit:$androidx_junit"
|
|
androidTestImplementation "androidx.test:rules:$androidx_rules"
|
|
androidTestImplementation 'com.google.code.findbugs:jsr305:3.0.2'
|
|
|
|
/* Dagger2 - We are going to use dagger.android which includes
|
|
* support for Activity and fragment injection so we need to include
|
|
* the following dependencies */
|
|
|
|
|
|
annotationProcessor "com.google.dagger:dagger-compiler:$dagger_version"
|
|
annotationProcessor "com.google.dagger:dagger-android-processor:$dagger_version"
|
|
kapt "com.google.dagger:dagger-android-processor:$dagger_version"
|
|
|
|
/* Dagger2 - default dependency */
|
|
kapt "com.google.dagger:dagger-compiler:$dagger_version"
|
|
|
|
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
|
|
}
|
|
|
|
/*
|
|
// 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)
|
|
}
|
|
}
|
|
*/
|
|
|
|
printf('--------------\n')
|
|
printf('isMaster: %s\n', isMaster().toString())
|
|
printf('gitAvailable: %s\n', gitAvailable().toString())
|
|
printf('allCommited: %s\n', allCommited().toString())
|
|
printf('--------------\n')
|
|
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')
|
|
}
|
|
if (isMaster() && !allCommited()) {
|
|
throw new GradleException('There are uncommitted changes. Clone sources again as described in wiki and do not allow gradle update')
|
|
}
|
|
|