Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit ae9f56e

Browse files
committed
refactor(build): move dependency updates to a Settings plugin
1 parent 79773db commit ae9f56e

File tree

3 files changed

+27
-18
lines changed

3 files changed

+27
-18
lines changed

build-logic/src/main/kotlin/app/passwordstore/gradle/DependencyUpdatesPlugin.kt

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,31 @@ import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
55
import nl.littlerobots.vcu.plugin.VersionCatalogUpdateExtension
66
import nl.littlerobots.vcu.plugin.VersionCatalogUpdatePlugin
77
import org.gradle.api.Plugin
8-
import org.gradle.api.Project
8+
import org.gradle.api.initialization.Settings
99
import org.gradle.kotlin.dsl.apply
1010
import org.gradle.kotlin.dsl.configure
1111
import org.gradle.kotlin.dsl.withType
1212

1313
@Suppress("Unused")
14-
class DependencyUpdatesPlugin : Plugin<Project> {
14+
class DependencyUpdatesPlugin : Plugin<Settings> {
1515

16-
override fun apply(project: Project) {
17-
project.pluginManager.apply(VersionsPlugin::class)
18-
project.pluginManager.apply(VersionCatalogUpdatePlugin::class)
19-
project.tasks.withType<DependencyUpdatesTask> {
20-
rejectVersionIf {
21-
when (candidate.group) {
22-
"commons-codec",
23-
"org.eclipse.jgit" -> true
24-
else -> false
16+
override fun apply(settings: Settings) {
17+
settings.gradle.allprojects {
18+
if (rootProject == this) {
19+
pluginManager.apply(VersionCatalogUpdatePlugin::class)
20+
extensions.configure<VersionCatalogUpdateExtension> { keep.keepUnusedLibraries.set(true) }
21+
pluginManager.apply(VersionsPlugin::class)
22+
tasks.withType<DependencyUpdatesTask> {
23+
rejectVersionIf {
24+
when (candidate.group) {
25+
"commons-codec",
26+
"org.eclipse.jgit" -> true
27+
else -> false
28+
}
29+
}
30+
checkForGradleUpdate = false
2531
}
2632
}
27-
checkForGradleUpdate = false
28-
}
29-
project.extensions.configure<VersionCatalogUpdateExtension> {
30-
keep.keepUnusedLibraries.set(true)
3133
}
3234
}
3335
}

build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@ plugins {
66
id("com.github.android-password-store.git-hooks")
77
id("com.github.android-password-store.kotlin-common")
88
id("com.github.android-password-store.ktfmt")
9-
id("com.github.android-password-store.versions")
109
alias(libs.plugins.hilt) apply false
1110
}

settings.gradle.kts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ rootProject.name = "APS"
88

99
// Plugin repositories
1010
pluginManagement {
11-
plugins { id("org.gradle.toolchains.foojay-resolver-convention") version "0.6.0" }
1211
repositories {
1312
includeBuild("build-logic")
1413
exclusiveContent {
@@ -43,6 +42,11 @@ pluginManagement {
4342
includeModule("com.gradle", "gradle-enterprise-gradle-plugin")
4443
includeModule("com.gradle.enterprise", "com.gradle.enterprise.gradle.plugin")
4544
includeModule("me.tylerbwong.gradle.metalava", "plugin")
45+
includeModule(
46+
"org.gradle.toolchains.foojay-resolver-convention",
47+
"org.gradle.toolchains.foojay-resolver-convention.gradle.plugin",
48+
)
49+
includeModule("org.gradle.toolchains", "foojay-resolver")
4650
}
4751
}
4852
exclusiveContent {
@@ -53,7 +57,11 @@ pluginManagement {
5357
}
5458
}
5559

56-
plugins { id("com.gradle.enterprise") version "3.13.4" }
60+
plugins {
61+
id("org.gradle.toolchains.foojay-resolver-convention") version "0.6.0"
62+
id("com.gradle.enterprise") version "3.13.4"
63+
id("com.github.android-password-store.versions")
64+
}
5765

5866
gradleEnterprise {
5967
buildScan {

0 commit comments

Comments
 (0)