Steve Soltys | e872018 | 2018-11-07 22:04:37 -0500 | [diff] [blame] | 1 | import groovy.xml.XmlUtil |
| 2 | |
| 3 | apply plugin: 'com.android.application' |
Torsten Grote | 3d5911d | 2019-07-03 19:44:37 +0200 | [diff] [blame] | 4 | apply plugin: 'kotlin-android' |
Steve Soltys | e872018 | 2018-11-07 22:04:37 -0500 | [diff] [blame] | 5 | |
| 6 | android { |
Torsten Grote | 2434fe3 | 2019-06-03 12:23:09 -0300 | [diff] [blame] | 7 | |
Torsten Grote | 415b572 | 2020-09-09 16:46:30 -0300 | [diff] [blame] | 8 | compileSdkVersion 30 |
| 9 | buildToolsVersion '30.0.2' // adapt in .travis.yaml if changed here |
Torsten Grote | 2434fe3 | 2019-06-03 12:23:09 -0300 | [diff] [blame] | 10 | |
| 11 | defaultConfig { |
Torsten Grote | 45ac888 | 2020-09-09 18:12:02 -0300 | [diff] [blame] | 12 | minSdkVersion 29 // leave at 29 for robolectric tests |
Torsten Grote | 415b572 | 2020-09-09 16:46:30 -0300 | [diff] [blame] | 13 | targetSdkVersion 30 |
Torsten Grote | e955e02 | 2019-08-06 08:16:37 +0200 | [diff] [blame] | 14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" |
Torsten Grote | b9cac5e | 2019-12-18 13:14:25 -0300 | [diff] [blame] | 15 | testInstrumentationRunnerArguments disableAnalytics: 'true' |
Torsten Grote | 2434fe3 | 2019-06-03 12:23:09 -0300 | [diff] [blame] | 16 | } |
Steve Soltys | e872018 | 2018-11-07 22:04:37 -0500 | [diff] [blame] | 17 | |
| 18 | buildTypes { |
| 19 | release { |
| 20 | minifyEnabled false |
Steve Soltys | e872018 | 2018-11-07 22:04:37 -0500 | [diff] [blame] | 21 | } |
| 22 | } |
| 23 | |
| 24 | lintOptions { |
Torsten Grote | 57f4042 | 2020-09-14 17:47:01 -0300 | [diff] [blame^] | 25 | disable "CheckedExceptions" |
| 26 | abortOnError true |
Steve Soltys | e872018 | 2018-11-07 22:04:37 -0500 | [diff] [blame] | 27 | } |
| 28 | compileOptions { |
| 29 | targetCompatibility 1.8 |
| 30 | sourceCompatibility 1.8 |
| 31 | } |
Torsten Grote | fcf17fe | 2020-01-18 15:39:53 -0300 | [diff] [blame] | 32 | kotlinOptions { |
| 33 | jvmTarget = JavaVersion.VERSION_1_8.toString() |
| 34 | } |
Torsten Grote | 2ce625a | 2019-07-09 19:22:24 +0200 | [diff] [blame] | 35 | testOptions { |
| 36 | unitTests.all { |
| 37 | useJUnitPlatform() |
| 38 | testLogging { |
| 39 | events "passed", "skipped", "failed" |
| 40 | } |
| 41 | } |
Torsten Grote | b9cac5e | 2019-12-18 13:14:25 -0300 | [diff] [blame] | 42 | unitTests { |
| 43 | includeAndroidResources = true |
| 44 | } |
Torsten Grote | 2ce625a | 2019-07-09 19:22:24 +0200 | [diff] [blame] | 45 | } |
Torsten Grote | d1f5986 | 2019-06-03 15:51:58 -0300 | [diff] [blame] | 46 | |
Torsten Grote | 74aa62a | 2019-08-20 13:04:09 +0200 | [diff] [blame] | 47 | sourceSets { |
| 48 | test { |
| 49 | java.srcDirs += "$projectDir/src/sharedTest/java" |
| 50 | } |
| 51 | androidTest { |
| 52 | java.srcDirs += "$projectDir/src/sharedTest/java" |
| 53 | } |
| 54 | } |
| 55 | |
Torsten Grote | d1f5986 | 2019-06-03 15:51:58 -0300 | [diff] [blame] | 56 | // optional signingConfigs |
| 57 | def keystorePropertiesFile = rootProject.file("keystore.properties") |
| 58 | if (keystorePropertiesFile.exists()) { |
| 59 | def keystoreProperties = new Properties() |
| 60 | keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) |
| 61 | |
| 62 | signingConfigs { |
| 63 | release { |
| 64 | keyAlias keystoreProperties['keyAlias'] |
| 65 | keyPassword keystoreProperties['keyPassword'] |
| 66 | storeFile file(keystoreProperties['storeFile']) |
| 67 | storePassword keystoreProperties['storePassword'] |
| 68 | } |
| 69 | } |
| 70 | buildTypes.release.signingConfig = signingConfigs.release |
Torsten Grote | 2ce625a | 2019-07-09 19:22:24 +0200 | [diff] [blame] | 71 | buildTypes.debug.signingConfig = signingConfigs.release |
Torsten Grote | d1f5986 | 2019-06-03 15:51:58 -0300 | [diff] [blame] | 72 | } |
Steve Soltys | e872018 | 2018-11-07 22:04:37 -0500 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | gradle.projectsEvaluated { |
| 76 | tasks.withType(JavaCompile) { |
Torsten Grote | e659892 | 2019-09-19 11:19:44 -0300 | [diff] [blame] | 77 | if (JavaVersion.current() >= JavaVersion.VERSION_1_9) { |
| 78 | options.compilerArgs.addAll(['--release', '8']) |
| 79 | } |
Steve Soltys | e872018 | 2018-11-07 22:04:37 -0500 | [diff] [blame] | 80 | options.compilerArgs.add('-Xbootclasspath/p:app/libs/android.jar:app/libs/libcore.jar') |
| 81 | } |
| 82 | } |
| 83 | |
Torsten Grote | b17a55a | 2019-06-11 10:25:36 -0300 | [diff] [blame] | 84 | // http://www.31mins.com/android-studio-build-system-application/ |
Torsten Grote | 2434fe3 | 2019-06-03 12:23:09 -0300 | [diff] [blame] | 85 | preBuild.doLast { |
| 86 | def imlFile = file(project.name + ".iml") |
Steve Soltys | e872018 | 2018-11-07 22:04:37 -0500 | [diff] [blame] | 87 | |
Torsten Grote | 2434fe3 | 2019-06-03 12:23:09 -0300 | [diff] [blame] | 88 | try { |
| 89 | def parsedXml = (new XmlParser()).parse(imlFile) |
| 90 | def jdkNode = parsedXml.component[1].orderEntry.find { it.'@type' == 'jdk' } |
| 91 | parsedXml.component[1].remove(jdkNode) |
Steve Soltys | e872018 | 2018-11-07 22:04:37 -0500 | [diff] [blame] | 92 | |
Torsten Grote | 2434fe3 | 2019-06-03 12:23:09 -0300 | [diff] [blame] | 93 | def sdkString = "Android API " + android.compileSdkVersion.substring("android-".length()) + " Platform" |
Torsten Grote | e659892 | 2019-09-19 11:19:44 -0300 | [diff] [blame] | 94 | //noinspection GroovyResultOfObjectAllocationIgnored // the note gets inserted |
Torsten Grote | 2434fe3 | 2019-06-03 12:23:09 -0300 | [diff] [blame] | 95 | new Node(parsedXml.component[1], 'orderEntry', ['type': 'jdk', 'jdkName': sdkString, 'jdkType': 'Android SDK']) |
| 96 | XmlUtil.serialize(parsedXml, new FileOutputStream(imlFile)) |
Steve Soltys | e872018 | 2018-11-07 22:04:37 -0500 | [diff] [blame] | 97 | |
Torsten Grote | 2434fe3 | 2019-06-03 12:23:09 -0300 | [diff] [blame] | 98 | } catch (NullPointerException | FileNotFoundException ex) { |
| 99 | ex.printStackTrace() |
Steve Soltys | e872018 | 2018-11-07 22:04:37 -0500 | [diff] [blame] | 100 | } |
| 101 | } |
| 102 | |
Torsten Grote | 2ce625a | 2019-07-09 19:22:24 +0200 | [diff] [blame] | 103 | // To produce these binaries, in latest AOSP source tree, run |
Torsten Grote | ca309df | 2020-09-09 16:45:51 -0300 | [diff] [blame] | 104 | // $ m |
Torsten Grote | 2ce625a | 2019-07-09 19:22:24 +0200 | [diff] [blame] | 105 | def aospDeps = fileTree(include: [ |
Torsten Grote | ca309df | 2020-09-09 16:45:51 -0300 | [diff] [blame] | 106 | // For more information about this module: |
| 107 | // https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-11.0.0_r3/Android.bp#507 |
| 108 | // framework_intermediates/classes-header.jar works for gradle build as well, |
| 109 | // but not unit tests, so we use the actual classes (without updatable modules). |
| 110 | // |
| 111 | // out/target/common/obj/JAVA_LIBRARIES/framework-minus-apex_intermediates/classes.jar |
Torsten Grote | 2ce625a | 2019-07-09 19:22:24 +0200 | [diff] [blame] | 112 | 'android.jar', |
Torsten Grote | ca309df | 2020-09-09 16:45:51 -0300 | [diff] [blame] | 113 | // out/target/common/obj/JAVA_LIBRARIES/core-libart.com.android.art.release_intermediates/classes.jar |
Torsten Grote | 2ce625a | 2019-07-09 19:22:24 +0200 | [diff] [blame] | 114 | 'libcore.jar' |
| 115 | ], dir: 'libs') |
| 116 | |
Steve Soltys | e872018 | 2018-11-07 22:04:37 -0500 | [diff] [blame] | 117 | dependencies { |
Torsten Grote | 2ce625a | 2019-07-09 19:22:24 +0200 | [diff] [blame] | 118 | compileOnly aospDeps |
Steve Soltys | e872018 | 2018-11-07 22:04:37 -0500 | [diff] [blame] | 119 | |
Torsten Grote | ceac5fc | 2020-09-11 15:42:10 -0300 | [diff] [blame] | 120 | /** |
| 121 | * Dependencies in AOSP |
| 122 | * |
| 123 | * We try to keep the dependencies in sync with what AOSP ships as Seedvault is meant to be built |
| 124 | * with the AOSP build system and gradle builds are just for more pleasant development. |
| 125 | * Using the AOSP versions in gradle builds allows us to spot issues early on. |
| 126 | */ |
| 127 | |
Torsten Grote | 6cde6be | 2020-09-11 14:32:45 -0300 | [diff] [blame] | 128 | //noinspection GradleDependency |
Torsten Grote | e659892 | 2019-09-19 11:19:44 -0300 | [diff] [blame] | 129 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" |
Torsten Grote | 3d5911d | 2019-07-03 19:44:37 +0200 | [diff] [blame] | 130 | |
Torsten Grote | 6cde6be | 2020-09-11 14:32:45 -0300 | [diff] [blame] | 131 | // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-11.0.0_r3/current/androidx/Android.bp#610 |
| 132 | //noinspection GradleDependency |
| 133 | implementation 'androidx.core:core-ktx:1.5.0-alpha01' |
| 134 | |
| 135 | // A newer version gets pulled in with AOSP via core, so we include this here explicitly |
| 136 | // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-11.0.0_r3/current/androidx/Android.bp#930 |
| 137 | //noinspection GradleDependency |
| 138 | implementation 'androidx.fragment:fragment-ktx:1.3.0-alpha07' |
| 139 | |
| 140 | // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-11.0.0_r3/current/androidx/Android.bp#2412 |
| 141 | //noinspection GradleDependency |
| 142 | implementation 'androidx.preference:preference:1.1.1' // 1.2.0-alpha01 is not even released |
| 143 | |
| 144 | // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-11.0.0_r3/current/androidx/Android.bp#1553 |
| 145 | //noinspection GradleDependency |
| 146 | implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.0-alpha05' |
| 147 | |
| 148 | // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-11.0.0_r3/current/androidx/Android.bp#1353 |
| 149 | //noinspection GradleDependency |
Michael Bestas | eb15fa9 | 2020-07-10 03:33:24 +0300 | [diff] [blame] | 150 | implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.0-alpha05' |
Torsten Grote | 6cde6be | 2020-09-11 14:32:45 -0300 | [diff] [blame] | 151 | |
| 152 | // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-11.0.0_r3/current/extras/constraint-layout-x/Android.bp#30 |
| 153 | //noinspection GradleDependency |
| 154 | implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta7' |
| 155 | |
| 156 | // https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-11.0.0_r3/current/extras/material-design-x/Android.bp#6 |
| 157 | //noinspection GradleDependency |
| 158 | implementation 'com.google.android.material:material:1.1.0-alpha05' |
| 159 | |
Torsten Grote | cfcf7b3 | 2020-09-11 15:16:38 -0300 | [diff] [blame] | 160 | |
Torsten Grote | ceac5fc | 2020-09-11 15:42:10 -0300 | [diff] [blame] | 161 | /** |
| 162 | * External Dependencies |
| 163 | * |
| 164 | * If the dependencies below are updated, |
| 165 | * please make sure to update the prebuilt libraries and the Android.bp files |
| 166 | * in the top-level `libs` folder to reflect that. |
| 167 | * You can copy these libraries from ~/.gradle/caches/modules-2 |
| 168 | */ |
| 169 | |
| 170 | def koin_version = '2.1.1' |
| 171 | implementation("org.koin:koin-android:$koin_version") { |
| 172 | exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib' |
| 173 | } |
| 174 | implementation("org.koin:koin-androidx-viewmodel:$koin_version") { |
| 175 | exclude group: 'org.koin', module: 'koin-androidx-scope' |
| 176 | exclude group: 'androidx.lifecycle' |
| 177 | } |
| 178 | |
| 179 | implementation 'io.github.novacrypto:BIP39:2019.01.27' |
| 180 | |
| 181 | /** |
| 182 | * Test Dependencies (do not concern the AOSP build) |
| 183 | */ |
Torsten Grote | 2ce625a | 2019-07-09 19:22:24 +0200 | [diff] [blame] | 184 | |
Torsten Grote | 7bda3eb | 2020-08-26 14:17:50 -0300 | [diff] [blame] | 185 | lintChecks 'com.github.thirdegg:lint-rules:0.0.5-alpha' |
Torsten Grote | 2ce625a | 2019-07-09 19:22:24 +0200 | [diff] [blame] | 186 | |
Torsten Grote | f7df78d | 2020-08-07 16:57:27 -0300 | [diff] [blame] | 187 | def junit_version = "5.5.2" // careful, upgrading this can change a Cipher's IV size in tests!? |
Torsten Grote | f68095a | 2020-08-06 12:33:36 -0300 | [diff] [blame] | 188 | def mockk_version = "1.10.0" |
Torsten Grote | ceac5fc | 2020-09-11 15:42:10 -0300 | [diff] [blame] | 189 | testImplementation aospDeps // anything less than 'implementation' fails tests run with gradlew |
Torsten Grote | 45ac888 | 2020-09-09 18:12:02 -0300 | [diff] [blame] | 190 | testImplementation 'androidx.test.ext:junit:1.1.2' |
| 191 | testImplementation('org.robolectric:robolectric:4.3.1') { // 4.4 has issue with non-idle Looper |
Torsten Grote | b594d30 | 2020-09-14 14:04:40 -0300 | [diff] [blame] | 192 | // https://github.com/robolectric/robolectric/issues/5245 |
| 193 | exclude group: "com.google.auto.service", module: "auto-service" |
| 194 | } |
Torsten Grote | b9cac5e | 2019-12-18 13:14:25 -0300 | [diff] [blame] | 195 | testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version" |
Torsten Grote | f68095a | 2020-08-06 12:33:36 -0300 | [diff] [blame] | 196 | testImplementation "io.mockk:mockk:$mockk_version" |
Torsten Grote | b9cac5e | 2019-12-18 13:14:25 -0300 | [diff] [blame] | 197 | testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version" |
| 198 | testRuntimeOnly "org.junit.vintage:junit-vintage-engine:$junit_version" |
Torsten Grote | e955e02 | 2019-08-06 08:16:37 +0200 | [diff] [blame] | 199 | |
Torsten Grote | 45ac888 | 2020-09-09 18:12:02 -0300 | [diff] [blame] | 200 | androidTestImplementation 'androidx.test:runner:1.3.0' |
| 201 | androidTestImplementation 'androidx.test:rules:1.3.0' |
| 202 | androidTestImplementation 'androidx.test.ext:junit:1.1.2' |
Torsten Grote | f68095a | 2020-08-06 12:33:36 -0300 | [diff] [blame] | 203 | androidTestImplementation "io.mockk:mockk-android:$mockk_version" |
Steve Soltys | e872018 | 2018-11-07 22:04:37 -0500 | [diff] [blame] | 204 | } |