blob: 738f6cab00efab4654dfc12577f45c56656f885a [file] [log] [blame]
Steve Soltyse8720182018-11-07 22:04:37 -05001import groovy.xml.XmlUtil
2
3apply plugin: 'com.android.application'
Torsten Grote3d5911d2019-07-03 19:44:37 +02004apply plugin: 'kotlin-android'
Steve Soltyse8720182018-11-07 22:04:37 -05005
6android {
Torsten Grote2434fe32019-06-03 12:23:09 -03007
Torsten Grote415b5722020-09-09 16:46:30 -03008 compileSdkVersion 30
9 buildToolsVersion '30.0.2' // adapt in .travis.yaml if changed here
Torsten Grote2434fe32019-06-03 12:23:09 -030010
11 defaultConfig {
Torsten Grote45ac8882020-09-09 18:12:02 -030012 minSdkVersion 29 // leave at 29 for robolectric tests
Torsten Grote415b5722020-09-09 16:46:30 -030013 targetSdkVersion 30
Torsten Grotee955e022019-08-06 08:16:37 +020014 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Torsten Groteb9cac5e2019-12-18 13:14:25 -030015 testInstrumentationRunnerArguments disableAnalytics: 'true'
Torsten Grote2434fe32019-06-03 12:23:09 -030016 }
Steve Soltyse8720182018-11-07 22:04:37 -050017
18 buildTypes {
19 release {
20 minifyEnabled false
Steve Soltyse8720182018-11-07 22:04:37 -050021 }
22 }
23
24 lintOptions {
Torsten Grote57f40422020-09-14 17:47:01 -030025 disable "CheckedExceptions"
26 abortOnError true
Steve Soltyse8720182018-11-07 22:04:37 -050027 }
28 compileOptions {
29 targetCompatibility 1.8
30 sourceCompatibility 1.8
31 }
Torsten Grotefcf17fe2020-01-18 15:39:53 -030032 kotlinOptions {
33 jvmTarget = JavaVersion.VERSION_1_8.toString()
34 }
Torsten Grote2ce625a2019-07-09 19:22:24 +020035 testOptions {
36 unitTests.all {
37 useJUnitPlatform()
38 testLogging {
39 events "passed", "skipped", "failed"
40 }
41 }
Torsten Groteb9cac5e2019-12-18 13:14:25 -030042 unitTests {
43 includeAndroidResources = true
44 }
Torsten Grote2ce625a2019-07-09 19:22:24 +020045 }
Torsten Groted1f59862019-06-03 15:51:58 -030046
Torsten Grote74aa62a2019-08-20 13:04:09 +020047 sourceSets {
48 test {
49 java.srcDirs += "$projectDir/src/sharedTest/java"
50 }
51 androidTest {
52 java.srcDirs += "$projectDir/src/sharedTest/java"
53 }
54 }
55
Torsten Groted1f59862019-06-03 15:51:58 -030056 // 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 Grote2ce625a2019-07-09 19:22:24 +020071 buildTypes.debug.signingConfig = signingConfigs.release
Torsten Groted1f59862019-06-03 15:51:58 -030072 }
Steve Soltyse8720182018-11-07 22:04:37 -050073}
74
75gradle.projectsEvaluated {
76 tasks.withType(JavaCompile) {
Torsten Grotee6598922019-09-19 11:19:44 -030077 if (JavaVersion.current() >= JavaVersion.VERSION_1_9) {
78 options.compilerArgs.addAll(['--release', '8'])
79 }
Steve Soltyse8720182018-11-07 22:04:37 -050080 options.compilerArgs.add('-Xbootclasspath/p:app/libs/android.jar:app/libs/libcore.jar')
81 }
82}
83
Torsten Groteb17a55a2019-06-11 10:25:36 -030084// http://www.31mins.com/android-studio-build-system-application/
Torsten Grote2434fe32019-06-03 12:23:09 -030085preBuild.doLast {
86 def imlFile = file(project.name + ".iml")
Steve Soltyse8720182018-11-07 22:04:37 -050087
Torsten Grote2434fe32019-06-03 12:23:09 -030088 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 Soltyse8720182018-11-07 22:04:37 -050092
Torsten Grote2434fe32019-06-03 12:23:09 -030093 def sdkString = "Android API " + android.compileSdkVersion.substring("android-".length()) + " Platform"
Torsten Grotee6598922019-09-19 11:19:44 -030094 //noinspection GroovyResultOfObjectAllocationIgnored // the note gets inserted
Torsten Grote2434fe32019-06-03 12:23:09 -030095 new Node(parsedXml.component[1], 'orderEntry', ['type': 'jdk', 'jdkName': sdkString, 'jdkType': 'Android SDK'])
96 XmlUtil.serialize(parsedXml, new FileOutputStream(imlFile))
Steve Soltyse8720182018-11-07 22:04:37 -050097
Torsten Grote2434fe32019-06-03 12:23:09 -030098 } catch (NullPointerException | FileNotFoundException ex) {
99 ex.printStackTrace()
Steve Soltyse8720182018-11-07 22:04:37 -0500100 }
101}
102
Torsten Grote2ce625a2019-07-09 19:22:24 +0200103// To produce these binaries, in latest AOSP source tree, run
Torsten Groteca309df2020-09-09 16:45:51 -0300104// $ m
Torsten Grote2ce625a2019-07-09 19:22:24 +0200105def aospDeps = fileTree(include: [
Torsten Groteca309df2020-09-09 16:45:51 -0300106 // 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 Grote2ce625a2019-07-09 19:22:24 +0200112 'android.jar',
Torsten Groteca309df2020-09-09 16:45:51 -0300113 // out/target/common/obj/JAVA_LIBRARIES/core-libart.com.android.art.release_intermediates/classes.jar
Torsten Grote2ce625a2019-07-09 19:22:24 +0200114 'libcore.jar'
115], dir: 'libs')
116
Steve Soltyse8720182018-11-07 22:04:37 -0500117dependencies {
Torsten Grote2ce625a2019-07-09 19:22:24 +0200118 compileOnly aospDeps
Steve Soltyse8720182018-11-07 22:04:37 -0500119
Torsten Groteceac5fc2020-09-11 15:42:10 -0300120 /**
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 Grote6cde6be2020-09-11 14:32:45 -0300128 //noinspection GradleDependency
Torsten Grotee6598922019-09-19 11:19:44 -0300129 implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
Torsten Grote3d5911d2019-07-03 19:44:37 +0200130
Torsten Grote6cde6be2020-09-11 14:32:45 -0300131 // 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 Bestaseb15fa92020-07-10 03:33:24 +0300150 implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.0-alpha05'
Torsten Grote6cde6be2020-09-11 14:32:45 -0300151
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 Grotecfcf7b32020-09-11 15:16:38 -0300160
Torsten Groteceac5fc2020-09-11 15:42:10 -0300161 /**
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 Grote2ce625a2019-07-09 19:22:24 +0200184
Torsten Grote7bda3eb2020-08-26 14:17:50 -0300185 lintChecks 'com.github.thirdegg:lint-rules:0.0.5-alpha'
Torsten Grote2ce625a2019-07-09 19:22:24 +0200186
Torsten Grotef7df78d2020-08-07 16:57:27 -0300187 def junit_version = "5.5.2" // careful, upgrading this can change a Cipher's IV size in tests!?
Torsten Grotef68095a2020-08-06 12:33:36 -0300188 def mockk_version = "1.10.0"
Torsten Groteceac5fc2020-09-11 15:42:10 -0300189 testImplementation aospDeps // anything less than 'implementation' fails tests run with gradlew
Torsten Grote45ac8882020-09-09 18:12:02 -0300190 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 Groteb594d302020-09-14 14:04:40 -0300192 // https://github.com/robolectric/robolectric/issues/5245
193 exclude group: "com.google.auto.service", module: "auto-service"
194 }
Torsten Groteb9cac5e2019-12-18 13:14:25 -0300195 testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
Torsten Grotef68095a2020-08-06 12:33:36 -0300196 testImplementation "io.mockk:mockk:$mockk_version"
Torsten Groteb9cac5e2019-12-18 13:14:25 -0300197 testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"
198 testRuntimeOnly "org.junit.vintage:junit-vintage-engine:$junit_version"
Torsten Grotee955e022019-08-06 08:16:37 +0200199
Torsten Grote45ac8882020-09-09 18:12:02 -0300200 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 Grotef68095a2020-08-06 12:33:36 -0300203 androidTestImplementation "io.mockk:mockk-android:$mockk_version"
Steve Soltyse8720182018-11-07 22:04:37 -0500204}