Skip to content

Commit d1640e6

Browse files
authored
Introduced BOM to have all the dependencies aligned (#2093)
Added dependency on kotlinx-serialization-bom inside other kotlinx-serialization modules themselves, so they have same versions through it Resolves #2053
1 parent bc6112e commit d1640e6

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

build.gradle

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ allprojects {
147147
}
148148

149149
def unpublishedProjects = ["benchmark", "guide", "kotlinx-serialization-json-tests"] as Set
150+
def excludedFromBomProjects = unpublishedProjects + "kotlinx-serialization-bom" as Set
151+
def uncoveredProjects = ["kotlinx-serialization-bom", "benchmark", "guide"] as Set
150152

151153
subprojects {
152154
tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile).all { task ->
@@ -162,12 +164,11 @@ subprojects {
162164
if (!unpublishedProjects.contains(project.name)) {
163165
apply from: rootProject.file('gradle/publishing.gradle')
164166
}
165-
166167
}
167168

168169
subprojects {
169170
// Can't be applied to BOM
170-
if (project.name == "kotlinx-serialization-bom" || project.name == "benchmark" || project.name == "guide") return
171+
if (excludedFromBomProjects.contains(project.name)) return
171172

172173
// Animalsniffer setup
173174
apply plugin: 'ru.vyarus.animalsniffer'
@@ -190,9 +191,16 @@ subprojects {
190191
signature 'net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature'
191192
signature 'org.codehaus.mojo.signature:java18:1.0@signature'
192193
}
194+
195+
// Add dependency on kotlinx-serialization-bom inside other kotlinx-serialization modules themselves, so they have same versions
196+
BomKt.addBomApiDependency(project, ":kotlinx-serialization-bom")
193197
}
198+
}
199+
200+
// Kover setup
201+
subprojects {
202+
if (uncoveredProjects.contains(project.name)) return
194203

195-
// Kover setup
196204
apply from: rootProject.file("gradle/kover.gradle")
197205
}
198206

buildSrc/src/main/kotlin/Bom.kt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright 2017-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
import org.gradle.api.Project
6+
import org.gradle.kotlin.dsl.*
7+
import org.jetbrains.kotlin.gradle.dsl.*
8+
9+
fun Project.addBomApiDependency(bomProjectPath: String) {
10+
val isMultiplatform = plugins.hasPlugin("kotlin-multiplatform")
11+
12+
if (isMultiplatform) {
13+
kotlinExtension.sourceSets.getByName("jvmMain").dependencies {
14+
api(project.dependencies.platform(project(bomProjectPath)))
15+
}
16+
} else {
17+
dependencies {
18+
"api"(platform(project(bomProjectPath)))
19+
}
20+
}
21+
}
22+

0 commit comments

Comments
 (0)