2018-11-08 04:04:37 +01:00
|
|
|
import groovy.xml.XmlUtil
|
|
|
|
|
2020-09-25 15:23:32 +02:00
|
|
|
plugins {
|
|
|
|
id "com.android.application"
|
|
|
|
id "kotlin-android"
|
|
|
|
id "org.jlleitschuh.gradle.ktlint" version "9.4.0"
|
|
|
|
}
|
2018-11-08 04:04:37 +01:00
|
|
|
|
2020-10-23 15:25:44 +02:00
|
|
|
def gitDescribe = { ->
|
|
|
|
def stdout = new ByteArrayOutputStream()
|
|
|
|
exec {
|
|
|
|
commandLine 'git', 'describe', '--always', '--tags', '--dirty=-dirty'
|
|
|
|
standardOutput = stdout
|
|
|
|
}
|
|
|
|
return stdout.toString().trim()
|
|
|
|
}
|
|
|
|
|
2018-11-08 04:04:37 +01:00
|
|
|
android {
|
2019-06-03 17:23:09 +02:00
|
|
|
|
2020-09-09 21:46:30 +02:00
|
|
|
compileSdkVersion 30
|
|
|
|
buildToolsVersion '30.0.2' // adapt in .travis.yaml if changed here
|
2019-06-03 17:23:09 +02:00
|
|
|
|
|
|
|
defaultConfig {
|
2020-09-09 23:12:02 +02:00
|
|
|
minSdkVersion 29 // leave at 29 for robolectric tests
|
2020-09-09 21:46:30 +02:00
|
|
|
targetSdkVersion 30
|
2020-10-23 15:25:44 +02:00
|
|
|
versionNameSuffix "-$gitDescribe"
|
2019-08-06 08:16:37 +02:00
|
|
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
2019-12-18 17:14:25 +01:00
|
|
|
testInstrumentationRunnerArguments disableAnalytics: 'true'
|
2019-06-03 17:23:09 +02:00
|
|
|
}
|
2018-11-08 04:04:37 +01:00
|
|
|
|
|
|
|
buildTypes {
|
|
|
|
release {
|
|
|
|
minifyEnabled false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lintOptions {
|
2020-09-14 22:47:01 +02:00
|
|
|
disable "CheckedExceptions"
|
|
|
|
abortOnError true
|
2018-11-08 04:04:37 +01:00
|
|
|
}
|
|
|
|
compileOptions {
|
|
|
|
targetCompatibility 1.8
|
|
|
|
sourceCompatibility 1.8
|
|
|
|
}
|
2020-01-18 19:39:53 +01:00
|
|
|
kotlinOptions {
|
|
|
|
jvmTarget = JavaVersion.VERSION_1_8.toString()
|
|
|
|
}
|
2019-07-09 19:22:24 +02:00
|
|
|
testOptions {
|
|
|
|
unitTests.all {
|
|
|
|
useJUnitPlatform()
|
|
|
|
testLogging {
|
|
|
|
events "passed", "skipped", "failed"
|
|
|
|
}
|
|
|
|
}
|
2019-12-18 17:14:25 +01:00
|
|
|
unitTests {
|
|
|
|
includeAndroidResources = true
|
|
|
|
}
|
2019-07-09 19:22:24 +02:00
|
|
|
}
|
2019-06-03 20:51:58 +02:00
|
|
|
|
2019-08-20 13:04:09 +02:00
|
|
|
sourceSets {
|
|
|
|
test {
|
|
|
|
java.srcDirs += "$projectDir/src/sharedTest/java"
|
|
|
|
}
|
|
|
|
androidTest {
|
|
|
|
java.srcDirs += "$projectDir/src/sharedTest/java"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-03 20:51:58 +02:00
|
|
|
// optional signingConfigs
|
|
|
|
def keystorePropertiesFile = rootProject.file("keystore.properties")
|
|
|
|
if (keystorePropertiesFile.exists()) {
|
|
|
|
def keystoreProperties = new Properties()
|
|
|
|
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
|
|
|
|
|
|
|
signingConfigs {
|
|
|
|
release {
|
|
|
|
keyAlias keystoreProperties['keyAlias']
|
|
|
|
keyPassword keystoreProperties['keyPassword']
|
|
|
|
storeFile file(keystoreProperties['storeFile'])
|
|
|
|
storePassword keystoreProperties['storePassword']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
buildTypes.release.signingConfig = signingConfigs.release
|
2019-07-09 19:22:24 +02:00
|
|
|
buildTypes.debug.signingConfig = signingConfigs.release
|
2019-06-03 20:51:58 +02:00
|
|
|
}
|
2018-11-08 04:04:37 +01:00
|
|
|
}
|
|
|
|
|
2020-09-15 22:16:22 +02:00
|
|
|
apply from: '../gradle/dependencies.gradle'
|
|
|
|
|
2020-09-25 15:23:32 +02:00
|
|
|
ktlint {
|
|
|
|
version = "0.36.0" // https://github.com/pinterest/ktlint/issues/764
|
|
|
|
android = true
|
|
|
|
enableExperimentalRules = false
|
|
|
|
verbose = true
|
|
|
|
disabledRules = [
|
|
|
|
"import-ordering",
|
|
|
|
"no-blank-line-before-rbrace",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2018-11-08 04:04:37 +01:00
|
|
|
gradle.projectsEvaluated {
|
|
|
|
tasks.withType(JavaCompile) {
|
2019-09-19 16:19:44 +02:00
|
|
|
if (JavaVersion.current() >= JavaVersion.VERSION_1_9) {
|
|
|
|
options.compilerArgs.addAll(['--release', '8'])
|
|
|
|
}
|
2018-11-08 04:04:37 +01:00
|
|
|
options.compilerArgs.add('-Xbootclasspath/p:app/libs/android.jar:app/libs/libcore.jar')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-11 15:25:36 +02:00
|
|
|
// http://www.31mins.com/android-studio-build-system-application/
|
2019-06-03 17:23:09 +02:00
|
|
|
preBuild.doLast {
|
|
|
|
def imlFile = file(project.name + ".iml")
|
2018-11-08 04:04:37 +01:00
|
|
|
|
2019-06-03 17:23:09 +02:00
|
|
|
try {
|
|
|
|
def parsedXml = (new XmlParser()).parse(imlFile)
|
|
|
|
def jdkNode = parsedXml.component[1].orderEntry.find { it.'@type' == 'jdk' }
|
|
|
|
parsedXml.component[1].remove(jdkNode)
|
2018-11-08 04:04:37 +01:00
|
|
|
|
2020-09-25 15:23:32 +02:00
|
|
|
def apiString = android.compileSdkVersion.substring("android-".length())
|
|
|
|
def sdkString = "Android API " + apiString + " Platform"
|
2019-09-19 16:19:44 +02:00
|
|
|
//noinspection GroovyResultOfObjectAllocationIgnored // the note gets inserted
|
2020-09-25 15:23:32 +02:00
|
|
|
new Node(parsedXml.component[1], 'orderEntry', [
|
|
|
|
'type' : 'jdk',
|
|
|
|
'jdkName': sdkString,
|
|
|
|
'jdkType': 'Android SDK'
|
|
|
|
])
|
2019-06-03 17:23:09 +02:00
|
|
|
XmlUtil.serialize(parsedXml, new FileOutputStream(imlFile))
|
2018-11-08 04:04:37 +01:00
|
|
|
|
2019-06-03 17:23:09 +02:00
|
|
|
} catch (NullPointerException | FileNotFoundException ex) {
|
|
|
|
ex.printStackTrace()
|
2018-11-08 04:04:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-15 22:16:22 +02:00
|
|
|
configurations {
|
|
|
|
all {
|
|
|
|
resolutionStrategy {
|
|
|
|
failOnNonReproducibleResolution()
|
|
|
|
}
|
2020-09-14 19:04:40 +02:00
|
|
|
}
|
2018-11-08 04:04:37 +01:00
|
|
|
}
|