refactor(build): move dependency updates to a Settings plugin

This commit is contained in:
Harsh Shandilya 2023-07-12 15:24:40 +05:30
parent 79773dbd7a
commit ae9f56e965
No known key found for this signature in database
3 changed files with 27 additions and 18 deletions

View file

@ -5,29 +5,31 @@ import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import nl.littlerobots.vcu.plugin.VersionCatalogUpdateExtension import nl.littlerobots.vcu.plugin.VersionCatalogUpdateExtension
import nl.littlerobots.vcu.plugin.VersionCatalogUpdatePlugin import nl.littlerobots.vcu.plugin.VersionCatalogUpdatePlugin
import org.gradle.api.Plugin 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.apply
import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.withType import org.gradle.kotlin.dsl.withType
@Suppress("Unused") @Suppress("Unused")
class DependencyUpdatesPlugin : Plugin<Project> { class DependencyUpdatesPlugin : Plugin<Settings> {
override fun apply(project: Project) { override fun apply(settings: Settings) {
project.pluginManager.apply(VersionsPlugin::class) settings.gradle.allprojects {
project.pluginManager.apply(VersionCatalogUpdatePlugin::class) if (rootProject == this) {
project.tasks.withType<DependencyUpdatesTask> { pluginManager.apply(VersionCatalogUpdatePlugin::class)
rejectVersionIf { extensions.configure<VersionCatalogUpdateExtension> { keep.keepUnusedLibraries.set(true) }
when (candidate.group) { pluginManager.apply(VersionsPlugin::class)
"commons-codec", tasks.withType<DependencyUpdatesTask> {
"org.eclipse.jgit" -> true rejectVersionIf {
else -> false when (candidate.group) {
"commons-codec",
"org.eclipse.jgit" -> true
else -> false
}
}
checkForGradleUpdate = false
} }
} }
checkForGradleUpdate = false
}
project.extensions.configure<VersionCatalogUpdateExtension> {
keep.keepUnusedLibraries.set(true)
} }
} }
} }

View file

@ -6,6 +6,5 @@ plugins {
id("com.github.android-password-store.git-hooks") id("com.github.android-password-store.git-hooks")
id("com.github.android-password-store.kotlin-common") id("com.github.android-password-store.kotlin-common")
id("com.github.android-password-store.ktfmt") id("com.github.android-password-store.ktfmt")
id("com.github.android-password-store.versions")
alias(libs.plugins.hilt) apply false alias(libs.plugins.hilt) apply false
} }

View file

@ -8,7 +8,6 @@ rootProject.name = "APS"
// Plugin repositories // Plugin repositories
pluginManagement { pluginManagement {
plugins { id("org.gradle.toolchains.foojay-resolver-convention") version "0.6.0" }
repositories { repositories {
includeBuild("build-logic") includeBuild("build-logic")
exclusiveContent { exclusiveContent {
@ -43,6 +42,11 @@ pluginManagement {
includeModule("com.gradle", "gradle-enterprise-gradle-plugin") includeModule("com.gradle", "gradle-enterprise-gradle-plugin")
includeModule("com.gradle.enterprise", "com.gradle.enterprise.gradle.plugin") includeModule("com.gradle.enterprise", "com.gradle.enterprise.gradle.plugin")
includeModule("me.tylerbwong.gradle.metalava", "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 { 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 { gradleEnterprise {
buildScan { buildScan {