Switch to Kotlin build scripts + version catalog

This commit is contained in:
Steve Soltys 2023-10-13 01:42:24 -04:00
parent ee3a923034
commit b917293bbc
16 changed files with 698 additions and 692 deletions

View file

@ -1,243 +0,0 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'org.jlleitschuh.gradle.ktlint'
}
def gitDescribe = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--always', '--tags', '--dirty=-dirty'
standardOutput = stdout
}
return stdout.toString().trim()
}
android {
namespace 'com.stevesoltys.seedvault'
compileSdk rootProject.ext.compileSdk
defaultConfig {
minSdk rootProject.ext.minSdk
targetSdk rootProject.ext.targetSdk
versionNameSuffix "-$gitDescribe"
testInstrumentationRunner "com.stevesoltys.seedvault.KoinInstrumentationTestRunner"
testInstrumentationRunnerArguments disableAnalytics: 'true'
if (project.hasProperty('instrumented_test_size')) {
final testSize = project.getProperty('instrumented_test_size')
println("Instrumented test size: $testSize")
testInstrumentationRunnerArguments size: testSize
}
}
buildTypes {
release {
minifyEnabled false
}
}
lint {
disable "DialogFragmentCallbacksDetector",
"InvalidFragmentVersionForActivityResult",
"CheckedExceptions"
abortOnError true
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
languageVersion = "1.8"
}
packagingOptions {
exclude("META-INF/LICENSE.md")
exclude("META-INF/LICENSE-notice.md")
}
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("development/platform.jks")
storePassword "platform"
}
}
buildTypes.release.signingConfig = signingConfigs.aosp
buildTypes.debug.signingConfig = signingConfigs.aosp
}
dependencies {
compileOnly rootProject.ext.aosp_libs
/**
* Dependencies in AOSP
*
* 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.
* Using the AOSP versions in gradle builds allows us to spot issues early on.
*/
implementation rootProject.ext.kotlin_libs.std
// These coroutine libraries get upgraded otherwise to versions incompatible with kotlin version
implementation rootProject.ext.kotlin_libs.coroutines
implementation rootProject.ext.std_libs.androidx_core
// A newer version gets pulled in with AOSP via core, so we include fragment here explicitly
implementation rootProject.ext.std_libs.androidx_fragment
implementation rootProject.ext.std_libs.androidx_activity
implementation rootProject.ext.std_libs.androidx_preference
implementation rootProject.ext.std_libs.androidx_lifecycle_viewmodel_ktx
implementation rootProject.ext.std_libs.androidx_lifecycle_livedata_ktx
implementation rootProject.ext.std_libs.androidx_constraintlayout
implementation rootProject.ext.std_libs.androidx_documentfile
implementation rootProject.ext.std_libs.com_google_android_material
implementation rootProject.ext.storage_libs.com_google_crypto_tink_android
/**
* Storage Dependencies
*/
implementation project(':storage:lib')
/**
* External Dependencies
*
* If the dependencies below are updated,
* please make sure to update the prebuilt libraries and the Android.bp files
* in the top-level `libs` folder to reflect that.
* You can copy these libraries from ~/.gradle/caches/modules-2/files-2.1
*/
// later versions than 2.1.1 require newer kotlin version
// implementation "io.insert-koin:koin-core-jvm:3.2.0"
// implementation "io.insert-koin:koin-android:3.2.0"
implementation fileTree(include: ['*.jar'], dir: "${rootProject.rootDir}/libs/koin-android")
implementation fileTree(include: ['*.aar'], dir: "${rootProject.rootDir}/libs/koin-android")
// implementation "cash.z.ecc.android:kotlin-bip39:1.0.6"
implementation fileTree(include: ['kotlin-bip39-jvm-1.0.6.jar'], dir: "${rootProject.rootDir}/libs")
/**
* Test Dependencies (do not concern the AOSP build)
*/
lintChecks rootProject.ext.lint_libs.exceptions
// anything less than 'implementation' fails tests run with gradlew
testImplementation rootProject.ext.aosp_libs
testImplementation 'androidx.test.ext:junit:1.1.5'
testImplementation('org.robolectric:robolectric:4.10.3')
testImplementation 'org.hamcrest:hamcrest:2.2'
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit5_version"
testImplementation "org.junit.jupiter:junit-jupiter-params:$junit5_version"
testImplementation "io.mockk:mockk:$mockk_version"
testImplementation 'org.bitcoinj:bitcoinj-core:0.16.2'
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit5_version"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:$junit5_version"
androidTestImplementation rootProject.ext.aosp_libs
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test:rules:1.4.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation "io.mockk:mockk-android:1.13.8"
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
}
apply from: "${rootProject.rootDir}/gradle/ktlint.gradle"
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs.add('-Xbootclasspath/p:app/libs/android.jar:app/libs/libcore.jar')
}
}
tasks.withType(Test).configureEach {
testLogging {
showExceptions true
showCauses true
showStackTraces true
exceptionFormat = 'full'
}
}
configurations {
all {
resolutionStrategy {
failOnNonReproducibleResolution()
}
}
}
tasks.register('provisionEmulator', Exec) {
group("emulator")
dependsOn(tasks.assembleRelease)
doFirst {
commandLine "${project.projectDir}/development/scripts/provision_emulator.sh",
"seedvault",
"system-images;android-34;default;x86_64"
environment "ANDROID_HOME", android.sdkDirectory.absolutePath
environment "JAVA_HOME", System.properties['java.home']
}
}
tasks.register('startEmulator', Exec) {
group("emulator")
doFirst {
commandLine "${project.projectDir}/development/scripts/start_emulator.sh", "seedvault"
environment "ANDROID_HOME", android.sdkDirectory.absolutePath
environment "JAVA_HOME", System.properties['java.home']
}
}
tasks.register('installEmulatorRelease', Exec) {
group("emulator")
dependsOn(tasks.assembleRelease)
doFirst {
commandLine "${project.projectDir}/development/scripts/install_app.sh"
environment "ANDROID_HOME", android.sdkDirectory.absolutePath
environment "JAVA_HOME", System.properties['java.home']
}
}
tasks.register('clearEmulatorAppData', Exec) {
group("emulator")
doFirst {
commandLine "${project.projectDir}/development/scripts/clear_app_data.sh"
environment "ANDROID_HOME", android.sdkDirectory.absolutePath
environment "JAVA_HOME", System.properties['java.home']
}
}

256
app/build.gradle.kts Normal file
View file

@ -0,0 +1,256 @@
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import java.io.ByteArrayOutputStream
plugins {
id("com.android.application")
kotlin("android")
}
val gitDescribe = {
val stdout = ByteArrayOutputStream()
exec {
commandLine("git", "describe", "--always", "--tags", "--dirty=-dirty")
standardOutput = stdout
}
stdout.toString().trim()
}
android {
namespace = "com.stevesoltys.seedvault"
compileSdk = libs.versions.compileSdk.get().toInt()
defaultConfig {
minSdk = libs.versions.minSdk.get().toInt()
targetSdk = libs.versions.targetSdk.get().toInt()
versionNameSuffix = "-${gitDescribe()}"
testInstrumentationRunner = "com.stevesoltys.seedvault.KoinInstrumentationTestRunner"
testInstrumentationRunnerArguments(mapOf("disableAnalytics" to "true"))
if (project.hasProperty("instrumented_test_size")) {
val testSize = project.property("instrumented_test_size").toString()
println("Instrumented test size: $testSize")
testInstrumentationRunnerArguments(mapOf("size" to testSize))
}
}
signingConfigs {
create("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("development/platform.jks")
storePassword = "platform"
}
}
buildTypes {
all {
isMinifyEnabled = false
}
getByName("release").signingConfig = signingConfigs.getByName("aosp")
getByName("debug").signingConfig = signingConfigs.getByName("aosp")
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
languageVersion = "1.8"
}
packagingOptions {
exclude("META-INF/LICENSE.md")
exclude("META-INF/LICENSE-notice.md")
}
testOptions.unitTests {
all { it.useJUnitPlatform() }
isIncludeAndroidResources = true
}
sourceSets {
named("test") {
java.srcDirs("$projectDir/src/sharedTest/java")
}
named("androidTest") {
java.srcDirs("$projectDir/src/sharedTest/java")
}
}
lint {
abortOnError = true
disable.clear()
disable += setOf(
"DialogFragmentCallbacksDetector",
"InvalidFragmentVersionForActivityResult",
"CheckedExceptions"
)
}
}
dependencies {
val aospLibs = fileTree("$projectDir/libs") {
// 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
include("android.jar")
// out/target/common/obj/JAVA_LIBRARIES/core-libart.com.android.art_intermediates/classes.jar
include("libcore.jar")
}
compileOnly(aospLibs)
/**
* Dependencies in AOSP
*
* 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.
* Using the AOSP versions in gradle builds allows us to spot issues early on.
*/
implementation(libs.bundles.kotlin)
// These coroutine libraries get upgraded otherwise to versions incompatible with kotlin version
implementation(libs.bundles.coroutines)
implementation(libs.androidx.core)
// A newer version gets pulled in with AOSP via core, so we include fragment here explicitly
implementation(libs.androidx.fragment)
implementation(libs.androidx.activity)
implementation(libs.androidx.preference)
implementation(libs.androidx.lifecycle.viewmodel.ktx)
implementation(libs.androidx.lifecycle.livedata.ktx)
implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.documentfile)
implementation(libs.google.material)
implementation(libs.google.tink.android)
/**
* Storage Dependencies
*/
implementation(project(":storage:lib"))
/**
* External Dependencies
*
* If the dependencies below are updated,
* please make sure to update the prebuilt libraries and the Android.bp files
* in the top-level `libs` folder to reflect that.
* You can copy these libraries from ~/.gradle/caches/modules-2/files-2.1
*/
// later versions than 2.1.1 require newer kotlin version
implementation(fileTree("${rootProject.rootDir}/libs/koin-android").include("*.jar"))
implementation(fileTree("${rootProject.rootDir}/libs/koin-android").include("*.aar"))
implementation(fileTree("${rootProject.rootDir}/libs").include("kotlin-bip39-jvm-1.0.6.jar"))
/**
* Test Dependencies (do not concern the AOSP build)
*/
lintChecks(libs.thirdegg.lint.rules)
// anything less than 'implementation' fails tests run with gradlew
testImplementation(aospLibs)
testImplementation("androidx.test.ext:junit:1.1.5")
testImplementation("org.robolectric:robolectric:4.10.3")
testImplementation("org.hamcrest:hamcrest:2.2")
testImplementation("org.junit.jupiter:junit-jupiter-api:${libs.versions.junit5.get()}")
testImplementation("org.junit.jupiter:junit-jupiter-params:${libs.versions.junit5.get()}")
testImplementation("io.mockk:mockk:${libs.versions.mockk.get()}")
testImplementation("org.bitcoinj:bitcoinj-core:0.16.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${libs.versions.junit5.get()}")
testRuntimeOnly("org.junit.vintage:junit-vintage-engine:${libs.versions.junit5.get()}")
androidTestImplementation(aospLibs)
androidTestImplementation("androidx.test:runner:1.4.0")
androidTestImplementation("androidx.test:rules:1.4.0")
androidTestImplementation("androidx.test.ext:junit:1.1.3")
androidTestImplementation("io.mockk:mockk-android:1.13.8")
androidTestImplementation("androidx.test.uiautomator:uiautomator:2.2.0")
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile::class) {
options.compilerArgs.add("-Xbootclasspath/p:app/libs/android.jar:app/libs/libcore.jar")
}
}
tasks.withType<Test>().configureEach {
testLogging {
events("passed", "skipped", "failed")
showExceptions = true
showCauses = true
showStackTraces = true
exceptionFormat = TestExceptionFormat.FULL
}
}
configurations.all {
resolutionStrategy {
failOnNonReproducibleResolution()
}
}
tasks.register<Exec>("provisionEmulator") {
group = "emulator"
dependsOn(tasks.getByName("assembleRelease"))
doFirst {
commandLine(
"${project.projectDir}/development/scripts/provision_emulator.sh",
"seedvault",
"system-images;android-34;default;x86_64"
)
environment("ANDROID_HOME", android.sdkDirectory.absolutePath)
environment("JAVA_HOME", System.getProperty("java.home"))
}
}
tasks.register<Exec>("startEmulator") {
group = "emulator"
doFirst {
commandLine("${project.projectDir}/development/scripts/start_emulator.sh", "seedvault")
environment("ANDROID_HOME", android.sdkDirectory.absolutePath)
environment("JAVA_HOME", System.getProperty("java.home"))
}
}
tasks.register<Exec>("installEmulatorRelease") {
group = "emulator"
dependsOn(tasks.getByName("assembleRelease"))
doFirst {
commandLine("${project.projectDir}/development/scripts/install_app.sh")
environment("ANDROID_HOME", android.sdkDirectory.absolutePath)
environment("JAVA_HOME", System.getProperty("java.home"))
}
}
tasks.register<Exec>("clearEmulatorAppData") {
group = "emulator"
doFirst {
commandLine("${project.projectDir}/development/scripts/clear_app_data.sh")
environment("ANDROID_HOME", android.sdkDirectory.absolutePath)
environment("JAVA_HOME", System.getProperty("java.home"))
}
}

View file

@ -1,33 +0,0 @@
buildscript {
// 1.3.61 Android 11
// 1.4.30 Android 12
// 1.6.10 Android 13
// 1.7.20 Android 13 (QPR2)
// 1.8.10 Android 14
// Check:
// https://android.googlesource.com/platform/external/kotlinc/+/refs/tags/android-14.0.0_r1/build.txt
ext.aosp_kotlin_version = '1.8.10' // 1.8.10-release-430 in AOSP
ext.kotlin_version = '1.8.10'
}
plugins {
id 'com.android.application' version '8.1.2' apply false
id 'com.android.library' version '8.1.2' apply false
id 'com.google.protobuf' version '0.9.4' apply false
id 'org.jetbrains.kotlin.android' version "$kotlin_version" apply false
id 'org.jetbrains.kotlin.kapt' version "$kotlin_version" apply false
id 'org.jetbrains.dokka' version "$kotlin_version" apply false
id 'org.jlleitschuh.gradle.ktlint' version '11.5.0' apply false
}
ext {
compileSdk = 34
minSdk = 33
targetSdk = 34
}
apply from: 'gradle/dependencies.gradle'
task clean(type: Delete) {
delete rootProject.buildDir
}

44
build.gradle.kts Normal file
View file

@ -0,0 +1,44 @@
import org.jlleitschuh.gradle.ktlint.KtlintExtension
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:${plugins.versions.androidGradle}")
classpath("com.google.protobuf:protobuf-gradle-plugin:${plugins.versions.protobuf}")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${plugins.versions.kotlin}")
classpath("org.jetbrains.dokka:dokka-gradle-plugin:${plugins.versions.kotlin}")
classpath("org.jlleitschuh.gradle:ktlint-gradle:${plugins.versions.ktlint}")
}
}
plugins {
id("com.android.application") version plugins.versions.androidGradle apply false
id("com.android.library") version plugins.versions.androidGradle apply false
id("com.google.protobuf") version plugins.versions.protobuf apply false
id("org.jetbrains.kotlin.android") version plugins.versions.kotlin apply false
id("org.jetbrains.kotlin.kapt") version plugins.versions.kotlin apply false
id("org.jetbrains.dokka") version plugins.versions.kotlin apply false
id("org.jlleitschuh.gradle.ktlint") version plugins.versions.ktlint apply false
}
tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}
subprojects {
if (path == ":app" || path == ":storage:lib") {
apply(plugin = "org.jlleitschuh.gradle.ktlint")
configure<KtlintExtension> {
version.set("0.42.1")
android.set(true)
enableExperimentalRules.set(false)
verbose.set(true)
disabledRules.set(listOf("import-ordering", "no-blank-line-before-rbrace", "indent"))
}
}
}

82
build.libs.toml Normal file
View file

@ -0,0 +1,82 @@
[metadata]
[versions]
# Android SDK versions
compileSdk = "34"
minSdk = "33"
targetSdk = "34"
# Test versions
junit4 = "4.13.2"
junit5 = "5.10.0" # careful, upgrading this can change a Cipher's IV size in tests!?
mockk = "1.13.4" # newer versions require kotlin > 1.8.10
espresso = "3.4.0"
# Dependency versions below this are AOSP versions.
# We use "strictly" to enforce the version cannot be overriden by transitive dependencies.
# We need to enforce that the versions we use are the same as AOSP to ensure compatibility.
# Kotlin versions
aosp-kotlin = { strictly = "1.8.10" }
# Lint versions
lint-rules = { strictly = "0.1.0" }
# Google versions
# https://android.googlesource.com/platform/external/protobuf/+/refs/tags/android-14.0.0_r1/java/pom.xml#7
protobuf = { strictly = "3.21.7" }
# https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-14.0.0_r1/current/extras/material-design-x/Android.bp#15
material = { strictly = "1.7.0-alpha03" }
# careful with upgrading tink, so old backups continue to be decryptable
# https://github.com/google/tink/releases
tink = { strictly = "1.10.0" }
# Coroutines versions
# https://android.googlesource.com/platform/external/kotlinx.coroutines/+/refs/tags/android-14.0.0_r1/CHANGES.md
coroutines = { strictly = "1.6.4" }
# AndroidX versions
# https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-14.0.0_r1/current/androidx/Android.bp
room = { strictly = "2.4.0-alpha05" }
androidx-core = { strictly = "1.9.0-alpha05" }
androidx-fragment = { strictly = "1.5.0-alpha03" }
androidx-activity = { strictly = "1.5.0-alpha03" }
androidx-preference = { strictly = "1.2.0-alpha01" }
androidx-lifecycle-viewmodel-ktx = { strictly = "2.5.0-alpha03" }
androidx-lifecycle-livedata-ktx = { strictly = "2.5.0-alpha03" }
androidx-constraintlayout = { strictly = "2.2.0-alpha05" }
androidx-documentfile = { strictly = "1.1.0-alpha01" }
[libraries]
# Kotlin standard dependencies
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "aosp-kotlin" }
kotlin-stdlib-jdk8 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "aosp-kotlin" }
kotlin-stdlib-common = { module = "org.jetbrains.kotlin:kotlin-stdlib-common", version.ref = "aosp-kotlin" }
# Lint dependencies
thirdegg-lint-rules = { module = "com.github.thirdegg:lint-rules", version.ref = "lint-rules" }
# Google dependencies
google-tink-android = { module = "com.google.crypto.tink:tink-android", version.ref = "tink" }
google-protobuf-javalite = { module = 'com.google.protobuf:protobuf-javalite', version.ref = 'protobuf' }
google-material = { module = 'com.google.android.material:material', version.ref = 'material' }
# Coroutines dependencies
kotlinx-coroutines-core-jvm = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm", version.ref = "coroutines" }
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" }
# AndroidX dependencies
androidx-core = { module = "androidx.core:core", version.ref = "androidx-core" }
androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "androidx-core" }
androidx-fragment = { module = "androidx.fragment:fragment-ktx", version.ref = "androidx-fragment" }
androidx-activity = { module = "androidx.activity:activity-ktx", version.ref = "androidx-activity" }
androidx-preference = { module = "androidx.preference:preference", version.ref = "androidx-preference" }
androidx-lifecycle-viewmodel-ktx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "androidx-lifecycle-viewmodel-ktx" }
androidx-lifecycle-livedata-ktx = { module = "androidx.lifecycle:lifecycle-livedata-ktx", version.ref = "androidx-lifecycle-livedata-ktx" }
androidx-constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "androidx-constraintlayout" }
androidx-documentfile = { module = "androidx.documentfile:documentfile", version.ref = "androidx-documentfile" }
androidx-room-runtime = { module = "androidx.room:room-runtime", version.ref = "room" }
[bundles]
kotlin = ["kotlin-stdlib", "kotlin-stdlib-jdk8", "kotlin-stdlib-common"]
coroutines = ["kotlinx-coroutines-core-jvm", "kotlinx-coroutines-android"]

5
build.plugins.toml Normal file
View file

@ -0,0 +1,5 @@
[versions]
kotlin = "1.8.10"
androidGradle = "8.1.2"
protobuf = "0.9.4"
ktlint = "11.5.0"

View file

@ -1,78 +0,0 @@
/*
* SPDX-FileCopyrightText: 2020 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
namespace 'org.calyxos.backup.contacts'
compileSdk rootProject.ext.compileSdk
defaultConfig {
applicationId "org.calyxos.backup.contacts"
minSdk rootProject.ext.minSdk
targetSdk rootProject.ext.targetSdk
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments disableAnalytics: 'true'
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}
packagingOptions {
exclude("META-INF/LICENSE.md")
exclude("META-INF/LICENSE-notice.md")
}
testOptions {
unitTests.returnDefaultValues = true
}
// optional signingConfigs
// On userdebug builds, you can use the testkey here to update the system app
def keystorePropertiesFile = project.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
}
}
def aospDeps = fileTree(include: [
// out/target/common/obj/JAVA_LIBRARIES/com.android.vcard_intermediates/classes.jar
'com.android.vcard.jar'
], dir: 'libs')
dependencies {
implementation aospDeps
testImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
testImplementation "junit:junit:$junit4_version"
testImplementation "io.mockk:mockk:$mockk_version"
androidTestImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_version"
androidTestImplementation "io.mockk:mockk-android:$mockk_version"
}

View file

@ -0,0 +1,77 @@
/*
* SPDX-FileCopyrightText: 2020 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
import java.io.FileInputStream
import java.util.Properties
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
}
android {
namespace = "org.calyxos.backup.contacts"
compileSdk = libs.versions.compileSdk.get().toInt()
defaultConfig {
applicationId = "org.calyxos.backup.contacts"
minSdk = libs.versions.minSdk.get().toInt()
targetSdk = libs.versions.targetSdk.get().toInt()
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments(mapOf("disableAnalytics" to "true"))
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}
packagingOptions {
exclude("META-INF/LICENSE.md")
exclude("META-INF/LICENSE-notice.md")
}
testOptions.unitTests {
isReturnDefaultValues = true
}
// optional signingConfigs
// On userdebug builds, you can use the testkey here to update the system app
val keystorePropertiesFile = project.file("keystore.properties")
if (keystorePropertiesFile.exists()) {
val keystoreProperties = Properties()
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
signingConfigs {
create("release") {
keyAlias = keystoreProperties["keyAlias"] as String
keyPassword = keystoreProperties["keyPassword"] as String
storeFile = file(keystoreProperties["storeFile"] as String)
storePassword = keystoreProperties["storePassword"] as String
}
}
buildTypes.getByName("release").signingConfig = signingConfigs.getByName("release")
buildTypes.getByName("debug").signingConfig = signingConfigs.getByName("release")
}
}
val aospDeps = fileTree(mapOf("include" to listOf("com.android.vcard.jar"), "dir" to "libs"))
dependencies {
implementation(aospDeps)
testImplementation(libs.kotlin.stdlib.jdk8)
testImplementation("junit:junit:${libs.versions.junit4.get()}")
testImplementation("io.mockk:mockk:${libs.versions.mockk.get()}")
androidTestImplementation(libs.kotlin.stdlib.jdk8)
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:${libs.versions.espresso.get()}")
androidTestImplementation("io.mockk:mockk-android:${libs.versions.mockk.get()}")
}

View file

@ -1,113 +0,0 @@
ext {
// https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-13.0.0_r3/current/androidx/Android.bp#3901
ext.room_version = "2.4.0-alpha05" // 2.5.0-alpha01 in AOSP but needs testing
// https://android.googlesource.com/platform/external/protobuf/+/refs/tags/android-14.0.0_r1/java/pom.xml#7
ext.protobuf_version = "3.21.7"
// test dependencies below - these do not care about AOSP and can be freely updated
junit4_version = "4.13.2"
junit5_version = "5.10.0" // careful, upgrading this can change a Cipher's IV size in tests!?
mockk_version = "1.13.4" // newer versions require kotlin > 1.8.10
espresso_version = "3.4.0"
}
// To produce these binaries, in latest AOSP source tree, run
// $ m
ext.aosp_libs = 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_intermediates/classes.jar
'libcore.jar',
], dir: "${rootProject.projectDir}/app/libs")
ext.kotlin_libs = [
std: [
dependencies.create('org.jetbrains.kotlin:kotlin-stdlib') {
version { strictly "$aosp_kotlin_version" }
},
dependencies.create('org.jetbrains.kotlin:kotlin-stdlib-jdk8') {
version { strictly "$aosp_kotlin_version" }
},
dependencies.create('org.jetbrains.kotlin:kotlin-stdlib-common') {
version { strictly "$aosp_kotlin_version" }
},
],
coroutines: [
dependencies.create('org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm') {
// https://android.googlesource.com/platform/external/kotlinx.coroutines/+/refs/tags/android-14.0.0_r1/CHANGES.md
version { strictly '1.6.4' }
},
dependencies.create('org.jetbrains.kotlinx:kotlinx-coroutines-android') {
// https://android.googlesource.com/platform/external/kotlinx.coroutines/+/refs/tags/android-14.0.0_r1/CHANGES.md
version { strictly '1.6.4' }
},
],
]
ext.std_libs = [
androidx_core: [
// https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-14.0.0_r1/current/androidx/Android.bp#2420
dependencies.create('androidx.core:core') {
version { strictly '1.9.0-alpha05' } // 1.9.0-alpha03 in AOSP but has SDK version issues
},
// https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-14.0.0_r1/current/androidx/Android.bp#2386
dependencies.create('androidx.core:core-ktx') {
version { strictly '1.9.0-alpha05' } // 1.9.0-alpha03 in AOSP but has SDK version issues
},
],
// https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-14.0.0_r1/current/androidx/Android.bp#2849
androidx_fragment: dependencies.create('androidx.fragment:fragment-ktx') {
version { strictly '1.5.0-alpha03' }
},
// https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-14.0.0_r1/current/androidx/Android.bp#61
androidx_activity: dependencies.create('androidx.activity:activity-ktx') {
version { strictly '1.5.0-alpha03' }
},
// https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-14.0.0_r1/current/androidx/Android.bp#4420
androidx_preference: dependencies.create('androidx.preference:preference') {
version { strictly '1.2.0-alpha01' }
},
// https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-13.0.0_r3/current/androidx/Android.bp#3521
androidx_lifecycle_viewmodel_ktx: dependencies.create('androidx.lifecycle:lifecycle-viewmodel-ktx') {
version { strictly '2.5.0-alpha03' }
},
// https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-14.0.0_r1/current/androidx/Android.bp#3279
androidx_lifecycle_livedata_ktx: dependencies.create('androidx.lifecycle:lifecycle-livedata-ktx') {
version { strictly '2.5.0-alpha03' }
},
// https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-14.0.0_r1/current/androidx/Android.bp#2244
androidx_constraintlayout: dependencies.create('androidx.constraintlayout:constraintlayout') {
version { strictly '2.2.0-alpha05' }
},
// https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-14.0.0_r1/current/androidx/Android.bp#2556
androidx_documentfile: dependencies.create('androidx.documentfile:documentfile') {
version { strictly '1.1.0-alpha01' } // 1.1.0-alpha02 in AOSP but not released yet
},
// https://android.googlesource.com/platform/prebuilts/sdk/+/refs/tags/android-14.0.0_r1/current/extras/material-design-x/Android.bp#15
com_google_android_material: dependencies.create('com.google.android.material:material') {
version { strictly '1.7.0-alpha03' }
},
]
ext.lint_libs = [
exceptions: 'com.github.thirdegg:lint-rules:0.1.0'
]
ext.storage_libs = [
androidx_room_runtime: dependencies.create('androidx.room:room-runtime') {
version { strictly "$room_version" }
},
com_google_protobuf_javalite: dependencies.create('com.google.protobuf:protobuf-javalite') {
version { strictly "$protobuf_version" }
},
// https://github.com/google/tink/releases
com_google_crypto_tink_android: dependencies.create('com.google.crypto.tink:tink-android') {
// careful with upgrading tink, so old backups continue to be decryptable
version { strictly '1.10.0' }
},
]

View file

@ -1,11 +0,0 @@
ktlint {
version = "0.42.1"
android = true
enableExperimentalRules = false
verbose = true
disabledRules = [
"import-ordering",
"no-blank-line-before-rbrace",
"indent",
]
}

View file

@ -1,32 +0,0 @@
pluginManagement {
buildscript {
repositories {
mavenCentral()
maven { url = uri("https://storage.googleapis.com/r8-releases/raw") }
}
dependencies {
// https://issuetracker.google.com/issues/227160052#comment37
// This can be removed when we switch to Android Gradle plugin 8.2.
classpath("com.android.tools:r8:8.2.28")
}
}
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
rootProject.name = 'Seedvault'
include ':app'
include ':contactsbackup'
include ':storage:lib'
include ':storage:demo'

44
settings.gradle.kts Normal file
View file

@ -0,0 +1,44 @@
pluginManagement {
buildscript {
repositories {
mavenCentral()
maven {
// https://issuetracker.google.com/issues/227160052#comment37
// This can be removed when we switch to Android Gradle plugin 8.2.
setUrl(uri("https://storage.googleapis.com/r8-releases/raw"))
}
}
dependencies {
classpath("com.android.tools:r8:8.2.28")
}
}
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven("https://jitpack.io")
}
versionCatalogs {
create("libs") {
from(files("build.libs.toml"))
}
create("plugins") {
from(files("build.plugins.toml"))
}
}
}
rootProject.name = "Seedvault"
include(":app")
include(":contactsbackup")
include(":storage:lib")
include(":storage:demo")

View file

@ -1,76 +0,0 @@
/*
* SPDX-FileCopyrightText: 2021 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
plugins {
id 'com.android.application'
id 'com.google.protobuf'
id 'org.jetbrains.kotlin.android'
id 'org.jetbrains.kotlin.kapt'
}
android {
namespace 'de.grobox.storagebackuptester'
compileSdk rootProject.ext.compileSdk
defaultConfig {
applicationId "de.grobox.storagebackuptester"
minSdk rootProject.ext.minSdk
targetSdk rootProject.ext.targetSdk
versionCode 20
versionName "0.9.7"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments disableAnalytics: 'true'
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
}
lint {
disable "DialogFragmentCallbacksDetector",
"InvalidFragmentVersionForActivityResult"
}
packagingOptions {
jniLibs {
excludes += ['META-INF/services/kotlin*']
}
resources {
excludes += [
'META-INF/*.kotlin_module',
'META-INF/androidx.*.version',
'META-INF/services/kotlin*',
'kotlin/internal/internal.kotlin_builtins'
]
}
}
}
dependencies {
implementation project(':storage:lib')
implementation rootProject.ext.kotlin_libs.std
implementation rootProject.ext.std_libs.androidx_core
// A newer version gets pulled in with AOSP via core, so we include fragment here explicitly
implementation rootProject.ext.std_libs.androidx_fragment
implementation rootProject.ext.std_libs.androidx_activity
implementation rootProject.ext.std_libs.androidx_lifecycle_viewmodel_ktx
implementation rootProject.ext.std_libs.androidx_lifecycle_livedata_ktx
implementation rootProject.ext.std_libs.androidx_constraintlayout
implementation rootProject.ext.std_libs.com_google_android_material
implementation rootProject.ext.storage_libs.com_google_protobuf_javalite
}

View file

@ -0,0 +1,83 @@
/*
* SPDX-FileCopyrightText: 2021 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
plugins {
id("com.android.application")
id("com.google.protobuf")
id("org.jetbrains.kotlin.android")
id("org.jetbrains.kotlin.kapt")
}
android {
namespace = "de.grobox.storagebackuptester"
compileSdk = libs.versions.compileSdk.get().toInt()
defaultConfig {
applicationId = "de.grobox.storagebackuptester"
minSdk = libs.versions.minSdk.get().toInt()
targetSdk = libs.versions.targetSdk.get().toInt()
versionCode = 20
versionName = "0.9.7"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments.clear()
testInstrumentationRunnerArguments.putAll(mapOf("disableAnalytics" to "true"))
}
buildTypes {
getByName("release") {
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
freeCompilerArgs += listOf("-opt-in=kotlin.RequiresOptIn")
}
lintOptions {
disable("DialogFragmentCallbacksDetector", "InvalidFragmentVersionForActivityResult")
}
packagingOptions {
jniLibs {
excludes += listOf("META-INF/services/kotlin*")
}
resources {
excludes += listOf(
"META-INF/*.kotlin_module",
"META-INF/androidx.*.version",
"META-INF/services/kotlin*",
"kotlin/internal/internal.kotlin_builtins"
)
}
}
}
dependencies {
implementation(project(":storage:lib"))
implementation(libs.bundles.kotlin)
implementation(libs.androidx.core)
// A newer version gets pulled in with AOSP via core, so we include fragment here explicitly
implementation(libs.androidx.fragment)
implementation(libs.androidx.activity)
implementation(libs.androidx.lifecycle.viewmodel.ktx)
implementation(libs.androidx.lifecycle.livedata.ktx)
implementation(libs.androidx.constraintlayout)
implementation(libs.google.material)
implementation(libs.google.protobuf.javalite)
}

View file

@ -1,106 +0,0 @@
/*
* SPDX-FileCopyrightText: 2021 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
plugins {
id 'com.android.library'
id 'com.google.protobuf'
id 'org.jetbrains.kotlin.android'
id 'org.jetbrains.kotlin.kapt'
id 'org.jetbrains.dokka'
id 'org.jlleitschuh.gradle.ktlint'
}
android {
namespace 'org.calyxos.backup.storage'
compileSdk rootProject.ext.compileSdk
defaultConfig {
minSdk rootProject.ext.minSdk
targetSdk rootProject.ext.targetSdk
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments disableAnalytics: 'true'
consumerProguardFiles "consumer-rules.pro"
}
buildTypes {
all {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
languageVersion = "1.8"
freeCompilerArgs += '-opt-in=kotlin.RequiresOptIn'
freeCompilerArgs += '-Xexplicit-api=strict'
}
protobuf {
protoc {
if ("aarch64" == System.getProperty("os.arch")) {
// mac m1
artifact = "com.google.protobuf:protoc:$protobuf_version:osx-x86_64"
} else {
// other
artifact = "com.google.protobuf:protoc:$protobuf_version"
}
}
generateProtoTasks {
all().each { task ->
task.builtins {
java {
option "lite"
}
}
}
}
}
lint {
disable "DialogFragmentCallbacksDetector",
"InvalidFragmentVersionForActivityResult",
"CheckedExceptions"
}
}
kotlin {
explicitApi = 'strict'
}
dependencies {
implementation rootProject.ext.kotlin_libs.std
implementation rootProject.ext.std_libs.androidx_core
// A newer version gets pulled in with AOSP via core, so we include fragment here explicitly
implementation rootProject.ext.std_libs.androidx_fragment
implementation rootProject.ext.std_libs.androidx_activity
implementation rootProject.ext.std_libs.androidx_lifecycle_viewmodel_ktx
implementation rootProject.ext.std_libs.androidx_lifecycle_livedata_ktx
implementation rootProject.ext.std_libs.androidx_constraintlayout
implementation rootProject.ext.std_libs.androidx_documentfile
implementation rootProject.ext.std_libs.com_google_android_material
implementation rootProject.ext.storage_libs.androidx_room_runtime
implementation rootProject.ext.storage_libs.com_google_protobuf_javalite
implementation rootProject.ext.storage_libs.com_google_crypto_tink_android
kapt('androidx.room:room-compiler') {
version { strictly "$room_version" }
}
lintChecks rootProject.ext.lint_libs.exceptions
testImplementation "junit:junit:$junit4_version"
testImplementation "io.mockk:mockk:$mockk_version"
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_version"
}
apply from: "${rootProject.rootDir}/gradle/ktlint.gradle"

View file

@ -0,0 +1,107 @@
import com.google.protobuf.gradle.id
/*
* SPDX-FileCopyrightText: 2021 The Calyx Institute
* SPDX-License-Identifier: Apache-2.0
*/
plugins {
id("com.google.protobuf")
id("org.jetbrains.kotlin.kapt")
id("org.jetbrains.dokka")
id("com.android.library")
kotlin("android")
}
android {
namespace = "org.calyxos.backup.storage"
compileSdk = libs.versions.compileSdk.get().toInt()
defaultConfig {
minSdk = libs.versions.minSdk.get().toInt()
targetSdk = libs.versions.targetSdk.get().toInt()
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments(mapOf("disableAnalytics" to "true"))
}
buildTypes {
all {
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
languageVersion = "1.8"
freeCompilerArgs += listOf(
"-opt-in=kotlin.RequiresOptIn",
"-Xexplicit-api=strict"
)
}
protobuf {
protoc {
if ("aarch64" == System.getProperty("os.arch")) {
// mac m1
artifact = "com.google.protobuf:protoc:${libs.versions.protobuf.get()}:osx-x86_64"
} else {
// other
artifact = "com.google.protobuf:protoc:${libs.versions.protobuf.get()}"
}
}
generateProtoTasks {
all().forEach { task ->
task.builtins {
id("java") {
option("lite")
}
}
}
}
}
lint {
checkReleaseBuilds = false
abortOnError = false
disable.clear()
disable += setOf(
"DialogFragmentCallbacksDetector",
"InvalidFragmentVersionForActivityResult",
"CheckedExceptions"
)
}
}
dependencies {
implementation(libs.bundles.kotlin)
implementation(libs.androidx.core)
implementation(libs.androidx.fragment)
implementation(libs.androidx.activity)
implementation(libs.androidx.lifecycle.viewmodel.ktx)
implementation(libs.androidx.lifecycle.livedata.ktx)
implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.documentfile)
implementation(libs.google.material)
implementation(libs.androidx.room.runtime)
implementation(libs.google.protobuf.javalite)
implementation(libs.google.tink.android)
kapt(group = "androidx.room", name = "room-compiler", version = libs.versions.room.get())
lintChecks(libs.thirdegg.lint.rules)
testImplementation("junit:junit:${libs.versions.junit4.get()}")
testImplementation("io.mockk:mockk:${libs.versions.mockk.get()}")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:${libs.versions.aosp.kotlin.get()}")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation(
"androidx.test.espresso:espresso-core:${libs.versions.espresso.get()}"
)
}