Skip to content

Commit 35c2891

Browse files
committed
Move Kotlin User Project configuration to settings plugin
1 parent c40b2b6 commit 35c2891

8 files changed

+196
-179
lines changed

build-logic/src/main/kotlin/ktorbuild.kmp.gradle.kts

+3-4
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ kotlin {
2323
explicitApi()
2424

2525
compilerOptions {
26-
progressiveMode = ktorBuild.kotlinLanguageVersion.map { it >= KotlinVersion.DEFAULT }
27-
apiVersion = ktorBuild.kotlinApiVersion
28-
languageVersion = ktorBuild.kotlinLanguageVersion
26+
apiVersion = KotlinVersion.KOTLIN_2_0
27+
languageVersion = KotlinVersion.KOTLIN_2_1
28+
progressiveMode = languageVersion.map { it >= KotlinVersion.DEFAULT }
2929
freeCompilerArgs.addAll("-Xexpect-actual-classes")
3030
}
3131

@@ -64,5 +64,4 @@ if (targets.hasNative) {
6464
}
6565
}
6666

67-
setupTrain()
6867
if (ktorBuild.isCI.get()) configureTestTasksOnCi()

build-logic/src/main/kotlin/ktorbuild/KtorBuildExtension.kt

-27
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import org.gradle.api.provider.ProviderFactory
1212
import org.gradle.internal.os.OperatingSystem
1313
import org.gradle.jvm.toolchain.JavaLanguageVersion
1414
import org.gradle.kotlin.dsl.newInstance
15-
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
1615
import javax.inject.Inject
1716

1817
abstract class KtorBuildExtension private constructor(
@@ -49,26 +48,6 @@ abstract class KtorBuildExtension private constructor(
4948
.orElse(providers.provider { JavaVersion.current().majorVersion })
5049
.map(JavaLanguageVersion::of)
5150

52-
/**
53-
* The Kotlin API version Ktor should be compatible with.
54-
*
55-
* DON'T change the property name as it is used in Kotlin Libraries train.
56-
*/
57-
val kotlinApiVersion: Provider<KotlinVersion> =
58-
providers.gradleProperty("kotlin_api_version")
59-
.map(KotlinVersion::fromVersion)
60-
.orElse(DEFAULT_KOTLIN_API_VERSION)
61-
62-
/**
63-
* The Kotlin Language version Ktor should be compatible with.
64-
*
65-
* DON'T change the property name as it is used in Kotlin Libraries train.
66-
*/
67-
val kotlinLanguageVersion: Provider<KotlinVersion> =
68-
providers.gradleProperty("kotlin_language_version")
69-
.map(KotlinVersion::fromVersion)
70-
.orElse(DEFAULT_KOTLIN_LANGUAGE_VERSION)
71-
7251
/** Host operating system. */
7352
val os: Provider<OperatingSystem> = providers.provider { OperatingSystem.current() }
7453

@@ -77,11 +56,5 @@ abstract class KtorBuildExtension private constructor(
7756

7857
/** The default (minimal) JDK version used for building the project. */
7958
const val DEFAULT_JDK = 8
80-
81-
/** The default (minimal) Kotlin version used as an API version. */
82-
private val DEFAULT_KOTLIN_API_VERSION = KotlinVersion.KOTLIN_2_0
83-
84-
/** The default Kotlin version used as a Language version. */
85-
private val DEFAULT_KOTLIN_LANGUAGE_VERSION = KotlinVersion.KOTLIN_2_1
8659
}
8760
}

build-logic/src/main/kotlin/ktorbuild/internal/Train.kt

-74
This file was deleted.

build-settings-logic/build.gradle.kts

+1-5
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@ plugins {
66
`kotlin-dsl`
77
}
88

9-
repositories {
10-
mavenCentral()
11-
gradlePluginPortal()
12-
}
13-
149
dependencies {
10+
implementation(libs.kotlin.gradlePlugin)
1511
implementation(libs.develocity)
1612
implementation(libs.develocity.commonCustomUserData)
1713
}

build-settings-logic/settings.gradle.kts

+14
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,26 @@ plugins {
77
id("com.gradle.develocity") version "3.18.2"
88
}
99

10+
@Suppress("UnstableApiUsage")
1011
dependencyResolutionManagement {
1112
versionCatalogs {
1213
create("libs") {
1314
from(files("../gradle/libs.versions.toml"))
15+
16+
// Make it possible to override Kotlin version
17+
// See ktorsettings.kotlin-user-project for more details
18+
val kotlinVersion = providers.gradleProperty("kotlin_version").orNull
19+
if (kotlinVersion != null) version("kotlin", kotlinVersion)
1420
}
1521
}
22+
23+
repositories {
24+
gradlePluginPortal()
25+
26+
// Should be in sync with ktorsettings.kotlin-user-project
27+
val kotlinRepoUrl = providers.gradleProperty("kotlin_repo_url").orNull
28+
if (kotlinRepoUrl != null) maven(kotlinRepoUrl) { name = "KotlinDev" }
29+
}
1630
}
1731

1832
rootProject.name = "build-settings-logic"

build-settings-logic/src/main/kotlin/conventions-dependency-resolution-management.settings.gradle.kts

+20-69
Original file line numberDiff line numberDiff line change
@@ -4,68 +4,13 @@
44

55
@file:Suppress("UnstableApiUsage")
66

7-
/*
8-
* These properties are used to build Ktor against Kotlin compiler snapshot in two different configurations:
9-
*
10-
* Ktor K2:
11-
* - `kotlin_version overrides` the Kotlin version to be used for project compilation
12-
* - `kotlin_repo_url` defines additional repository to be added to the repository list
13-
* - `kotlin_language_version` overrides Kotlin language versions
14-
* - `kotlin_api_version` overrides Kotlin API version
15-
*
16-
* Ktor Train:
17-
* All the above properties are applied, and:
18-
* - `build_snapshot_train` is set to true
19-
* - `atomicfu_version`, `coroutines_version` and `serialization_version` are defined in TeamCity environment
20-
* - Additionally Sonatype snapshots repository added to the repository list,
21-
* and stress tests disabled.
22-
*
23-
* DO NOT change the names of these properties without adapting kotlinx.train build chain.
24-
*/
25-
267
pluginManagement {
27-
// Share repositories configuration between pluginManagement and dependencyResolutionManagement blocks
28-
val configureRepositories by extra {
29-
val additionalKotlinRepo = providers.gradleProperty("kotlin_repo_url").orNull
30-
31-
fun RepositoryHandler.() {
32-
google {
33-
content {
34-
includeGroupAndSubgroups("com.google")
35-
includeGroupAndSubgroups("com.android")
36-
}
37-
}
38-
mavenCentral()
39-
40-
if (additionalKotlinRepo != null) {
41-
maven(additionalKotlinRepo) { name = "KotlinDevRepo" }
42-
logger.info("Kotlin Dev repository: $additionalKotlinRepo")
43-
}
44-
45-
mavenLocal()
46-
47-
exclusiveContent {
48-
forRepository {
49-
maven("https://maven.pkg.jetbrains.space/public/p/ktor/eap") { name = "KtorEAP" }
50-
}
51-
filter { includeVersionByRegex("io.ktor", ".+", ".+-eap-\\d+") }
52-
}
53-
}
54-
}
55-
568
repositories {
579
gradlePluginPortal()
5810
configureRepositories()
5911
}
6012
}
6113

62-
val configureRepositories: RepositoryHandler.() -> Unit by extra
63-
val buildSnapshotTrain = providers.gradleProperty("build_snapshot_train").orNull.toBoolean()
64-
val kotlinVersion = providers.gradleProperty("kotlin_version")
65-
// kotlin_snapshot_version might be used instead of kotlin_version
66-
.orElse(providers.gradleProperty("kotlin_snapshot_version"))
67-
.orNull
68-
6914
dependencyResolutionManagement {
7015
repositories {
7116
configureRepositories()
@@ -77,25 +22,31 @@ dependencyResolutionManagement {
7722
from(files("../gradle/libs.versions.toml"))
7823
}
7924

80-
if (buildSnapshotTrain) {
81-
requireNotNull(kotlinVersion) {
82-
"kotlin_version should be specified when building with build_snapshot_train=true"
83-
}
84-
version("kotlin", kotlinVersion)
85-
version("atomicfu", extra["atomicfu_version"].toString())
86-
version("coroutines", extra["coroutines_version"].toString())
87-
version("serialization", extra["serialization_version"].toString())
88-
} else if (kotlinVersion != null) {
89-
version("kotlin", kotlinVersion)
90-
}
91-
9225
downgradeTestDependencies()
9326
}
9427
}
9528
}
9629

97-
fun VersionCatalogBuilder.downgradeTestDependencies() {
30+
private fun RepositoryHandler.configureRepositories() {
31+
google {
32+
content {
33+
includeGroupAndSubgroups("com.google")
34+
includeGroupAndSubgroups("com.android")
35+
}
36+
}
37+
mavenCentral()
38+
mavenLocal()
39+
40+
exclusiveContent {
41+
forRepository {
42+
maven("https://maven.pkg.jetbrains.space/public/p/ktor/eap") { name = "KtorEAP" }
43+
}
44+
filter { includeVersionByRegex("io.ktor", ".+", ".+-eap-\\d+") }
45+
}
46+
}
47+
48+
private fun VersionCatalogBuilder.downgradeTestDependencies() {
9849
val testJdk = providers.gradleProperty("test.jdk").orNull?.toInt() ?: return
9950

100-
if (testJdk < 11) version("logback", "1.3.14") // Java 8 support dropped in Logback 1.4.x
51+
if (testJdk < 11) version("logback", "1.3.14") // Java 8 support has been dropped in Logback 1.4.x
10152
}

0 commit comments

Comments
 (0)