blob: 3159d385e070f46aefda6a2b6bb18abd591d20b5 [file] [log] [blame]
import groovy.xml.XmlUtil
plugins {
id "com.android.application"
id "kotlin-android"
id "org.jlleitschuh.gradle.ktlint" version "9.4.0"
}
def gitDescribe = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--always', '--tags', '--dirty=-dirty'
standardOutput = stdout
}
return stdout.toString().trim()
}
android {
compileSdkVersion 30
buildToolsVersion '30.0.2'
defaultConfig {
minSdkVersion 29 // leave at 29 for robolectric tests
targetSdkVersion 30
versionNameSuffix "-$gitDescribe"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments disableAnalytics: 'true'
}
buildTypes {
release {
minifyEnabled false
}
}
lintOptions {
disable "CheckedExceptions"
abortOnError true
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
testOptions {
unitTests.all {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
}
}
unitTests {
includeAndroidResources = true
}
}
sourceSets {
test {
java.srcDirs += "$projectDir/src/sharedTest/java"
}
androidTest {
java.srcDirs += "$projectDir/src/sharedTest/java"
}
}
signingConfigs {
aosp {
// Generated from the AOSP platform key:
// https://android.googlesource.com/platform/build/+/refs/tags/android-11.0.0_r29/target/product/security/platform.pk8
keyAlias "platform"
keyPassword "platform"
storeFile file("platform.jks")
storePassword "platform"
}
}
buildTypes.release.signingConfig = signingConfigs.aosp
buildTypes.debug.signingConfig = signingConfigs.aosp
}
apply from: '../gradle/dependencies.gradle'
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",
]
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
if (JavaVersion.current() >= JavaVersion.VERSION_1_9) {
options.compilerArgs.addAll(['--release', '8'])
}
options.compilerArgs.add('-Xbootclasspath/p:app/libs/android.jar:app/libs/libcore.jar')
}
}
// http://www.31mins.com/android-studio-build-system-application/
preBuild.doLast {
def imlFile = file(project.name + ".iml")
try {
def parsedXml = (new XmlParser()).parse(imlFile)
def jdkNode = parsedXml.component[1].orderEntry.find { it.'@type' == 'jdk' }
parsedXml.component[1].remove(jdkNode)
def apiString = android.compileSdkVersion.substring("android-".length())
def sdkString = "Android API " + apiString + " Platform"
//noinspection GroovyResultOfObjectAllocationIgnored // the note gets inserted
new Node(parsedXml.component[1], 'orderEntry', [
'type' : 'jdk',
'jdkName': sdkString,
'jdkType': 'Android SDK'
])
XmlUtil.serialize(parsedXml, new FileOutputStream(imlFile))
} catch (NullPointerException | FileNotFoundException ex) {
ex.printStackTrace()
}
}
configurations {
all {
resolutionStrategy {
failOnNonReproducibleResolution()
}
}
}