Skip to content

Commit d89fd04

Browse files
committed
Extracted common Gradle settings logic to the settings plugin
1 parent 8f035f4 commit d89fd04

File tree

5 files changed

+44
-22
lines changed

5 files changed

+44
-22
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
plugins {
2+
`kotlin-dsl`
3+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
rootProject.name = "build-settings-logic"
2+
3+
dependencyResolutionManagement {
4+
5+
@Suppress("UnstableApiUsage")
6+
repositories {
7+
mavenCentral()
8+
gradlePluginPortal()
9+
}
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
dependencyResolutionManagement {
2+
versionCatalogs {
3+
register("libs").configure {
4+
val kotlinVersion = providers.gradleProperty("kotlinVersion")
5+
if (kotlinVersion.isPresent) {
6+
version("kotlin", kotlinVersion.get())
7+
}
8+
}
9+
}
10+
}

buildSrc/settings.gradle.kts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1+
pluginManagement {
2+
includeBuild("../build-settings-logic")
3+
}
4+
15
dependencyResolutionManagement {
6+
// For buildSrc we need to declare a custom path to the toml file with versions' catalog.
7+
// But for a root project we can't set `from` inside `versionCatalogs` catalog block for the default `libs` catalog.
8+
// (see https://github.com/gradle/gradle/issues/21328)
9+
// That is why it is not fully moved to the dependencyResolutionManagement block in the settings convention plugin.
210
versionCatalogs {
3-
create("libs") {
11+
getByName("libs") {
412
from(files("../gradle/libs.versions.toml"))
513
}
6-
val kotlinVersion = providers.gradleProperty("kotlinVersion")
7-
if (kotlinVersion.isPresent) {
8-
create("libs") {
9-
version("kotlin", kotlinVersion.get())
10-
}
11-
}
1214
}
15+
}
16+
17+
plugins {
18+
id("kotlin-compiler-server-version-catalog")
1319
}

settings.gradle.kts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,17 @@
11
rootProject.name = "kotlin-compiler-server"
2-
include(":executors")
3-
include(":indexation")
4-
include(":common")
5-
include(":dependencies")
6-
72
pluginManagement {
3+
includeBuild("build-settings-logic")
84
repositories {
95
gradlePluginPortal()
106
mavenCentral()
117
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap")
128
}
139
}
10+
plugins {
11+
id("kotlin-compiler-server-version-catalog")
12+
}
1413

15-
dependencyResolutionManagement {
16-
versionCatalogs {
17-
val kotlinVersion = providers.gradleProperty("kotlinVersion")
18-
if (kotlinVersion.isPresent) {
19-
create("libs") {
20-
version("kotlin", kotlinVersion.get())
21-
}
22-
}
23-
}
24-
}
14+
include(":executors")
15+
include(":indexation")
16+
include(":common")
17+
include(":dependencies")

0 commit comments

Comments
 (0)