diff options
Diffstat (limited to 'build-logic/src/main')
-rw-r--r-- | build-logic/src/main/kotlin/app/passwordstore/gradle/DependencyUpdatesPlugin.kt | 34 |
1 files changed, 34 insertions, 0 deletions
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) + } + } + } + } +} |