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 { abortOnError false } 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 } } 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() } } // To produce these binaries, in latest AOSP source tree, run // $ m def aospDeps = fileTree(include: [ // For more information about this module: // https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-11.0.0_r3/Android.bp#507 // framework_intermediates/classes-header.jar works for gradle build as well, // but not unit tests, so we use the actual classes (without updatable modules). // // out/target/common/obj/JAVA_LIBRARIES/framework-minus-apex_intermediates/classes.jar 'android.jar', // out/target/common/obj/JAVA_LIBRARIES/core-libart.com.android.art.release_intermediates/classes.jar 'libcore.jar' ], dir: 'libs') // We try to keep the dependencies in sync with what AOSP ships as Seedvault is meant to be built // with the AOSP build system and gradle builds are just for more pleasant development. // If the dependencies below are updated please make sure to update the // prebuilt libraries and Android.bp in the top `libs` folder to reflect that. // You can copy these libraries from ~/.gradle/caches/modules-2 dependencies { compileOnly aospDeps //noinspection GradleDependency implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation 'io.github.novacrypto:BIP39:2019.01.27' implementation 'org.koin:koin-androidx-viewmodel:2.0.1' // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-11.0.0_r3/current/androidx/Android.bp#610 //noinspection GradleDependency implementation 'androidx.core:core-ktx:1.5.0-alpha01' // A newer version gets pulled in with AOSP via core, so we include this here explicitly // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-11.0.0_r3/current/androidx/Android.bp#930 //noinspection GradleDependency implementation 'androidx.fragment:fragment-ktx:1.3.0-alpha07' // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-11.0.0_r3/current/androidx/Android.bp#2412 //noinspection GradleDependency implementation 'androidx.preference:preference:1.1.1' // 1.2.0-alpha01 is not even released // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-11.0.0_r3/current/androidx/Android.bp#1553 //noinspection GradleDependency implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.0-alpha05' // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-11.0.0_r3/current/androidx/Android.bp#1353 //noinspection GradleDependency implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.0-alpha05' // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-11.0.0_r3/current/extras/constraint-layout-x/Android.bp#30 //noinspection GradleDependency implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta7' // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-11.0.0_r3/current/extras/material-design-x/Android.bp#6 //noinspection GradleDependency implementation 'com.google.android.material:material:1.1.0-alpha05' // // Dependencies below do not concern the AOSP build // lintChecks 'com.github.thirdegg:lint-rules:0.0.5-alpha' def junit_version = "5.5.2" // careful, upgrading this can change a Cipher's IV size in tests!? def mockk_version = "1.10.0" testImplementation aospDeps // anything less fails tests run with gradlew testImplementation 'androidx.test.ext:junit:1.1.2' testImplementation('org.robolectric:robolectric:4.3.1') { // 4.4 has issue with non-idle Looper // https://github.com/robolectric/robolectric/issues/5245 exclude group: "com.google.auto.service", module: "auto-service" } testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version" testImplementation "io.mockk:mockk:$mockk_version" testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version" testRuntimeOnly "org.junit.vintage:junit-vintage-engine:$junit_version" androidTestImplementation 'androidx.test:runner:1.3.0' androidTestImplementation 'androidx.test:rules:1.3.0' androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation "io.mockk:mockk-android:$mockk_version" }