diff options
-rw-r--r-- | build-logic/build.gradle.kts | 5 | ||||
-rw-r--r-- | build-logic/src/main/kotlin/app/passwordstore/gradle/DependencyUpdatesPlugin.kt | 34 | ||||
-rw-r--r-- | build.gradle.kts | 1 | ||||
-rw-r--r-- | gradle.properties | 6 | ||||
-rw-r--r-- | gradle/libs.versions.toml | 1 |
5 files changed, 47 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) + } + } + } + } +} diff --git a/build.gradle.kts b/build.gradle.kts index 5a688c54..aac6cf2b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,4 +6,5 @@ plugins { id("com.github.android-password-store.git-hooks") id("com.github.android-password-store.kotlin-common") id("com.github.android-password-store.ktfmt") + id("com.github.android-password-store.versions") } diff --git a/gradle.properties b/gradle.properties index 6f1f929c..d1acfafb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -58,3 +58,9 @@ SONATYPE_CONNECT_TIMEOUT_SECONDS=120 SONATYPE_CLOSE_TIMEOUT_SECONDS=1800 org.gradle.jvmargs=-Xmx4096m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 + +# Version Catalog Update Plugin workarounds and fixes +systemProp.javax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl +systemProp.javax.xml.transform.TransformerFactory=com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl +systemProp.javax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl +nl.littlerobots.vcu.resolver=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7426ed21..7924c4bb 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -50,6 +50,7 @@ build-okhttp = "com.squareup.okhttp3:okhttp:4.12.0" build-r8 = "com.android.tools:r8:8.3.37" build-semver = "com.github.zafarkhaja:java-semver:0.10.2" build-sentry = "io.sentry.android.gradle:io.sentry.android.gradle.gradle.plugin:4.3.1" +build-vcu = "nl.littlerobots.version-catalog-update:nl.littlerobots.version-catalog-update.gradle.plugin:0.8.4" compose-bom = "androidx.compose:compose-bom:2024.03.00" compose-foundation-core = { module = "androidx.compose.foundation:foundation" } compose-foundation-layout = { module = "androidx.compose.foundation:foundation-layout" } |