Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrated build scripts to kts #2654

Merged
merged 17 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)
}