diff options
author | Harsh Shandilya <me@msfjarvis.dev> | 2022-06-30 21:33:59 +0530 |
---|---|---|
committer | Harsh Shandilya <me@msfjarvis.dev> | 2022-07-07 11:28:58 +0530 |
commit | 8a9ebf3f7e0af5f7a7ccd67b6902a94b0d8c687b (patch) | |
tree | 5c9598f92fc6321acab66d37f7c93e444bcbc532 | |
parent | 83fc3e6b874865a44be339ff363776e58d9ad8fe (diff) |
build-logic: introduce versions plugin
-rw-r--r-- | build-logic/kotlin-plugins/build.gradle.kts | 6 | ||||
-rw-r--r-- | build-logic/kotlin-plugins/src/main/kotlin/dev/msfjarvis/aps/gradle/DependencyUpdatesPlugin.kt | 33 | ||||
-rw-r--r-- | build-logic/settings.gradle.kts | 4 | ||||
-rw-r--r-- | build.gradle.kts | 1 | ||||
-rw-r--r-- | gradle/libs.versions.toml | 2 | ||||
-rw-r--r-- | settings.gradle.kts | 1 |
6 files changed, 47 insertions, 0 deletions
diff --git a/build-logic/kotlin-plugins/build.gradle.kts b/build-logic/kotlin-plugins/build.gradle.kts index bfd54dc0..78359ea6 100644 --- a/build-logic/kotlin-plugins/build.gradle.kts +++ b/build-logic/kotlin-plugins/build.gradle.kts @@ -50,6 +50,10 @@ gradlePlugin { id = "com.github.android-password-store.spotless" implementationClass = "dev.msfjarvis.aps.gradle.SpotlessPlugin" } + register("versions") { + id = "com.github.android-password-store.versions" + implementationClass = "dev.msfjarvis.aps.gradle.DependencyUpdatesPlugin" + } } } @@ -58,4 +62,6 @@ dependencies { implementation(libs.build.binarycompat) implementation(libs.build.kotlin) implementation(libs.build.spotless) + implementation(libs.build.vcu) + implementation(libs.build.versions) } diff --git a/build-logic/kotlin-plugins/src/main/kotlin/dev/msfjarvis/aps/gradle/DependencyUpdatesPlugin.kt b/build-logic/kotlin-plugins/src/main/kotlin/dev/msfjarvis/aps/gradle/DependencyUpdatesPlugin.kt new file mode 100644 index 00000000..e3d6e761 --- /dev/null +++ b/build-logic/kotlin-plugins/src/main/kotlin/dev/msfjarvis/aps/gradle/DependencyUpdatesPlugin.kt @@ -0,0 +1,33 @@ +package dev.msfjarvis.aps.gradle + +import com.github.benmanes.gradle.versions.VersionsPlugin +import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask +import nl.littlerobots.vcu.plugin.VersionCatalogUpdateExtension +import nl.littlerobots.vcu.plugin.VersionCatalogUpdatePlugin +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.getByType +import org.gradle.kotlin.dsl.withType + +@Suppress("Unused") +class DependencyUpdatesPlugin : Plugin<Project> { + override fun apply(project: Project) { + project.pluginManager.apply(VersionsPlugin::class) + project.pluginManager.apply(VersionCatalogUpdatePlugin::class) + project.tasks.withType<DependencyUpdatesTask>().configureEach { + rejectVersionIf { + when (candidate.group) { + "commons-codec", + "com.android.tools.build", + "org.eclipse.jgit" -> true + else -> false + } + } + checkForGradleUpdate = false + } + project.extensions.getByType<VersionCatalogUpdateExtension>().run { + keep.keepUnusedLibraries.set(true) + } + } +} diff --git a/build-logic/settings.gradle.kts b/build-logic/settings.gradle.kts index be6946c3..f4d7dc57 100644 --- a/build-logic/settings.gradle.kts +++ b/build-logic/settings.gradle.kts @@ -25,6 +25,10 @@ dependencyResolutionManagement { includeGroup("com.google.testing.platform") } } + exclusiveContent { + forRepository(::gradlePluginPortal) + filter { includeModule("com.github.ben-manes", "gradle-versions-plugin") } + } mavenCentral() } versionCatalogs { diff --git a/build.gradle.kts b/build.gradle.kts index 5a278514..9b77f32d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,5 +9,6 @@ plugins { id("com.github.android-password-store.binary-compatibility") id("com.github.android-password-store.git-hooks") id("com.github.android-password-store.spotless") + id("com.github.android-password-store.versions") alias(libs.plugins.hilt) apply false } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index bd9b8e06..2690aaa1 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -47,6 +47,8 @@ build-okhttp = "com.squareup.okhttp3:okhttp:4.10.0" build-semver = "com.vdurmont:semver4j:3.1.0" build-sentry = "io.sentry.android.gradle:io.sentry.android.gradle.gradle.plugin:3.1.2" build-spotless = "com.diffplug.spotless:spotless-plugin-gradle:6.8.0" +build-vcu = "nl.littlerobots.version-catalog-update:nl.littlerobots.version-catalog-update.gradle.plugin:0.5.1" +build-versions = "com.github.ben-manes:gradle-versions-plugin:0.42.0" dagger-hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "hilt" } dagger-hilt-compiler = { module = "com.google.dagger:hilt-compiler", version.ref = "hilt" } diff --git a/settings.gradle.kts b/settings.gradle.kts index 0838f6e6..36e36935 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -30,6 +30,7 @@ pluginManagement { exclusiveContent { forRepository(::gradlePluginPortal) filter { + includeModule("com.github.ben-manes", "gradle-versions-plugin") includeModule("com.gradle", "gradle-enterprise-gradle-plugin") includeModule("com.gradle.enterprise", "com.gradle.enterprise.gradle.plugin") } |