From ae9f56e9657ca55ef6c1bc541950dc9b91495f79 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Wed, 12 Jul 2023 15:24:40 +0530 Subject: refactor(build): move dependency updates to a `Settings` plugin --- .../gradle/DependencyUpdatesPlugin.kt | 32 ++++++++++++---------- build.gradle.kts | 1 - settings.gradle.kts | 12 ++++++-- 3 files changed, 27 insertions(+), 18 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 index 50810938..2880ac1d 100644 --- a/build-logic/src/main/kotlin/app/passwordstore/gradle/DependencyUpdatesPlugin.kt +++ b/build-logic/src/main/kotlin/app/passwordstore/gradle/DependencyUpdatesPlugin.kt @@ -5,29 +5,31 @@ 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.api.initialization.Settings import org.gradle.kotlin.dsl.apply import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.withType @Suppress("Unused") -class DependencyUpdatesPlugin : Plugin { +class DependencyUpdatesPlugin : Plugin { - override fun apply(project: Project) { - project.pluginManager.apply(VersionsPlugin::class) - project.pluginManager.apply(VersionCatalogUpdatePlugin::class) - project.tasks.withType { - rejectVersionIf { - when (candidate.group) { - "commons-codec", - "org.eclipse.jgit" -> true - else -> false + override fun apply(settings: Settings) { + settings.gradle.allprojects { + if (rootProject == this) { + pluginManager.apply(VersionCatalogUpdatePlugin::class) + extensions.configure { keep.keepUnusedLibraries.set(true) } + pluginManager.apply(VersionsPlugin::class) + tasks.withType { + rejectVersionIf { + when (candidate.group) { + "commons-codec", + "org.eclipse.jgit" -> true + else -> false + } + } + checkForGradleUpdate = false } } - checkForGradleUpdate = false - } - project.extensions.configure { - keep.keepUnusedLibraries.set(true) } } } diff --git a/build.gradle.kts b/build.gradle.kts index 450f9faa..26d94616 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,6 +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") alias(libs.plugins.hilt) apply false } diff --git a/settings.gradle.kts b/settings.gradle.kts index ff7fcd8c..5f267c59 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -8,7 +8,6 @@ rootProject.name = "APS" // Plugin repositories pluginManagement { - plugins { id("org.gradle.toolchains.foojay-resolver-convention") version "0.6.0" } repositories { includeBuild("build-logic") exclusiveContent { @@ -43,6 +42,11 @@ pluginManagement { includeModule("com.gradle", "gradle-enterprise-gradle-plugin") includeModule("com.gradle.enterprise", "com.gradle.enterprise.gradle.plugin") includeModule("me.tylerbwong.gradle.metalava", "plugin") + includeModule( + "org.gradle.toolchains.foojay-resolver-convention", + "org.gradle.toolchains.foojay-resolver-convention.gradle.plugin", + ) + includeModule("org.gradle.toolchains", "foojay-resolver") } } exclusiveContent { @@ -53,7 +57,11 @@ pluginManagement { } } -plugins { id("com.gradle.enterprise") version "3.13.4" } +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version "0.6.0" + id("com.gradle.enterprise") version "3.13.4" + id("com.github.android-password-store.versions") +} gradleEnterprise { buildScan { -- cgit v1.2.3