aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/pull_request.yml54
-rw-r--r--app/version.properties8
-rw-r--r--build-logic/android-plugins/src/main/kotlin/versioning/Constants.kt14
-rw-r--r--build-logic/android-plugins/src/main/kotlin/versioning/VersioningPlugin.kt71
-rw-r--r--build-logic/android-plugins/src/main/kotlin/versioning/VersioningTask.kt46
-rw-r--r--build-logic/automation-plugins/src/main/kotlin/psl/PSLUpdateTask.kt46
-rw-r--r--build-logic/automation-plugins/src/main/kotlin/psl/PublicSuffixListPlugin.kt39
-rw-r--r--build-logic/kotlin-plugins/build.gradle.kts1
-rw-r--r--build-logic/kotlin-plugins/src/main/kotlin/com.github.android-password-store.kotlin-library.gradle.kts13
-rw-r--r--gradle/libs.versions.toml1
10 files changed, 132 insertions, 161 deletions
diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml
index 4482384a..faf39eb9 100644
--- a/.github/workflows/pull_request.yml
+++ b/.github/workflows/pull_request.yml
@@ -188,57 +188,3 @@ jobs:
uses: gradle/gradle-build-action@v2.1.3
with:
arguments: lintDebug
-
- code-coverage:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout repository
- uses: actions/checkout@v2.4.0
- with:
- fetch-depth: 0
-
- - name: Check if relevant files have changed
- uses: actions/github-script@v5.1.0
- id: service-changed
- with:
- result-encoding: string
- script: |
- const script = require('.github/check-changed-files.js')
- return await script({github, context})
-
- - name: Set up JDK
- if: ${{ steps.service-changed.outputs.result == 'true' }}
- uses : actions/setup-java@v2.4.0
- with :
- distribution : 'zulu'
- java-version : '17'
- cache: 'gradle'
-
- - name: Copy CI gradle.properties
- if: ${{ steps.service-changed.outputs.result == 'true' }}
- run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
-
- - name: Generate coverage reports with kotlinx-kover
- if: ${{ steps.service-changed.outputs.result == 'true' }}
- uses: gradle/gradle-build-action@v2.1.3
- with:
- arguments: koverXmlReport
-
- - name: Export coverage XMLs
- if: ${{ steps.service-changed.outputs.result == 'true' }}
- id: coverage-export
- shell: bash
- run: |
- REPORTS="$(find ./build/coverage-reports/ -maxdepth 1 -type f -printf "${GITHUB_WORKSPACE}/%p," -name "*.xml")"
- REPORTS="${REPORTS::${#REPORTS}-1}"
- echo ::set-output name=REPORT_PATHS::${REPORTS}
-
- - name: Publish JaCoCo report to PR
- if: false
- uses: madrapps/jacoco-report@v1.2
- with:
- paths: ${{ steps.coverage-export.outputs.REPORT_PATHS }}
- token: ${{ secrets.GITHUB_TOKEN }}
- min-coverage-overall: 0
- min-coverage-changed-files: 40
- title: Code Coverage
diff --git a/app/version.properties b/app/version.properties
index f0b5b26a..784adb1b 100644
--- a/app/version.properties
+++ b/app/version.properties
@@ -1,11 +1,5 @@
#
-# Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
-# SPDX-License-Identifier: GPL-3.0-only
+# This file was automatically generated by 'versioning-plugin'. DO NOT EDIT MANUALLY.
#
-
-#
-#This file was automatically generated by 'versioning-plugin'. DO NOT EDIT MANUALLY.
-#
-#Sun Jan 17 12:32:03 IST 2021
versioning-plugin.versionCode=20000
versioning-plugin.versionName=2.0.0-SNAPSHOT
diff --git a/build-logic/android-plugins/src/main/kotlin/versioning/Constants.kt b/build-logic/android-plugins/src/main/kotlin/versioning/Constants.kt
new file mode 100644
index 00000000..000f5438
--- /dev/null
+++ b/build-logic/android-plugins/src/main/kotlin/versioning/Constants.kt
@@ -0,0 +1,14 @@
+/*
+ * Copyright © 2014-2022 The Android Password Store Authors. All Rights Reserved.
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+
+package versioning
+
+const val VERSIONING_PROP_FILE = "version.properties"
+const val VERSIONING_PROP_VERSION_NAME = "versioning-plugin.versionName"
+const val VERSIONING_PROP_VERSION_CODE = "versioning-plugin.versionCode"
+const val VERSIONING_PROP_COMMENT =
+ """#
+# This file was automatically generated by 'versioning-plugin'. DO NOT EDIT MANUALLY.
+#"""
diff --git a/build-logic/android-plugins/src/main/kotlin/versioning/VersioningPlugin.kt b/build-logic/android-plugins/src/main/kotlin/versioning/VersioningPlugin.kt
index 3083921f..5d838b63 100644
--- a/build-logic/android-plugins/src/main/kotlin/versioning/VersioningPlugin.kt
+++ b/build-logic/android-plugins/src/main/kotlin/versioning/VersioningPlugin.kt
@@ -7,18 +7,10 @@ package versioning
import com.android.build.gradle.internal.plugins.AppPlugin
import com.vdurmont.semver4j.Semver
-import java.io.OutputStream
import java.util.Properties
import org.gradle.api.Plugin
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 =
- """
-This file was automatically generated by 'versioning-plugin'. DO NOT EDIT MANUALLY.
-"""
+import org.gradle.kotlin.dsl.register
/**
* A Gradle [Plugin] that takes a [Project] with the [AppPlugin] applied and dynamically sets the
@@ -26,23 +18,9 @@ This file was automatically generated by 'versioning-plugin'. DO NOT EDIT MANUAL
* 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", "Unused")
class VersioningPlugin : Plugin<Project> {
- /** 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)
- }
-
override fun apply(project: Project) {
with(project) {
val appPlugin =
@@ -67,40 +45,25 @@ class VersioningPlugin : Plugin<Project> {
appPlugin.extension.defaultConfig.versionCode = versionCode
afterEvaluate {
val version = Semver(versionName)
- tasks.register("clearPreRelease") {
- doLast { version.withClearedSuffix().writeForAndroid(propFile.asFile.outputStream()) }
+ tasks.register<VersioningTask>("clearPreRelease") {
+ semverString.set(version.withClearedSuffix().toString())
+ propertyFile.set(propFile)
}
- tasks.register("bumpMajor") {
- doLast {
- version
- .withIncMajor()
- .withClearedSuffix()
- .writeForAndroid(propFile.asFile.outputStream())
- }
+ tasks.register<VersioningTask>("bumpMajor") {
+ semverString.set(version.withIncMajor().withClearedSuffix().toString())
+ propertyFile.set(propFile)
}
- tasks.register("bumpMinor") {
- doLast {
- version
- .withIncMinor()
- .withClearedSuffix()
- .writeForAndroid(propFile.asFile.outputStream())
- }
+ tasks.register<VersioningTask>("bumpMinor") {
+ semverString.set(version.withIncMinor().withClearedSuffix().toString())
+ propertyFile.set(propFile)
}
- tasks.register("bumpPatch") {
- doLast {
- version
- .withIncPatch()
- .withClearedSuffix()
- .writeForAndroid(propFile.asFile.outputStream())
- }
+ tasks.register<VersioningTask>("bumpPatch") {
+ semverString.set(version.withIncPatch().withClearedSuffix().toString())
+ propertyFile.set(propFile)
}
- tasks.register("bumpSnapshot") {
- doLast {
- version
- .withIncMinor()
- .withSuffix("SNAPSHOT")
- .writeForAndroid(propFile.asFile.outputStream())
- }
+ tasks.register<VersioningTask>("bumpSnapshot") {
+ semverString.set(version.withIncMinor().withSuffix("SNAPSHOT").toString())
+ propertyFile.set(propFile)
}
}
}
diff --git a/build-logic/android-plugins/src/main/kotlin/versioning/VersioningTask.kt b/build-logic/android-plugins/src/main/kotlin/versioning/VersioningTask.kt
new file mode 100644
index 00000000..fe437c04
--- /dev/null
+++ b/build-logic/android-plugins/src/main/kotlin/versioning/VersioningTask.kt
@@ -0,0 +1,46 @@
+/*
+ * Copyright © 2014-2022 The Android Password Store Authors. All Rights Reserved.
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+
+package versioning
+
+import com.vdurmont.semver4j.Semver
+import org.gradle.api.DefaultTask
+import org.gradle.api.file.RegularFileProperty
+import org.gradle.api.provider.Property
+import org.gradle.api.tasks.CacheableTask
+import org.gradle.api.tasks.Input
+import org.gradle.api.tasks.OutputFile
+import org.gradle.api.tasks.TaskAction
+
+@CacheableTask
+abstract class VersioningTask : DefaultTask() {
+ @get:Input abstract val semverString: Property<String>
+
+ @get:OutputFile abstract val propertyFile: RegularFileProperty
+
+ /** Generate the Android 'versionCode' property */
+ private fun Semver.androidCode(): Int {
+ return major * 1_00_00 + minor * 1_00 + patch
+ }
+
+ private fun Semver.toPropFileText(): String {
+ val newVersionCode = androidCode()
+ val newVersionName = toString()
+ return buildString {
+ appendLine(VERSIONING_PROP_COMMENT)
+ append(VERSIONING_PROP_VERSION_CODE)
+ append('=')
+ appendLine(newVersionCode)
+ append(VERSIONING_PROP_VERSION_NAME)
+ append('=')
+ appendLine(newVersionName)
+ }
+ }
+
+ @TaskAction
+ fun execute() {
+ propertyFile.get().asFile.writeText(Semver(semverString.get()).toPropFileText())
+ }
+}
diff --git a/build-logic/automation-plugins/src/main/kotlin/psl/PSLUpdateTask.kt b/build-logic/automation-plugins/src/main/kotlin/psl/PSLUpdateTask.kt
new file mode 100644
index 00000000..e8fdc498
--- /dev/null
+++ b/build-logic/automation-plugins/src/main/kotlin/psl/PSLUpdateTask.kt
@@ -0,0 +1,46 @@
+/*
+ * Copyright © 2014-2022 The Android Password Store Authors. All Rights Reserved.
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+
+package psl
+
+import okio.buffer
+import okio.sink
+import org.gradle.api.DefaultTask
+import org.gradle.api.file.RegularFile
+import org.gradle.api.file.RegularFileProperty
+import org.gradle.api.provider.Property
+import org.gradle.api.tasks.CacheableTask
+import org.gradle.api.tasks.Input
+import org.gradle.api.tasks.OutputFile
+import org.gradle.api.tasks.TaskAction
+
+@CacheableTask
+abstract class PSLUpdateTask : DefaultTask() {
+ @get:Input abstract val pslData: Property<PublicSuffixListData>
+ @get:OutputFile abstract val outputFile: RegularFileProperty
+
+ @TaskAction
+ fun updatePSL() {
+ writeListToDisk(outputFile.get(), pslData.get())
+ }
+
+ private fun writeListToDisk(destination: RegularFile, data: PublicSuffixListData) {
+ val fileSink = destination.asFile.sink()
+
+ fileSink.buffer().use { sink ->
+ sink.writeInt(data.totalRuleBytes)
+
+ for (domain in data.sortedRules) {
+ sink.write(domain).writeByte('\n'.toInt())
+ }
+
+ sink.writeInt(data.totalExceptionRuleBytes)
+
+ for (domain in data.sortedExceptionRules) {
+ sink.write(domain).writeByte('\n'.toInt())
+ }
+ }
+ }
+}
diff --git a/build-logic/automation-plugins/src/main/kotlin/psl/PublicSuffixListPlugin.kt b/build-logic/automation-plugins/src/main/kotlin/psl/PublicSuffixListPlugin.kt
index 3c003c53..bc503fde 100644
--- a/build-logic/automation-plugins/src/main/kotlin/psl/PublicSuffixListPlugin.kt
+++ b/build-logic/automation-plugins/src/main/kotlin/psl/PublicSuffixListPlugin.kt
@@ -4,16 +4,15 @@
package psl
-import java.io.File
+import java.io.Serializable
import java.util.TreeSet
import okhttp3.OkHttpClient
import okhttp3.Request
import okio.ByteString
import okio.ByteString.Companion.encodeUtf8
-import okio.buffer
-import okio.sink
import org.gradle.api.Plugin
import org.gradle.api.Project
+import org.gradle.kotlin.dsl.register
/**
* Gradle plugin to update the public suffix list used by the `lib-publicsuffixlist` component.
@@ -23,34 +22,10 @@ import org.gradle.api.Project
*/
class PublicSuffixListPlugin : Plugin<Project> {
override fun apply(project: Project) {
- project.tasks.register("updatePSL") {
- doLast {
- val filename = project.projectDir.absolutePath + "/src/main/assets/publicsuffixes"
- updatePublicSuffixList(filename)
- }
- }
- }
-
- private fun updatePublicSuffixList(destination: String) {
- val list = fetchPublicSuffixList()
- writeListToDisk(destination, list)
- }
-
- private fun writeListToDisk(destination: String, data: PublicSuffixListData) {
- val fileSink = File(destination).sink()
-
- fileSink.buffer().use { sink ->
- sink.writeInt(data.totalRuleBytes)
-
- for (domain in data.sortedRules) {
- sink.write(domain).writeByte('\n'.toInt())
- }
-
- sink.writeInt(data.totalExceptionRuleBytes)
-
- for (domain in data.sortedExceptionRules) {
- sink.write(domain).writeByte('\n'.toInt())
- }
+ project.tasks.register<PSLUpdateTask>("updatePSL") {
+ val list = fetchPublicSuffixList()
+ pslData.set(list)
+ outputFile.set(project.layout.projectDirectory.file("src/main/assets/publicsuffixes"))
}
}
@@ -119,4 +94,4 @@ data class PublicSuffixListData(
var totalExceptionRuleBytes: Int = 0,
val sortedRules: TreeSet<ByteString> = TreeSet(),
val sortedExceptionRules: TreeSet<ByteString> = TreeSet()
-)
+) : Serializable
diff --git a/build-logic/kotlin-plugins/build.gradle.kts b/build-logic/kotlin-plugins/build.gradle.kts
index 8e182d12..5fd5ba0c 100644
--- a/build-logic/kotlin-plugins/build.gradle.kts
+++ b/build-logic/kotlin-plugins/build.gradle.kts
@@ -24,7 +24,6 @@ afterEvaluate {
dependencies {
implementation(libs.build.agp)
implementation(libs.build.binarycompat)
- implementation(libs.build.kover)
implementation(libs.build.kotlin)
implementation(libs.build.spotless)
}
diff --git a/build-logic/kotlin-plugins/src/main/kotlin/com.github.android-password-store.kotlin-library.gradle.kts b/build-logic/kotlin-plugins/src/main/kotlin/com.github.android-password-store.kotlin-library.gradle.kts
index 8dfa887f..516f5e4f 100644
--- a/build-logic/kotlin-plugins/src/main/kotlin/com.github.android-password-store.kotlin-library.gradle.kts
+++ b/build-logic/kotlin-plugins/src/main/kotlin/com.github.android-password-store.kotlin-library.gradle.kts
@@ -6,10 +6,7 @@
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
-plugins {
- id("com.github.android-password-store.kotlin-common")
- id("org.jetbrains.kotlinx.kover")
-}
+plugins { id("com.github.android-password-store.kotlin-common") }
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
@@ -18,11 +15,3 @@ tasks.withType<KotlinCompile>().configureEach {
}
}
}
-
-tasks.koverXmlReport {
- xmlReportFile.set(rootProject.layout.buildDirectory.file("coverage-reports/${project.name}.xml"))
-}
-
-tasks.koverHtmlReport {
- htmlReportDir.set(rootProject.layout.buildDirectory.dir("coverage-reports/${project.name}"))
-}
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 02678722..20df822d 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -40,7 +40,6 @@ aps-zxingAndroidEmbedded = "com.github.android-password-store:zxing-android-embe
build-agp = "com.android.tools.build:gradle:7.1.0"
build-binarycompat = "org.jetbrains.kotlinx:binary-compatibility-validator:0.8.0"
-build-kover = "org.jetbrains.kotlinx:kover:0.5.0"
build-dokka = "org.jetbrains.dokka:dokka-gradle-plugin:1.6.10"
build-download = "de.undercouch:gradle-download-task:5.0.1"
build-hilt = "com.google.dagger:hilt-android-gradle-plugin:2.40.5"