aboutsummaryrefslogtreecommitdiff
path: root/build-logic
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2024-03-22 00:08:20 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2024-03-22 00:43:04 +0530
commitb05c71fc35ae530894e5134a4f92ccdfa793c27b (patch)
tree89c323b58e89128d104f63e43a5127eacdce0309 /build-logic
parent93ee16df3827cc8cee1029a0c6b70a4d1db8f94d (diff)
feat(build): add back dependency updates plugin
Diffstat (limited to 'build-logic')
-rw-r--r--build-logic/build.gradle.kts5
-rw-r--r--build-logic/src/main/kotlin/app/passwordstore/gradle/DependencyUpdatesPlugin.kt34
2 files changed, 39 insertions, 0 deletions
diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts
index 877d6752..4917fc8c 100644
--- a/build-logic/build.gradle.kts
+++ b/build-logic/build.gradle.kts
@@ -65,6 +65,10 @@ gradlePlugin {
id = "com.github.android-password-store.versioning-plugin"
implementationClass = "app.passwordstore.gradle.versioning.VersioningPlugin"
}
+ register("versions") {
+ id = "com.github.android-password-store.versions"
+ implementationClass = "app.passwordstore.gradle.DependencyUpdatesPlugin"
+ }
}
}
@@ -84,6 +88,7 @@ dependencies {
implementation(libs.build.r8)
implementation(libs.build.semver)
implementation(libs.build.sentry)
+ implementation(libs.build.vcu)
implementation(libs.kotlinx.coroutines.core)
// Expose the generated version catalog API to the plugin.
diff --git a/build-logic/src/main/kotlin/app/passwordstore/gradle/DependencyUpdatesPlugin.kt b/build-logic/src/main/kotlin/app/passwordstore/gradle/DependencyUpdatesPlugin.kt
new file mode 100644
index 00000000..cac23ee2
--- /dev/null
+++ b/build-logic/src/main/kotlin/app/passwordstore/gradle/DependencyUpdatesPlugin.kt
@@ -0,0 +1,34 @@
+/*
+ * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+package app.passwordstore.gradle
+
+import com.github.zafarkhaja.semver.Version
+import kotlin.jvm.optionals.getOrNull
+import nl.littlerobots.vcu.plugin.VersionCatalogUpdateExtension
+import nl.littlerobots.vcu.plugin.VersionCatalogUpdatePlugin
+import nl.littlerobots.vcu.plugin.versionSelector
+import org.gradle.api.Plugin
+import org.gradle.api.Project
+import org.gradle.kotlin.dsl.apply
+import org.gradle.kotlin.dsl.configure
+
+@Suppress("Unused")
+class DependencyUpdatesPlugin : Plugin<Project> {
+ override fun apply(project: Project) {
+ project.pluginManager.apply(VersionCatalogUpdatePlugin::class)
+ project.extensions.configure<VersionCatalogUpdateExtension> {
+ keep.keepUnusedLibraries.set(true)
+ versionSelector {
+ val currentVersion = Version.tryParse(it.currentVersion).getOrNull()
+ val newVersion = Version.tryParse(it.candidate.version).getOrNull()
+ if (currentVersion == null || newVersion == null) {
+ false
+ } else {
+ newVersion.isHigherThan(currentVersion)
+ }
+ }
+ }
+ }
+}