aboutsummaryrefslogtreecommitdiff
path: root/buildSrc
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2021-03-09 14:53:11 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2021-03-18 11:40:30 +0530
commit774fda83ac276a635e3402034b1eedbd10be916f (patch)
tree57783a953fcd193d32f1e3dc8df26e07f03df328 /buildSrc
parentbe31ae37f443982b377d027cd613f04d0926568d (diff)
all: reformat with ktfmt
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'buildSrc')
-rw-r--r--buildSrc/build.gradle.kts60
-rw-r--r--buildSrc/buildSrc/build.gradle.kts8
-rw-r--r--buildSrc/src/main/java/BaseProjectConfig.kt175
-rw-r--r--buildSrc/src/main/java/BinaryCompatibilityValidator.kt6
-rw-r--r--buildSrc/src/main/java/CrowdinDownloadPlugin.kt104
-rw-r--r--buildSrc/src/main/java/CrowdinExtension.kt18
-rw-r--r--buildSrc/src/main/java/Dependencies.kt154
-rw-r--r--buildSrc/src/main/java/KotlinCompilerArgs.kt4
-rw-r--r--buildSrc/src/main/java/Ktfmt.kt4
-rw-r--r--buildSrc/src/main/java/PasswordStorePlugin.kt57
-rw-r--r--buildSrc/src/main/java/SigningConfig.kt36
-rw-r--r--buildSrc/src/main/java/VersioningPlugin.kt159
12 files changed, 377 insertions, 408 deletions
diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts
index 87f70c66..627cab92 100644
--- a/buildSrc/build.gradle.kts
+++ b/buildSrc/build.gradle.kts
@@ -3,46 +3,42 @@
* SPDX-License-Identifier: GPL-3.0-only
*/
-plugins {
- `kotlin-dsl`
-}
+plugins { `kotlin-dsl` }
repositories {
- google()
- gradlePluginPortal()
- mavenCentral()
- // For binary compatibility validator.
- maven { url = uri("https://kotlin.bintray.com/kotlinx") }
+ google()
+ gradlePluginPortal()
+ mavenCentral()
+ // For binary compatibility validator.
+ maven { url = uri("https://kotlin.bintray.com/kotlinx") }
}
-kotlinDslPluginOptions {
- experimentalWarning.set(false)
-}
+kotlinDslPluginOptions { experimentalWarning.set(false) }
gradlePlugin {
- plugins {
- register("aps") {
- id = "aps-plugin"
- implementationClass = "PasswordStorePlugin"
- }
- register("crowdin") {
- id = "crowdin-plugin"
- implementationClass = "CrowdinDownloadPlugin"
- }
- register("versioning") {
- id = "versioning-plugin"
- implementationClass = "VersioningPlugin"
- }
+ plugins {
+ register("aps") {
+ id = "aps-plugin"
+ implementationClass = "PasswordStorePlugin"
+ }
+ register("crowdin") {
+ id = "crowdin-plugin"
+ implementationClass = "CrowdinDownloadPlugin"
+ }
+ register("versioning") {
+ id = "versioning-plugin"
+ implementationClass = "VersioningPlugin"
}
+ }
}
dependencies {
- implementation(Plugins.androidGradlePlugin)
- implementation(Plugins.binaryCompatibilityValidator)
- implementation(Plugins.dokkaPlugin)
- implementation(Plugins.downloadTaskPlugin)
- implementation(Plugins.kotlinGradlePlugin)
- implementation(Plugins.ktfmtGradlePlugin)
- implementation(Plugins.mavenPublishPlugin)
- implementation(Plugins.semver4j)
+ implementation(Plugins.androidGradlePlugin)
+ implementation(Plugins.binaryCompatibilityValidator)
+ implementation(Plugins.dokkaPlugin)
+ implementation(Plugins.downloadTaskPlugin)
+ implementation(Plugins.kotlinGradlePlugin)
+ implementation(Plugins.ktfmtGradlePlugin)
+ implementation(Plugins.mavenPublishPlugin)
+ implementation(Plugins.semver4j)
}
diff --git a/buildSrc/buildSrc/build.gradle.kts b/buildSrc/buildSrc/build.gradle.kts
index 7092e5dd..f4bc8a7e 100644
--- a/buildSrc/buildSrc/build.gradle.kts
+++ b/buildSrc/buildSrc/build.gradle.kts
@@ -1,6 +1,4 @@
-plugins {
- `kotlin-dsl`
-}
+plugins { `kotlin-dsl` }
repositories {
mavenCentral()
@@ -8,9 +6,7 @@ repositories {
gradlePluginPortal()
}
-kotlinDslPluginOptions {
- experimentalWarning.set(false)
-}
+kotlinDslPluginOptions { experimentalWarning.set(false) }
// force compilation of Dependencies.kt so it can be referenced in buildSrc/build.gradle.kts
sourceSets.main {
diff --git a/buildSrc/src/main/java/BaseProjectConfig.kt b/buildSrc/src/main/java/BaseProjectConfig.kt
index 6593fe39..5dcde1af 100644
--- a/buildSrc/src/main/java/BaseProjectConfig.kt
+++ b/buildSrc/src/main/java/BaseProjectConfig.kt
@@ -17,125 +17,114 @@ import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
/**
- * Configure root project.
- * Note that classpath dependencies still need to be defined in the `buildscript` block in the top-level build.gradle.kts file.
+ * Configure root project. Note that classpath dependencies still need to be defined in the
+ * `buildscript` block in the top-level build.gradle.kts file.
*/
internal fun Project.configureForRootProject() {
- // register task for cleaning the build directory in the root project
- tasks.register("clean", Delete::class.java) {
- delete(rootProject.buildDir)
- }
- tasks.withType<Wrapper> {
- gradleVersion = "6.8.3"
- distributionType = Wrapper.DistributionType.ALL
- distributionSha256Sum = "9af5c8e7e2cd1a3b0f694a4ac262b9f38c75262e74a9e8b5101af302a6beadd7"
- }
- configureBinaryCompatibilityValidator()
+ // register task for cleaning the build directory in the root project
+ tasks.register("clean", Delete::class.java) { delete(rootProject.buildDir) }
+ tasks.withType<Wrapper> {
+ gradleVersion = "6.8.3"
+ distributionType = Wrapper.DistributionType.ALL
+ distributionSha256Sum = "9af5c8e7e2cd1a3b0f694a4ac262b9f38c75262e74a9e8b5101af302a6beadd7"
+ }
+ configureBinaryCompatibilityValidator()
}
-/**
- * Configure all projects including the root project
- */
+/** Configure all projects including the root project */
internal fun Project.configureForAllProjects() {
- repositories {
- google()
- mavenCentral()
- jcenter() {
- content {
- // https://github.com/zhanghai/AndroidFastScroll/issues/35
- includeModule("me.zhanghai.android.fastscroll", "library")
- // https://github.com/open-keychain/open-keychain/issues/2645
- includeModule("org.sufficientlysecure", "sshauthentication-api")
- }
- }
- maven("https://jitpack.io") {
- name = "Jitpack"
- content {
- includeModule("com.github.android-password-store", "zxing-android-embedded")
- includeModule("com.github.haroldadmin", "WhatTheStack")
- }
- }
+ repositories {
+ google()
+ mavenCentral()
+ jcenter() {
+ content {
+ // https://github.com/zhanghai/AndroidFastScroll/issues/35
+ includeModule("me.zhanghai.android.fastscroll", "library")
+ // https://github.com/open-keychain/open-keychain/issues/2645
+ includeModule("org.sufficientlysecure", "sshauthentication-api")
+ }
}
- tasks.withType<KotlinCompile> {
- kotlinOptions {
- jvmTarget = JavaVersion.VERSION_1_8.toString()
- freeCompilerArgs = freeCompilerArgs + additionalCompilerArgs
- languageVersion = "1.4"
- useIR = true
- }
+ maven("https://jitpack.io") {
+ name = "Jitpack"
+ content {
+ includeModule("com.github.android-password-store", "zxing-android-embedded")
+ includeModule("com.github.haroldadmin", "WhatTheStack")
+ }
}
- tasks.withType<Test> {
- maxParallelForks = Runtime.getRuntime().availableProcessors() * 2
- testLogging {
- events(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
- }
+ }
+ tasks.withType<KotlinCompile> {
+ kotlinOptions {
+ jvmTarget = JavaVersion.VERSION_1_8.toString()
+ freeCompilerArgs = freeCompilerArgs + additionalCompilerArgs
+ languageVersion = "1.4"
+ useIR = true
}
+ }
+ tasks.withType<Test> {
+ maxParallelForks = Runtime.getRuntime().availableProcessors() * 2
+ testLogging { events(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED) }
+ }
}
-/**
- * Checks if we're building a snapshot
- */
+/** Checks if we're building a snapshot */
@Suppress("UnstableApiUsage")
fun Project.isSnapshot(): Boolean {
- with(project.providers) {
- val workflow = environmentVariable("GITHUB_WORKFLOW").forUseAtConfigurationTime()
- val snapshot = environmentVariable("SNAPSHOT").forUseAtConfigurationTime()
- return workflow.isPresent && snapshot.isPresent
- }
+ with(project.providers) {
+ val workflow = environmentVariable("GITHUB_WORKFLOW").forUseAtConfigurationTime()
+ val snapshot = environmentVariable("SNAPSHOT").forUseAtConfigurationTime()
+ return workflow.isPresent && snapshot.isPresent
+ }
}
-/**
- * Apply configurations for app module
- */
+/** Apply configurations for app module */
@Suppress("UnstableApiUsage")
internal fun BaseAppModuleExtension.configureAndroidApplicationOptions(project: Project) {
- val minifySwitch = project.providers.environmentVariable("DISABLE_MINIFY").forUseAtConfigurationTime()
+ val minifySwitch =
+ project.providers.environmentVariable("DISABLE_MINIFY").forUseAtConfigurationTime()
- adbOptions.installOptions("--user 0")
+ adbOptions.installOptions("--user 0")
- buildFeatures {
- viewBinding = true
- buildConfig = true
- }
+ buildFeatures {
+ viewBinding = true
+ buildConfig = true
+ }
- buildTypes {
- named("release") {
- isMinifyEnabled = !minifySwitch.isPresent
- setProguardFiles(listOf("proguard-android-optimize.txt", "proguard-rules.pro"))
- buildConfigField("boolean", "ENABLE_DEBUG_FEATURES", "${project.isSnapshot()}")
- }
- named("debug") {
- applicationIdSuffix = ".debug"
- versionNameSuffix = "-debug"
- isMinifyEnabled = false
- buildConfigField("boolean", "ENABLE_DEBUG_FEATURES", "true")
- }
+ buildTypes {
+ named("release") {
+ isMinifyEnabled = !minifySwitch.isPresent
+ setProguardFiles(listOf("proguard-android-optimize.txt", "proguard-rules.pro"))
+ buildConfigField("boolean", "ENABLE_DEBUG_FEATURES", "${project.isSnapshot()}")
}
+ named("debug") {
+ applicationIdSuffix = ".debug"
+ versionNameSuffix = "-debug"
+ isMinifyEnabled = false
+ buildConfigField("boolean", "ENABLE_DEBUG_FEATURES", "true")
+ }
+ }
}
-/**
- * Apply baseline configurations for all Android projects (Application and Library).
- */
+/** Apply baseline configurations for all Android projects (Application and Library). */
@Suppress("UnstableApiUsage")
internal fun TestedExtension.configureCommonAndroidOptions() {
- compileSdkVersion(30)
+ compileSdkVersion(30)
- defaultConfig {
- minSdkVersion(23)
- targetSdkVersion(29)
- }
+ defaultConfig {
+ minSdkVersion(23)
+ targetSdkVersion(29)
+ }
- packagingOptions {
- exclude("**/*.version")
- exclude("**/*.txt")
- exclude("**/*.kotlin_module")
- exclude("**/plugin.properties")
- }
+ packagingOptions {
+ exclude("**/*.version")
+ exclude("**/*.txt")
+ exclude("**/*.kotlin_module")
+ exclude("**/plugin.properties")
+ }
- compileOptions {
- sourceCompatibility = JavaVersion.VERSION_1_8
- targetCompatibility = JavaVersion.VERSION_1_8
- }
+ compileOptions {
+ sourceCompatibility = JavaVersion.VERSION_1_8
+ targetCompatibility = JavaVersion.VERSION_1_8
+ }
- testOptions.animationsDisabled = true
+ testOptions.animationsDisabled = true
}
diff --git a/buildSrc/src/main/java/BinaryCompatibilityValidator.kt b/buildSrc/src/main/java/BinaryCompatibilityValidator.kt
index 8d755a86..6d7c53fb 100644
--- a/buildSrc/src/main/java/BinaryCompatibilityValidator.kt
+++ b/buildSrc/src/main/java/BinaryCompatibilityValidator.kt
@@ -8,9 +8,5 @@ import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
internal fun Project.configureBinaryCompatibilityValidator() {
- extensions.configure<ApiValidationExtension> {
- ignoredProjects = mutableSetOf(
- "app"
- )
- }
+ extensions.configure<ApiValidationExtension> { ignoredProjects = mutableSetOf("app") }
}
diff --git a/buildSrc/src/main/java/CrowdinDownloadPlugin.kt b/buildSrc/src/main/java/CrowdinDownloadPlugin.kt
index af32975f..03a7859c 100644
--- a/buildSrc/src/main/java/CrowdinDownloadPlugin.kt
+++ b/buildSrc/src/main/java/CrowdinDownloadPlugin.kt
@@ -14,63 +14,59 @@ import org.gradle.kotlin.dsl.register
class CrowdinDownloadPlugin : Plugin<Project> {
- override fun apply(project: Project) {
- with(project) {
- val extension = extensions.create<CrowdinExtension>("crowdin")
- afterEvaluate {
- val projectName = extension.projectName
- if (projectName.isEmpty()) {
- throw GradleException(
- """
+ override fun apply(project: Project) {
+ with(project) {
+ val extension = extensions.create<CrowdinExtension>("crowdin")
+ afterEvaluate {
+ val projectName = extension.projectName
+ if (projectName.isEmpty()) {
+ throw GradleException(
+ """
Applying `crowdin-plugin` requires a projectName to be configured via the "crowdin" extension.
- """.trimIndent()
- )
- }
- tasks.register<Download>("downloadCrowdin") {
- src("https://crowdin.com/backend/download/project/$projectName.zip")
- dest("$buildDir/translations.zip")
- overwrite(true)
- }
- tasks.register<Copy>("extractCrowdin") {
- setDependsOn(setOf("downloadCrowdin"))
- doFirst {
- File(buildDir, "translations").deleteRecursively()
- }
- from(zipTree("$buildDir/translations.zip"))
- into("$buildDir/translations")
- }
- tasks.register<Copy>("extractBaseStrings") {
- setDependsOn(setOf("extractCrowdin"))
- from("$buildDir/translations/${project.name}/src/main/res")
- into("${projectDir}/src/main/res")
- }
- tasks.register<Copy>("extractNonFreeStrings") {
- setDependsOn(setOf("extractCrowdin"))
- from("$buildDir/translations/") {
- exclude("app/")
- }
- into("$buildDir/nonFree-translations")
- doLast {
- File("$buildDir/nonFree-translations")
- .listFiles { file: File -> file.isDirectory }?.forEach { file ->
- val dest = File("${projectDir}/src/nonFree/values-${file.name}")
- val src = File(file, "app/src/nonFree/res/values/strings.xml")
- dest.mkdirs()
- src.renameTo(File(dest, "strings.xml"))
- }
- }
- }
- tasks.register("crowdin") {
- setDependsOn(setOf("extractBaseStrings", "extractNonFreeStrings"))
- if (!extension.skipCleanup) {
- doLast {
- File("$buildDir/translations").deleteRecursively()
- File("$buildDir/nonFree-translations").deleteRecursively()
- File("$buildDir/translations.zip").delete()
- }
- }
+ """.trimIndent())
+ }
+ tasks.register<Download>("downloadCrowdin") {
+ src("https://crowdin.com/backend/download/project/$projectName.zip")
+ dest("$buildDir/translations.zip")
+ overwrite(true)
+ }
+ tasks.register<Copy>("extractCrowdin") {
+ setDependsOn(setOf("downloadCrowdin"))
+ doFirst { File(buildDir, "translations").deleteRecursively() }
+ from(zipTree("$buildDir/translations.zip"))
+ into("$buildDir/translations")
+ }
+ tasks.register<Copy>("extractBaseStrings") {
+ setDependsOn(setOf("extractCrowdin"))
+ from("$buildDir/translations/${project.name}/src/main/res")
+ into("${projectDir}/src/main/res")
+ }
+ tasks.register<Copy>("extractNonFreeStrings") {
+ setDependsOn(setOf("extractCrowdin"))
+ from("$buildDir/translations/") { exclude("app/") }
+ into("$buildDir/nonFree-translations")
+ doLast {
+ File("$buildDir/nonFree-translations")
+ .listFiles { file: File -> file.isDirectory }
+ ?.forEach { file ->
+ val dest = File("${projectDir}/src/nonFree/values-${file.name}")
+ val src = File(file, "app/src/nonFree/res/values/strings.xml")
+ dest.mkdirs()
+ src.renameTo(File(dest, "strings.xml"))
}
+ }
+ }
+ tasks.register("crowdin") {
+ setDependsOn(setOf("extractBaseStrings", "extractNonFreeStrings"))
+ if (!extension.skipCleanup) {
+ doLast {
+ File("$buildDir/translations").deleteRecursively()
+ File("$buildDir/nonFree-translations").deleteRecursively()
+ File("$buildDir/translations.zip").delete()
}
+ }
}
+ }
}
+ }
}
diff --git a/buildSrc/src/main/java/CrowdinExtension.kt b/buildSrc/src/main/java/CrowdinExtension.kt
index ba244d62..e50d8e5c 100644
--- a/buildSrc/src/main/java/CrowdinExtension.kt
+++ b/buildSrc/src/main/java/CrowdinExtension.kt
@@ -5,15 +5,13 @@
open class CrowdinExtension {
- /**
- * Configure the project name on Crowdin
- */
- open var projectName = ""
+ /** Configure the project name on Crowdin */
+ open var projectName = ""
- /**
- * Don't delete downloaded and extracted translation archives from build directory.
- *
- * Useful for debugging.
- */
- open var skipCleanup = false
+ /**
+ * Don't delete downloaded and extracted translation archives from build directory.
+ *
+ * Useful for debugging.
+ */
+ open var skipCleanup = false
}
diff --git a/buildSrc/src/main/java/Dependencies.kt b/buildSrc/src/main/java/Dependencies.kt
index f83227cb..d8090538 100644
--- a/buildSrc/src/main/java/Dependencies.kt
+++ b/buildSrc/src/main/java/Dependencies.kt
@@ -6,88 +6,92 @@
private const val KOTLIN_VERSION = "1.4.31"
object Plugins {
- const val androidGradlePlugin = "com.android.tools.build:gradle:4.1.2"
- const val binaryCompatibilityValidator = "org.jetbrains.kotlinx:binary-compatibility-validator:0.2.4"
- const val dokkaPlugin = "org.jetbrains.dokka:dokka-gradle-plugin:1.4.20"
- const val downloadTaskPlugin = "de.undercouch:gradle-download-task:4.1.1"
- const val kotlinGradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$KOTLIN_VERSION"
- const val ktfmtGradlePlugin = "com.ncorti.ktfmt.gradle:plugin:0.4.0"
- const val mavenPublishPlugin = "com.vanniktech:gradle-maven-publish-plugin:0.13.0"
- const val semver4j = "com.vdurmont:semver4j:3.1.0"
+ const val androidGradlePlugin = "com.android.tools.build:gradle:4.1.2"
+ const val binaryCompatibilityValidator =
+ "org.jetbrains.kotlinx:binary-compatibility-validator:0.2.4"
+ const val dokkaPlugin = "org.jetbrains.dokka:dokka-gradle-plugin:1.4.20"
+ const val downloadTaskPlugin = "de.undercouch:gradle-download-task:4.1.1"
+ const val kotlinGradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$KOTLIN_VERSION"
+ const val ktfmtGradlePlugin = "com.ncorti.ktfmt.gradle:plugin:0.4.0"
+ const val mavenPublishPlugin = "com.vanniktech:gradle-maven-publish-plugin:0.13.0"
+ const val semver4j = "com.vdurmont:semver4j:3.1.0"
}
object Dependencies {
- object Kotlin {
- object Coroutines {
+ object Kotlin {
+ object Coroutines {
- private const val version = "1.4.2"
- const val android = "org.jetbrains.kotlinx:kotlinx-coroutines-android:$version"
- const val core = "org.jetbrains.kotlinx:kotlinx-coroutines-core:$version"
- }
+ private const val version = "1.4.2"
+ const val android = "org.jetbrains.kotlinx:kotlinx-coroutines-android:$version"
+ const val core = "org.jetbrains.kotlinx:kotlinx-coroutines-core:$version"
}
+ }
+
+ object AndroidX {
+
+ private const val lifecycleVersion = "2.3.0-rc01"
+
+ const val activity_ktx = "androidx.activity:activity-ktx:1.3.0-alpha03"
+ const val annotation = "androidx.annotation:annotation:1.1.0"
+ const val autofill = "androidx.autofill:autofill:1.1.0"
+ const val appcompat = "androidx.appcompat:appcompat:1.3.0-beta01"
+ const val biometric_ktx = "androidx.biometric:biometric-ktx:1.2.0-alpha03"
+ const val constraint_layout = "androidx.constraintlayout:constraintlayout:2.1.0-alpha2"
+ const val core_ktx = "androidx.core:core-ktx:1.5.0-beta02"
+ const val documentfile = "androidx.documentfile:documentfile:1.0.1"
+ const val fragment_ktx = "androidx.fragment:fragment-ktx:1.3.0"
+ const val lifecycle_common = "androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion"
+ const val lifecycle_livedata_ktx = "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycleVersion"
+ const val lifecycle_viewmodel_ktx =
+ "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion"
+ const val material = "com.google.android.material:material:1.3.0"
+ const val preference = "androidx.preference:preference:1.1.1"
+ const val recycler_view = "androidx.recyclerview:recyclerview:1.2.0-beta02"
+ const val recycler_view_selection = "androidx.recyclerview:recyclerview-selection:1.1.0"
+ const val security = "androidx.security:security-crypto:1.1.0-alpha03"
+ const val swiperefreshlayout = "androidx.swiperefreshlayout:swiperefreshlayout:1.2.0-alpha01"
+ }
+
+ object FirstParty {
+
+ const val zxing_android_embedded =
+ "com.github.android-password-store:zxing-android-embedded:4.1.0-aps"
+ }
+
+ object ThirdParty {
+
+ const val bouncycastle = "org.bouncycastle:bcprov-jdk15on:1.67"
+ const val commons_codec = "commons-codec:commons-codec:1.14"
+ const val eddsa = "net.i2p.crypto:eddsa:0.3.0"
+ const val fastscroll = "me.zhanghai.android.fastscroll:library:1.1.5"
+ const val jgit = "org.eclipse.jgit:org.eclipse.jgit:3.7.1.201504261725-r"
+ const val kotlin_result = "com.michael-bull.kotlin-result:kotlin-result:1.1.10"
+ const val leakcanary = "com.squareup.leakcanary:leakcanary-android:2.6"
+ const val modern_android_prefs = "de.maxr1998:modernandroidpreferences:2.0"
+ const val plumber = "com.squareup.leakcanary:plumber-android:2.6"
+ const val sshj = "com.hierynomus:sshj:0.31.0"
+ const val ssh_auth = "org.sufficientlysecure:sshauthentication-api:1.0"
+ const val timber = "com.jakewharton.timber:timber:4.7.1"
+ const val timberkt = "com.github.ajalt:timberkt:1.5.1"
+ const val whatthestack = "com.github.haroldadmin:WhatTheStack:0.3.0"
+ }
+
+ object NonFree {
+
+ const val google_play_auth_api_phone =
+ "com.google.android.gms:play-services-auth-api-phone:17.5.0"
+ }
+
+ object Testing {
+
+ const val junit = "junit:junit:4.13.1"
+ const val kotlin_test_junit = "org.jetbrains.kotlin:kotlin-test-junit:$KOTLIN_VERSION"
object AndroidX {
- private const val lifecycleVersion = "2.3.0-rc01"
-
- const val activity_ktx = "androidx.activity:activity-ktx:1.3.0-alpha03"
- const val annotation = "androidx.annotation:annotation:1.1.0"
- const val autofill = "androidx.autofill:autofill:1.1.0"
- const val appcompat = "androidx.appcompat:appcompat:1.3.0-beta01"
- const val biometric_ktx = "androidx.biometric:biometric-ktx:1.2.0-alpha03"
- const val constraint_layout = "androidx.constraintlayout:constraintlayout:2.1.0-alpha2"
- const val core_ktx = "androidx.core:core-ktx:1.5.0-beta02"
- const val documentfile = "androidx.documentfile:documentfile:1.0.1"
- const val fragment_ktx = "androidx.fragment:fragment-ktx:1.3.0"
- const val lifecycle_common = "androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion"
- const val lifecycle_livedata_ktx = "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycleVersion"
- const val lifecycle_viewmodel_ktx = "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion"
- const val material = "com.google.android.material:material:1.3.0"
- const val preference = "androidx.preference:preference:1.1.1"
- const val recycler_view = "androidx.recyclerview:recyclerview:1.2.0-beta02"
- const val recycler_view_selection = "androidx.recyclerview:recyclerview-selection:1.1.0"
- const val security = "androidx.security:security-crypto:1.1.0-alpha03"
- const val swiperefreshlayout = "androidx.swiperefreshlayout:swiperefreshlayout:1.2.0-alpha01"
- }
-
- object FirstParty {
-
- const val zxing_android_embedded = "com.github.android-password-store:zxing-android-embedded:4.1.0-aps"
- }
-
- object ThirdParty {
-
- const val bouncycastle = "org.bouncycastle:bcprov-jdk15on:1.67"
- const val commons_codec = "commons-codec:commons-codec:1.14"
- const val eddsa = "net.i2p.crypto:eddsa:0.3.0"
- const val fastscroll = "me.zhanghai.android.fastscroll:library:1.1.5"
- const val jgit = "org.eclipse.jgit:org.eclipse.jgit:3.7.1.201504261725-r"
- const val kotlin_result = "com.michael-bull.kotlin-result:kotlin-result:1.1.10"
- const val leakcanary = "com.squareup.leakcanary:leakcanary-android:2.6"
- const val modern_android_prefs = "de.maxr1998:modernandroidpreferences:2.0"
- const val plumber = "com.squareup.leakcanary:plumber-android:2.6"
- const val sshj = "com.hierynomus:sshj:0.31.0"
- const val ssh_auth = "org.sufficientlysecure:sshauthentication-api:1.0"
- const val timber = "com.jakewharton.timber:timber:4.7.1"
- const val timberkt = "com.github.ajalt:timberkt:1.5.1"
- const val whatthestack = "com.github.haroldadmin:WhatTheStack:0.3.0"
- }
-
- object NonFree {
-
- const val google_play_auth_api_phone = "com.google.android.gms:play-services-auth-api-phone:17.5.0"
- }
-
- object Testing {
-
- const val junit = "junit:junit:4.13.1"
- const val kotlin_test_junit = "org.jetbrains.kotlin:kotlin-test-junit:$KOTLIN_VERSION"
-
- object AndroidX {
-
- private const val version = "1.3.1-alpha03"
- const val runner = "androidx.test:runner:$version"
- const val rules = "androidx.test:rules:$version"
- }
+ private const val version = "1.3.1-alpha03"
+ const val runner = "androidx.test:runner:$version"
+ const val rules = "androidx.test:rules:$version"
}
+ }
}
diff --git a/buildSrc/src/main/java/KotlinCompilerArgs.kt b/buildSrc/src/main/java/KotlinCompilerArgs.kt
index 37d8edbd..fed92c22 100644
--- a/buildSrc/src/main/java/KotlinCompilerArgs.kt
+++ b/buildSrc/src/main/java/KotlinCompilerArgs.kt
@@ -3,6 +3,4 @@
* SPDX-License-Identifier: GPL-3.0-only
*/
-internal val additionalCompilerArgs = listOf(
- "-Xopt-in=kotlin.RequiresOptIn"
-)
+internal val additionalCompilerArgs = listOf("-Xopt-in=kotlin.RequiresOptIn")
diff --git a/buildSrc/src/main/java/Ktfmt.kt b/buildSrc/src/main/java/Ktfmt.kt
index 9f134274..49a90a06 100644
--- a/buildSrc/src/main/java/Ktfmt.kt
+++ b/buildSrc/src/main/java/Ktfmt.kt
@@ -6,6 +6,6 @@
import com.ncorti.ktfmt.gradle.KtfmtExtension
fun KtfmtExtension.configureKtfmt() {
- googleStyle()
- maxWidth.set(120)
+ googleStyle()
+ maxWidth.set(120)
}
diff --git a/buildSrc/src/main/java/PasswordStorePlugin.kt b/buildSrc/src/main/java/PasswordStorePlugin.kt
index a61aa210..5d2d5dd9 100644
--- a/buildSrc/src/main/java/PasswordStorePlugin.kt
+++ b/buildSrc/src/main/java/PasswordStorePlugin.kt
@@ -19,36 +19,39 @@ import org.gradle.kotlin.dsl.withType
class PasswordStorePlugin : Plugin<Project> {
- override fun apply(project: Project) {
- project.configureForAllProjects()
+ override fun apply(project: Project) {
+ project.configureForAllProjects()
- if (project.isRoot) {
- project.configureForRootProject()
- }
+ if (project.isRoot) {
+ project.configureForRootProject()
+ }
- project.plugins.all {
- when (this) {
- is JavaPlugin,
- is JavaLibraryPlugin -> {
- project.tasks.withType<JavaCompile> {
- options.compilerArgs.add("-Xlint:unchecked")
- options.isDeprecation = true
- }
- }
- is LibraryPlugin -> {
- project.extensions.getByType<TestedExtension>().configureCommonAndroidOptions()
- }
- is AppPlugin -> {
- project.extensions.getByType<BaseAppModuleExtension>().configureAndroidApplicationOptions(project)
- project.extensions.getByType<BaseAppModuleExtension>().configureBuildSigning(project)
- project.extensions.getByType<TestedExtension>().configureCommonAndroidOptions()
- }
- is KtfmtPlugin -> {
- project.extensions.getByType<KtfmtExtension>().configureKtfmt()
- }
- }
+ project.plugins.all {
+ when (this) {
+ is JavaPlugin, is JavaLibraryPlugin -> {
+ project.tasks.withType<JavaCompile> {
+ options.compilerArgs.add("-Xlint:unchecked")
+ options.isDeprecation = true
+ }
+ }
+ is LibraryPlugin -> {
+ project.extensions.getByType<TestedExtension>().configureCommonAndroidOptions()
+ }
+ is AppPlugin -> {
+ project
+ .extensions
+ .getByType<BaseAppModuleExtension>()
+ .configureAndroidApplicationOptions(project)
+ project.extensions.getByType<BaseAppModuleExtension>().configureBuildSigning(project)
+ project.extensions.getByType<TestedExtension>().configureCommonAndroidOptions()
+ }
+ is KtfmtPlugin -> {
+ project.extensions.getByType<KtfmtExtension>().configureKtfmt()
}
+ }
}
+ }
}
-private val Project.isRoot get() = this == this.rootProject
+private val Project.isRoot
+ get() = this == this.rootProject
diff --git a/buildSrc/src/main/java/SigningConfig.kt b/buildSrc/src/main/java/SigningConfig.kt
index c1abc161..eaa7433c 100644
--- a/buildSrc/src/main/java/SigningConfig.kt
+++ b/buildSrc/src/main/java/SigningConfig.kt
@@ -9,26 +9,24 @@ import org.gradle.api.Project
private const val KEYSTORE_CONFIG_PATH = "keystore.properties"
-/**
- * Configure signing for all build types.
- */
+/** Configure signing for all build types. */
@Suppress("UnstableApiUsage")
internal fun BaseAppModuleExtension.configureBuildSigning(project: Project) {
- with(project) {
- val keystoreConfigFile = rootProject.layout.projectDirectory.file(KEYSTORE_CONFIG_PATH)
- if (!keystoreConfigFile.asFile.exists()) return
- val contents = providers.fileContents(keystoreConfigFile).asText.forUseAtConfigurationTime()
- val keystoreProperties = Properties()
- keystoreProperties.load(contents.get().byteInputStream())
- signingConfigs {
- register("release") {
- keyAlias = keystoreProperties["keyAlias"] as String
- keyPassword = keystoreProperties["keyPassword"] as String
- storeFile = rootProject.file(keystoreProperties["storeFile"] as String)
- storePassword = keystoreProperties["storePassword"] as String
- }
- }
- val signingConfig = signingConfigs.getByName("release")
- buildTypes.all { setSigningConfig(signingConfig) }
+ with(project) {
+ val keystoreConfigFile = rootProject.layout.projectDirectory.file(KEYSTORE_CONFIG_PATH)
+ if (!keystoreConfigFile.asFile.exists()) return
+ val contents = providers.fileContents(keystoreConfigFile).asText.forUseAtConfigurationTime()
+ val keystoreProperties = Properties()
+ keystoreProperties.load(contents.get().byteInputStream())
+ signingConfigs {
+ register("release") {
+ keyAlias = keystoreProperties["keyAlias"] as String
+ keyPassword = keystoreProperties["keyPassword"] as String
+ storeFile = rootProject.file(keystoreProperties["storeFile"] as String)
+ storePassword = keystoreProperties["storePassword"] as String
+ }
}
+ val signingConfig = signingConfigs.getByName("release")
+ buildTypes.all { setSigningConfig(signingConfig) }
+ }
}
diff --git a/buildSrc/src/main/java/VersioningPlugin.kt b/buildSrc/src/main/java/VersioningPlugin.kt
index a2c9ff81..f05aa34e 100644
--- a/buildSrc/src/main/java/VersioningPlugin.kt
+++ b/buildSrc/src/main/java/VersioningPlugin.kt
@@ -3,7 +3,6 @@
* SPDX-License-Identifier: GPL-3.0-only
*/
-
import com.android.build.gradle.internal.plugins.AppPlugin
import com.vdurmont.semver4j.Semver
import java.io.OutputStream
@@ -14,98 +13,94 @@ import org.gradle.api.Project
private const val VERSIONING_PROP_FILE = "version.properties"
private const val VERSIONING_PROP_VERSION_NAME = "versioning-plugin.versionName"
private const val VERSIONING_PROP_VERSION_CODE = "versioning-plugin.versionCode"
-private const val VERSIONING_PROP_COMMENT = """
+private const val VERSIONING_PROP_COMMENT =
+ """
This file was automatically generated by 'versioning-plugin'. DO NOT EDIT MANUALLY.
"""
/**
* A Gradle [Plugin] that takes a [Project] with the [AppPlugin] applied and dynamically sets the
* versionCode and versionName properties based on values read from a [VERSIONING_PROP_FILE] file in
- * the [Project.getBuildDir] directory. It also adds Gradle tasks to bump the major, minor, and patch
- * versions along with one to prepare the next snapshot.
+ * the [Project.getBuildDir] directory. It also adds Gradle tasks to bump the major, minor, and
+ * patch versions along with one to prepare the next snapshot.
*/
-@Suppress(
- "UnstableApiUsage",
- "NAME_SHADOWING"
-)
+@Suppress("UnstableApiUsage", "NAME_SHADOWING")
class VersioningPlugin : Plugin<Project> {
- /**
- * Generate the Android 'versionCode' property
- */
- private fun Semver.androidCode(): Int {
- return major * 1_00_00 +
- minor * 1_00 +
- patch
- }
+ /** Generate the Android 'versionCode' property */
+ private fun Semver.androidCode(): Int {
+ return major * 1_00_00 + minor * 1_00 + patch
+ }
- /**
- * Write an Android-specific variant of [this] to [stream]
- */
- private fun Semver.writeForAndroid(stream: OutputStream) {
- val newVersionCode = androidCode()
- val props = Properties()
- props.setProperty(VERSIONING_PROP_VERSION_CODE, "$newVersionCode")
- props.setProperty(VERSIONING_PROP_VERSION_NAME, toString())
- props.store(stream, VERSIONING_PROP_COMMENT)
- }
+ /** Write an Android-specific variant of [this] to [stream] */
+ private fun Semver.writeForAndroid(stream: OutputStream) {
+ val newVersionCode = androidCode()
+ val props = Properties()
+ props.setProperty(VERSIONING_PROP_VERSION_CODE, "$newVersionCode")
+ props.setProperty(VERSIONING_PROP_VERSION_NAME, toString())
+ props.store(stream, VERSIONING_PROP_COMMENT)
+ }
- override fun apply(project: Project) {
- with(project) {
- val appPlugin = requireNotNull(plugins.findPlugin(AppPlugin::class.java)) {
- "Plugin 'com.android.application' must be applied to use this plugin"
- }
- val propFile = layout.projectDirectory.file(VERSIONING_PROP_FILE)
- require(propFile.asFile.exists()) {
- "A 'version.properties' file must exist in the project subdirectory to use this plugin"
- }
- val contents = providers.fileContents(propFile).asText.forUseAtConfigurationTime()
- val versionProps = Properties().also { it.load(contents.get().byteInputStream()) }
- val versionName = requireNotNull(versionProps.getProperty(VERSIONING_PROP_VERSION_NAME)) {
- "version.properties must contain a '$VERSIONING_PROP_VERSION_NAME' property"
- }
- val versionCode = requireNotNull(versionProps.getProperty(VERSIONING_PROP_VERSION_CODE).toInt()) {
- "version.properties must contain a '$VERSIONING_PROP_VERSION_CODE' property"
- }
- appPlugin.extension.defaultConfig.versionName = versionName
- appPlugin.extension.defaultConfig.versionCode = versionCode
- afterEvaluate {
- val version = Semver(versionName)
- tasks.register("clearPreRelease") {
- doLast {
- version.withClearedSuffix()
- .writeForAndroid(propFile.asFile.outputStream())
- }
- }
- tasks.register("bumpMajor") {
- doLast {
- version.withIncMajor()
- .withClearedSuffix()
- .writeForAndroid(propFile.asFile.outputStream())
- }
- }
- tasks.register("bumpMinor") {
- doLast {
- version.withIncMinor()
- .withClearedSuffix()
- .writeForAndroid(propFile.asFile.outputStream())
- }
- }
- tasks.register("bumpPatch") {
- doLast {
- version.withIncPatch()
- .withClearedSuffix()
- .writeForAndroid(propFile.asFile.outputStream())
- }
- }
- tasks.register("bumpSnapshot") {
- doLast {
- version.withIncMinor()
- .withSuffix("SNAPSHOT")
- .writeForAndroid(propFile.asFile.outputStream())
- }
- }
- }
+ override fun apply(project: Project) {
+ with(project) {
+ val appPlugin =
+ requireNotNull(plugins.findPlugin(AppPlugin::class.java)) {
+ "Plugin 'com.android.application' must be applied to use this plugin"
+ }
+ val propFile = layout.projectDirectory.file(VERSIONING_PROP_FILE)
+ require(propFile.asFile.exists()) {
+ "A 'version.properties' file must exist in the project subdirectory to use this plugin"
+ }
+ val contents = providers.fileContents(propFile).asText.forUseAtConfigurationTime()
+ val versionProps = Properties().also { it.load(contents.get().byteInputStream()) }
+ val versionName =
+ requireNotNull(versionProps.getProperty(VERSIONING_PROP_VERSION_NAME)) {
+ "version.properties must contain a '$VERSIONING_PROP_VERSION_NAME' property"
+ }
+ val versionCode =
+ requireNotNull(versionProps.getProperty(VERSIONING_PROP_VERSION_CODE).toInt()) {
+ "version.properties must contain a '$VERSIONING_PROP_VERSION_CODE' property"
+ }
+ appPlugin.extension.defaultConfig.versionName = versionName
+ appPlugin.extension.defaultConfig.versionCode = versionCode
+ afterEvaluate {
+ val version = Semver(versionName)
+ tasks.register("clearPreRelease") {
+ doLast { version.withClearedSuffix().writeForAndroid(propFile.asFile.outputStream()) }
+ }
+ tasks.register("bumpMajor") {
+ doLast {
+ version
+ .withIncMajor()
+ .withClearedSuffix()
+ .writeForAndroid(propFile.asFile.outputStream())
+ }
+ }
+ tasks.register("bumpMinor") {
+ doLast {
+ version
+ .withIncMinor()
+ .withClearedSuffix()
+ .writeForAndroid(propFile.asFile.outputStream())
+ }
+ }
+ tasks.register("bumpPatch") {
+ doLast {
+ version
+ .withIncPatch()
+ .withClearedSuffix()
+ .writeForAndroid(propFile.asFile.outputStream())
+ }
+ }
+ tasks.register("bumpSnapshot") {
+ doLast {
+ version
+ .withIncMinor()
+ .withSuffix("SNAPSHOT")
+ .writeForAndroid(propFile.asFile.outputStream())
+ }
}
+ }
}
+ }
}