d2ed3a10f0
Otherwise gradle pulls in newer versions of some libraries that require a newer Kotlin version at runtime and then make the app crash. This also moves the dependency declarations into a dedicated file.
111 lines
3.2 KiB
Groovy
111 lines
3.2 KiB
Groovy
import groovy.xml.XmlUtil
|
|
|
|
apply plugin: 'com.android.application'
|
|
apply plugin: 'kotlin-android'
|
|
|
|
android {
|
|
|
|
compileSdkVersion 30
|
|
buildToolsVersion '30.0.2' // adapt in .travis.yaml if changed here
|
|
|
|
defaultConfig {
|
|
minSdkVersion 29 // leave at 29 for robolectric tests
|
|
targetSdkVersion 30
|
|
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"
|
|
}
|
|
}
|
|
|
|
// 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
|
|
buildTypes.debug.signingConfig = signingConfigs.release
|
|
}
|
|
}
|
|
|
|
apply from: '../gradle/dependencies.gradle'
|
|
|
|
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 sdkString = "Android API " + android.compileSdkVersion.substring("android-".length()) + " 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()
|
|
}
|
|
}
|
|
}
|