Skip to content

Commit

Permalink
Migrated build scripts to kts (#2654)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
shanshin authored May 6, 2024
1 parent 84a2171 commit 5aa1032
Show file tree
Hide file tree
Showing 55 changed files with 1,723 additions and 1,592 deletions.
52 changes: 0 additions & 52 deletions benchmark/build.gradle

This file was deleted.

64 changes: 64 additions & 0 deletions benchmark/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import org.jetbrains.kotlin.gradle.dsl.*
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

/*
* Copyright 2017-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

plugins {
java
idea
kotlin("jvm")
alias(libs.plugins.serialization)
alias(libs.plugins.shadow)
alias(libs.plugins.jmh)
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

jmh {
jmhVersion.set("1.35")
}

tasks.processJmhResources {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

tasks.jmhJar {
archiveBaseName.set("benchmarks")
archiveVersion.set("")
destinationDirectory.set(file("$rootDir"))
}

// to include benchmark-module jmh source set compilation during build to verify that it is also compiled succesfully
tasks.assemble {
dependsOn(tasks.jmhClasses)
}

tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
jvmTarget = JvmTarget.JVM_1_8
}

kotlinOptions {
if (overriddenLanguageVersion != null) {
languageVersion = overriddenLanguageVersion
freeCompilerArgs += "-Xsuppress-version-warnings"
}
}
}

dependencies {
implementation(libs.jmhCore)
implementation(libs.guava)
implementation(libs.jackson.databind)
implementation(libs.jackson.module.kotlin)
implementation(libs.okio)
implementation(project(":kotlinx-serialization-core"))
implementation(project(":kotlinx-serialization-json"))
implementation(project(":kotlinx-serialization-json-okio"))
implementation(project(":kotlinx-serialization-protobuf"))
}
41 changes: 0 additions & 41 deletions bom/build.gradle

This file was deleted.

51 changes: 51 additions & 0 deletions bom/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import org.gradle.api.publish.maven.internal.publication.DefaultMavenPublication

plugins {
`java-platform`
}

val name = project.name

dependencies {
constraints {
rootProject.subprojects.forEach {
if (it.name == name) return@forEach
if (!it.plugins.hasPlugin("maven-publish")) return@forEach
evaluationDependsOn(it.path)
it.publishing.publications.all {
this as MavenPublication
if (artifactId.endsWith("-kotlinMultiplatform")) return@all
if (artifactId.endsWith("-metadata")) return@all
// Skip platform artifacts (like *-linuxx64, *-macosx64)
// It leads to inconsistent bom when publishing from different platforms
// (e.g. on linux it will include only linuxx64 artifacts and no macosx64)
// It shouldn't be a problem as usually consumers need to use generic *-native artifact
// Gradle will choose correct variant by using metadata attributes
if (artifacts.any { it.extension == "klib" }) return@all
this@constraints.api(mapOf("group" to groupId, "name" to artifactId, "version" to version))
}
}
}
}

publishing {
publications {
val mavenBom by creating(MavenPublication::class) {
from(components["javaPlatform"])
}
// Disable metadata publication
forEach { pub ->
pub as DefaultMavenPublication
pub.unsetModuleDescriptorGenerator()
tasks.matching { it.name == "generateMetadataFileFor${pub.name.capitalize()}Publication" }.all {
onlyIf { false }
}
}
}
}

fun DefaultMavenPublication.unsetModuleDescriptorGenerator() {
@Suppress("NULL_FOR_NONNULL_TYPE")
val generator: TaskProvider<Task?> = null
setModuleDescriptorGenerator(generator)
}
Loading

0 comments on commit 5aa1032

Please sign in to comment.