Skip to content

Commit cc5d1d9

Browse files
committed
Added configs for 'for-ide' builds
1 parent 4b4bd96 commit cc5d1d9

File tree

11 files changed

+67
-9
lines changed

11 files changed

+67
-9
lines changed

compiler-plugin/compiler-plugin-k2/build.gradle.kts

+9-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode
66
import util.enableContextReceivers
7+
import util.otherwise
8+
import util.whenForIde
79

810
plugins {
911
alias(libs.plugins.conventions.jvm)
@@ -19,6 +21,12 @@ kotlin {
1921
dependencies {
2022
compileOnly(libs.kotlin.reflect)
2123
compileOnly(libs.kotlin.compiler.embeddable)
22-
compileOnly(libs.serialization.plugin)
24+
whenForIde {
25+
compileOnly(libs.serialization.plugin.forIde) {
26+
isTransitive = false
27+
}
28+
} otherwise {
29+
compileOnly(libs.serialization.plugin)
30+
}
2331
implementation(projects.compilerPluginCommon)
2432
}

gradle-conventions-settings/src/main/kotlin/conventions-version-resolution.settings.gradle.kts

+9
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ fun Path.bufferedReader(
2525

2626
object SettingsConventions {
2727
const val KOTLIN_VERSION_ENV_VAR_NAME = "KOTLIN_VERSION"
28+
const val KOTLIN_COMPILER_VERSION_ENV_VAR_NAME = "KOTLIN_COMPILER_VERSION"
2829
const val LIBRARY_VERSION_ENV_VAR_NAME = "LIBRARY_VERSION"
2930
const val EAP_VERSION_ENV_VAR_NAME = "EAP_VERSION"
3031

3132
const val LIBRARY_CORE_VERSION_ALIAS = "kotlinx-rpc"
3233
const val KOTLIN_VERSION_ALIAS = "kotlin-lang"
34+
const val KOTLIN_COMPILER_VERSION_ALIAS = "kotlin-compiler"
3335

3436
const val VERSIONS_SECTION_NAME = "[versions]"
3537

@@ -146,13 +148,20 @@ fun resolveVersionCatalog(rootDir: Path): Map<String, String> {
146148
// Otherwise uses version from catalog.
147149
fun VersionCatalogBuilder.resolveKotlinVersion(versionCatalog: Map<String, String>): String {
148150
var kotlinCatalogVersion: String? = System.getenv(SettingsConventions.KOTLIN_VERSION_ENV_VAR_NAME)
151+
val kotlinCompilerVersion: String? = System.getenv(SettingsConventions.KOTLIN_COMPILER_VERSION_ENV_VAR_NAME)
149152

150153
if (kotlinCatalogVersion != null) {
151154
version(SettingsConventions.KOTLIN_VERSION_ALIAS, kotlinCatalogVersion)
152155
} else {
153156
kotlinCatalogVersion = versionCatalog[SettingsConventions.KOTLIN_VERSION_ALIAS]
154157
}
155158

159+
if (kotlinCompilerVersion != null) {
160+
version(SettingsConventions.KOTLIN_COMPILER_VERSION_ALIAS, kotlinCompilerVersion)
161+
} else {
162+
version(SettingsConventions.KOTLIN_COMPILER_VERSION_ALIAS, kotlinCatalogVersion!!)
163+
}
164+
156165
return kotlinCatalogVersion
157166
?: error("Expected to resolve '${SettingsConventions.KOTLIN_VERSION_ALIAS}' version")
158167
}

gradle-conventions-settings/src/main/kotlin/util/JsTarget.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fun ProjectKotlinConfig.configureJs() {
1717
return
1818
}
1919

20-
kotlin {
20+
kmp {
2121
js(IR) {
2222
configureJsAndWasmJsTasks()
2323
}

gradle-conventions-settings/src/main/kotlin/util/KotlinExtension.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import org.gradle.kotlin.dsl.the
1111
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
1212
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
1313

14-
fun Project.kotlin(block: KotlinMultiplatformExtension.() -> Unit) {
14+
fun Project.kmp(block: KotlinMultiplatformExtension.() -> Unit) {
1515
configure(block)
1616
}
1717

gradle-conventions-settings/src/main/kotlin/util/TargetUtils.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ private fun Project.configureDetekt(targets: List<KotlinTarget>) {
5151
}
5252

5353
fun ProjectKotlinConfig.configureKotlin(action: Action<KotlinMultiplatformExtension> = Action { }) {
54-
kotlin {
54+
kmp {
5555
val includedTargets = configureTargets(this@configureKotlin)
5656

5757
configureDetekt(includedTargets)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
package util
6+
7+
import org.gradle.api.Project
8+
9+
fun Project.whenForIde(block: () -> Unit): ActionApplied {
10+
val forIdeBuild by optionalProperty()
11+
12+
if (forIdeBuild) {
13+
block()
14+
}
15+
16+
return ActionApplied(forIdeBuild)
17+
}

gradle-conventions/src/main/kotlin/conventions-publishing.gradle.kts

+10
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ fun PublishingExtension.configurePublication() {
2727
repositories {
2828
configureSonatypeRepository()
2929
configureSpaceRepository()
30+
configureForIdeRepository()
3031
configureLocalDevRepository()
3132
}
3233

@@ -118,6 +119,15 @@ fun RepositoryHandler.configureSpaceRepository() {
118119
}
119120
}
120121

122+
fun RepositoryHandler.configureForIdeRepository() {
123+
configureRepository(project) {
124+
username = "SPACE_USERNAME"
125+
password = "SPACE_PASSWORD"
126+
name = "forIde"
127+
url = "https://maven.pkg.jetbrains.space/public/p/krpc/for-ide"
128+
}
129+
}
130+
121131
fun RepositoryHandler.configureLocalDevRepository() {
122132
// Something that's straightforward to "clean" for development, not mavenLocal
123133
maven("$globalRootDir/build/repo") {

gradle-conventions/src/main/latest/util/wasm.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fun ProjectKotlinConfig.configureWasm() {
1616
}
1717
}
1818

19-
kotlin {
19+
kmp {
2020
if (wasmJs) {
2121
wasmJs {
2222
configureJsAndWasmJsTasks()

gradle.properties

+3
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@ kotlin.suppressGradlePluginWarnings=IncorrectCompileOnlyDependencyWarning
4141
# Uncomment to skip adding git tags to Develocity build scan
4242
# Add this property to ~/.gradle/gradle.properties to avoid polluting git with unwanted changes
4343
#kotlinx.rpc.develocity.skipGitTags=true
44+
45+
# set to true when building IDE compiler plugin artifacts
46+
kotlinx.rpc.forIdeBuild=false

tests/compiler-plugin-tests/build.gradle.kts

+10-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode
66
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
7+
import util.otherwise
8+
import util.whenForIde
79

810
plugins {
911
java
@@ -69,7 +71,14 @@ dependencies {
6971
testRuntimeOnly(libs.kotlin.script.runtime)
7072
testRuntimeOnly(libs.kotlin.annotations.jvm)
7173

72-
testImplementation(libs.serialization.plugin)
74+
whenForIde {
75+
testImplementation(libs.serialization.plugin.forIde) {
76+
isTransitive = false
77+
}
78+
} otherwise {
79+
testImplementation(libs.serialization.plugin)
80+
}
81+
7382
testImplementation(libs.compiler.plugin.cli)
7483

7584
testImplementation(libs.kotlin.reflect)

versions-root/libs.versions.toml

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
kotlinx-rpc = "0.3.0"
44

55
# kotlin
6-
kotlin-lang = "2.0.21"
6+
kotlin-lang = "2.0.21" # or env.KOTLIN_VERSION
7+
kotlin-compiler = "0.0.0" # default to kotlin-lang or env.KOTLIN_COMPILER_VERSION
78

89
# kotlin independent versions
910
detekt-analyzer = "1.23.6"
@@ -49,10 +50,11 @@ kotlin-script-runtime = { module = "org.jetbrains.kotlin:kotlin-script-runtime",
4950
kotlin-annotations-jvm = { module = "org.jetbrains.kotlin:kotlin-annotations-jvm", version.ref = "kotlin-lang" }
5051
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin-lang" }
5152

52-
kotlin-compiler = { module = "org.jetbrains.kotlin:kotlin-compiler", version.ref = "kotlin-lang" }
53+
kotlin-compiler = { module = "org.jetbrains.kotlin:kotlin-compiler", version.ref = "kotlin-compiler" }
5354
kotlin-compiler-embeddable = { module = "org.jetbrains.kotlin:kotlin-compiler-embeddable" }
5455
kotlin-compiler-test-framework = { module = "org.jetbrains.kotlin:kotlin-compiler-internal-test-framework", version.ref = "kotlin-lang" }
55-
serialization-plugin = { module = "org.jetbrains.kotlin:kotlin-serialization-compiler-plugin", version.ref = "kotlin-lang" }
56+
serialization-plugin = { module = "org.jetbrains.kotlin:kotlin-serialization-compiler-plugin", version.ref = "kotlin-compiler" }
57+
serialization-plugin-forIde = { module = "org.jetbrains.kotlin:kotlinx-serialization-compiler-plugin-for-ide", version.ref = "kotlin-compiler" }
5658
kotlinx-browser = { module = "org.jetbrains.kotlinx:kotlinx-browser", version.ref = "kotlinx-browser" }
5759

5860
# serialization

0 commit comments

Comments
 (0)