Skip to content

Commit 5aa1032

Browse files
authored
Migrated build scripts to kts (#2654)
Actions: - Translate subprojects buildscripts to KTS - Upgrade Gradle to 8.7 - Move common login into convention precompiled plugins - Added support of version catalog - Use Kotlin version from version catalog - Removed usage of extra extension and rootProject - Removed buildscript block and grouped root scripts - Removed background native tests
1 parent 84a2171 commit 5aa1032

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1723
-1592
lines changed

benchmark/build.gradle

Lines changed: 0 additions & 52 deletions
This file was deleted.

benchmark/build.gradle.kts

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import org.jetbrains.kotlin.gradle.dsl.*
2+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
3+
4+
/*
5+
* Copyright 2017-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
6+
*/
7+
8+
plugins {
9+
java
10+
idea
11+
kotlin("jvm")
12+
alias(libs.plugins.serialization)
13+
alias(libs.plugins.shadow)
14+
alias(libs.plugins.jmh)
15+
}
16+
17+
java {
18+
sourceCompatibility = JavaVersion.VERSION_1_8
19+
targetCompatibility = JavaVersion.VERSION_1_8
20+
}
21+
22+
jmh {
23+
jmhVersion.set("1.35")
24+
}
25+
26+
tasks.processJmhResources {
27+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
28+
}
29+
30+
tasks.jmhJar {
31+
archiveBaseName.set("benchmarks")
32+
archiveVersion.set("")
33+
destinationDirectory.set(file("$rootDir"))
34+
}
35+
36+
// to include benchmark-module jmh source set compilation during build to verify that it is also compiled succesfully
37+
tasks.assemble {
38+
dependsOn(tasks.jmhClasses)
39+
}
40+
41+
tasks.withType<KotlinCompile>().configureEach {
42+
compilerOptions {
43+
jvmTarget = JvmTarget.JVM_1_8
44+
}
45+
46+
kotlinOptions {
47+
if (overriddenLanguageVersion != null) {
48+
languageVersion = overriddenLanguageVersion
49+
freeCompilerArgs += "-Xsuppress-version-warnings"
50+
}
51+
}
52+
}
53+
54+
dependencies {
55+
implementation(libs.jmhCore)
56+
implementation(libs.guava)
57+
implementation(libs.jackson.databind)
58+
implementation(libs.jackson.module.kotlin)
59+
implementation(libs.okio)
60+
implementation(project(":kotlinx-serialization-core"))
61+
implementation(project(":kotlinx-serialization-json"))
62+
implementation(project(":kotlinx-serialization-json-okio"))
63+
implementation(project(":kotlinx-serialization-protobuf"))
64+
}

bom/build.gradle

Lines changed: 0 additions & 41 deletions
This file was deleted.

bom/build.gradle.kts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import org.gradle.api.publish.maven.internal.publication.DefaultMavenPublication
2+
3+
plugins {
4+
`java-platform`
5+
}
6+
7+
val name = project.name
8+
9+
dependencies {
10+
constraints {
11+
rootProject.subprojects.forEach {
12+
if (it.name == name) return@forEach
13+
if (!it.plugins.hasPlugin("maven-publish")) return@forEach
14+
evaluationDependsOn(it.path)
15+
it.publishing.publications.all {
16+
this as MavenPublication
17+
if (artifactId.endsWith("-kotlinMultiplatform")) return@all
18+
if (artifactId.endsWith("-metadata")) return@all
19+
// Skip platform artifacts (like *-linuxx64, *-macosx64)
20+
// It leads to inconsistent bom when publishing from different platforms
21+
// (e.g. on linux it will include only linuxx64 artifacts and no macosx64)
22+
// It shouldn't be a problem as usually consumers need to use generic *-native artifact
23+
// Gradle will choose correct variant by using metadata attributes
24+
if (artifacts.any { it.extension == "klib" }) return@all
25+
this@constraints.api(mapOf("group" to groupId, "name" to artifactId, "version" to version))
26+
}
27+
}
28+
}
29+
}
30+
31+
publishing {
32+
publications {
33+
val mavenBom by creating(MavenPublication::class) {
34+
from(components["javaPlatform"])
35+
}
36+
// Disable metadata publication
37+
forEach { pub ->
38+
pub as DefaultMavenPublication
39+
pub.unsetModuleDescriptorGenerator()
40+
tasks.matching { it.name == "generateMetadataFileFor${pub.name.capitalize()}Publication" }.all {
41+
onlyIf { false }
42+
}
43+
}
44+
}
45+
}
46+
47+
fun DefaultMavenPublication.unsetModuleDescriptorGenerator() {
48+
@Suppress("NULL_FOR_NONNULL_TYPE")
49+
val generator: TaskProvider<Task?> = null
50+
setModuleDescriptorGenerator(generator)
51+
}

0 commit comments

Comments
 (0)