summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.gradle14
-rw-r--r--buildSrc/src/main/kotlin/Bom.kt22
2 files changed, 33 insertions, 3 deletions
diff --git a/build.gradle b/build.gradle
index 170a9df9..56f3f0a0 100644
--- a/build.gradle
+++ b/build.gradle
@@ -147,6 +147,8 @@ allprojects {
}
def unpublishedProjects = ["benchmark", "guide", "kotlinx-serialization-json-tests"] as Set
+def excludedFromBomProjects = unpublishedProjects + "kotlinx-serialization-bom" as Set
+def uncoveredProjects = ["kotlinx-serialization-bom", "benchmark", "guide"] as Set
subprojects {
tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile).all { task ->
@@ -162,12 +164,11 @@ subprojects {
if (!unpublishedProjects.contains(project.name)) {
apply from: rootProject.file('gradle/publishing.gradle')
}
-
}
subprojects {
// Can't be applied to BOM
- if (project.name == "kotlinx-serialization-bom" || project.name == "benchmark" || project.name == "guide") return
+ if (excludedFromBomProjects.contains(project.name)) return
// Animalsniffer setup
apply plugin: 'ru.vyarus.animalsniffer'
@@ -190,9 +191,16 @@ subprojects {
signature 'net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature'
signature 'org.codehaus.mojo.signature:java18:1.0@signature'
}
+
+ // Add dependency on kotlinx-serialization-bom inside other kotlinx-serialization modules themselves, so they have same versions
+ BomKt.addBomApiDependency(project, ":kotlinx-serialization-bom")
}
+}
+
+// Kover setup
+subprojects {
+ if (uncoveredProjects.contains(project.name)) return
- // Kover setup
apply from: rootProject.file("gradle/kover.gradle")
}
diff --git a/buildSrc/src/main/kotlin/Bom.kt b/buildSrc/src/main/kotlin/Bom.kt
new file mode 100644
index 00000000..7f93ed38
--- /dev/null
+++ b/buildSrc/src/main/kotlin/Bom.kt
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2017-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ */
+
+import org.gradle.api.Project
+import org.gradle.kotlin.dsl.*
+import org.jetbrains.kotlin.gradle.dsl.*
+
+fun Project.addBomApiDependency(bomProjectPath: String) {
+ val isMultiplatform = plugins.hasPlugin("kotlin-multiplatform")
+
+ if (isMultiplatform) {
+ kotlinExtension.sourceSets.getByName("jvmMain").dependencies {
+ api(project.dependencies.platform(project(bomProjectPath)))
+ }
+ } else {
+ dependencies {
+ "api"(platform(project(bomProjectPath)))
+ }
+ }
+}
+