Skip to content

Backport kxDT-as-KUP infrastructure and migration changes #560

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

Merged
merged 10 commits into from
Jul 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions benchmarks/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file.
*/

import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask

plugins {
id("kotlin")
id("me.champeau.jmh")
Expand Down Expand Up @@ -32,3 +34,10 @@ tasks.named<Jar>("jmhJar") {
repositories {
mavenCentral()
}

// !! infrastructure for builds as a Kotlin user project
tasks.named("assemble") {
// compile all Kotlin code from the module during full-repository builds
// so that it's covered during builds as a Kotlin user project
dependsOn(tasks.withType<KotlinCompilationTask<*>>())
}
36 changes: 18 additions & 18 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile

plugins {
id("kotlinx.team.infra") version "0.4.0-dev-85"
kotlin("multiplatform") apply false
Expand All @@ -22,28 +25,25 @@ val modularJavaToolchainVersion by ext(project.property("java.modularToolchainVe

allprojects {
repositories {
addTrainRepositories(project)
mavenCentral()
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
// outputs the compiler version to logs so we can check whether the train configuration applied
kotlinOptions.freeCompilerArgs += "-version"
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile>().configureEach {
compilerOptions { freeCompilerArgs.add("-Xjvm-default=all-compatibility") }
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile>().configureEach {
compilerOptions { freeCompilerArgs.add("-Xpartial-linkage-loglevel=ERROR") }
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile>().configureEach {
compilerOptions { freeCompilerArgs.add("-Xpartial-linkage-loglevel=ERROR") }
kupInfra {
kupArtifactsRepo(context = project)
}
}
}

// Disable NPM to NodeJS nightly compatibility check.
// Drop this when NodeJs version that supports latest Wasm become stable
tasks.withType<org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask>().configureEach {
args.add("--ignore-engines")
subprojects {
// drop this after migration to 2.2.0
tasks.withType<KotlinJvmCompile>().configureEach {
compilerOptions {
freeCompilerArgs.add("-Xjvm-default=all-compatibility")
}
}
kupInfra {
tasks.withType<KotlinCompilationTask<*>>().configureEach {
kupConfiguration()
}
}
}

kover {
Expand Down
51 changes: 30 additions & 21 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,40 @@ plugins {
`kotlin-dsl`
}

val props = Properties().apply {
file("../gradle.properties").inputStream().use { load(it) }
}
repositories {
mavenCentral()
gradlePluginPortal()

// copy-pasted from `CommunityProjectsBuild`, see the explanation there
fun RepositoryHandler.addTrainRepositories(project: Project) {
if (project.rootProject.properties["build_snapshot_train"]?.toString()?.toBoolean() == true) {
mavenLocal()
// !! infrastructure for builds as a Kotlin user project
// this is an inlined version of `KotlinUserProjectUtilities.kupArtifactsRepo`
// (because `buildSrc/.../KotlinUserProjectInfra.kt` is not available here)
val kupArtifactsRepoURL = providers.gradleProperty("kotlin_repo_url").orNull
if (kupArtifactsRepoURL != null) {
maven(kupArtifactsRepoURL)
logger.lifecycle("[KUP infra] Added '$kupArtifactsRepoURL' as a Maven repo to ':buildSrc'")
}
(project.rootProject.properties["kotlin_repo_url"] as? String)?.let(::maven)
}

// copy-pasted from `CommunityProjectsBuild`, but uses `props` to obtain the non-snapshot version, because
// we don't have access to the properties defined in `gradle.properties` of the encompassing project
val Project.kotlinVersion: String
get() = if (rootProject.properties["build_snapshot_train"]?.toString()?.toBoolean() == true) {
rootProject.properties["kotlin_snapshot_version"] as? String ?: error("kotlin_snapshot_version must be specified")
} else {
props.getProperty("defaultKotlinVersion")
}

repositories {
mavenCentral()
gradlePluginPortal()
addTrainRepositories(project)
// !! infrastructure for builds as a Kotlin user project
/**
* the value provided via the `kotlin_version` Gradle property if any
* (otherwise, `defaultKotlinVersion` defined in `gradle.properties` of the root project is used instead);
* note that there is no direct `buildSrc/.../KotlinUserProjectInfra.kt` analogue for this utility
* because `kotlin_version` is commonly used where `buildSrc/.../KotlinUserProjectInfra.kt` is not available
* (`settings.gradle.kts`, `buildSrc`, etc.)
*/
val Project.kotlinVersion: String by lazy {
val kotlinVersion: String = providers.gradleProperty("kotlin_version").orNull
?: run {
// we don't have access to the properties defined in `gradle.properties` of the root project,
// so we have to get them manually
val properties = Properties().apply {
file("../gradle.properties").inputStream().use { load(it) }
}
properties.getProperty("defaultKotlinVersion")
}
logger.lifecycle("[KUP infra] Set Kotlin distribution version to '$kotlinVersion'")
kotlinVersion
}

dependencies {
Expand Down
50 changes: 0 additions & 50 deletions buildSrc/src/main/kotlin/CommunityProjectsBuild.kt

This file was deleted.

Loading