Skip to content

Commit 0b5d334

Browse files
authored
Fix build config for for-ide builds (#287)
1 parent 4907cad commit 0b5d334

File tree

15 files changed

+86
-55
lines changed

15 files changed

+86
-55
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
/*
2-
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode
6+
import util.otherwise
7+
import util.whenForIde
68

79
plugins {
810
alias(libs.plugins.conventions.jvm)
@@ -18,6 +20,11 @@ kotlin {
1820
}
1921

2022
dependencies {
21-
compileOnly(libs.kotlin.compiler.embeddable)
23+
whenForIde {
24+
compileOnly(libs.kotlin.compiler)
25+
} otherwise {
26+
compileOnly(libs.kotlin.compiler.embeddable)
27+
}
28+
2229
implementation(projects.compilerPluginCommon)
2330
}

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
/*
2-
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode
6+
import util.otherwise
7+
import util.whenForIde
68

79
plugins {
810
alias(libs.plugins.conventions.jvm)
@@ -14,7 +16,12 @@ kotlin {
1416
}
1517

1618
dependencies {
17-
compileOnly(libs.kotlin.compiler.embeddable)
19+
whenForIde {
20+
compileOnly(libs.kotlin.compiler)
21+
} otherwise {
22+
compileOnly(libs.kotlin.compiler.embeddable)
23+
}
24+
1825
implementation(projects.compilerPluginK2)
1926
implementation(projects.compilerPluginCommon)
2027
implementation(projects.compilerPluginBackend)

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
/*
2-
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode
6+
import util.otherwise
7+
import util.whenForIde
68

79
plugins {
810
alias(libs.plugins.conventions.jvm)
@@ -14,5 +16,9 @@ kotlin {
1416
}
1517

1618
dependencies {
17-
compileOnly(libs.kotlin.compiler.embeddable)
19+
whenForIde {
20+
compileOnly(libs.kotlin.compiler)
21+
} otherwise {
22+
compileOnly(libs.kotlin.compiler.embeddable)
23+
}
1824
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ kotlin {
7272
}
7373

7474
dependencies {
75-
compileOnly(libs.kotlin.reflect)
76-
compileOnly(libs.kotlin.compiler.embeddable)
7775
whenForIde {
76+
compileOnly(libs.kotlin.compiler)
7877
compileOnly(libs.serialization.plugin.forIde) {
7978
isTransitive = false
8079
}
8180
} otherwise {
81+
compileOnly(libs.kotlin.compiler.embeddable)
8282
compileOnly(libs.serialization.plugin)
8383
}
8484
implementation(projects.compilerPluginCommon)

compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/FirRpcServiceGenerator.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
package kotlinx.rpc.codegen
@@ -11,6 +11,7 @@ import kotlinx.rpc.codegen.common.rpcMethodName
1111
import kotlinx.rpc.codegen.serialization.addAnnotation
1212
import kotlinx.rpc.codegen.serialization.generateCompanionDeclaration
1313
import kotlinx.rpc.codegen.serialization.generateSerializerImplClass
14+
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
1415
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
1516
import org.jetbrains.kotlin.descriptors.ClassKind
1617
import org.jetbrains.kotlin.descriptors.Modality

compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/FirVersionSpecificApi.kt

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
package kotlinx.rpc.codegen
@@ -25,13 +25,6 @@ interface FirVersionSpecificApi {
2525
var FirResolvedTypeRefBuilder.coneTypeVS: ConeKotlinType
2626
}
2727

28-
val vsApiClass by lazy {
29-
runCatching {
30-
Class.forName("kotlinx.rpc.codegen.FirVersionSpecificApiImpl")
31-
}.getOrNull()
32-
}
33-
3428
inline fun <T> vsApi(body: FirVersionSpecificApi.() -> T): T {
35-
val kClass = vsApiClass?.kotlin ?: error("FirVersionSpecificApi is not present")
36-
return (kClass.objectInstance as FirVersionSpecificApi).body()
29+
return FirVersionSpecificApiImpl.body()
3730
}

compiler-plugin/compiler-plugin-k2/src/main/core/kotlinx/rpc/codegen/checkers/diagnostics/FirRpcDiagnostics.kt

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5+
@file:Suppress("StructuralWrap")
6+
57
package kotlinx.rpc.codegen.checkers.diagnostics
68

79
import kotlinx.rpc.codegen.StrictModeAggregator
8-
import org.jetbrains.kotlin.com.intellij.psi.PsiElement
910
import org.jetbrains.kotlin.diagnostics.SourceElementPositioningStrategies
1011
import org.jetbrains.kotlin.diagnostics.error0
1112
import org.jetbrains.kotlin.diagnostics.error1
@@ -14,16 +15,23 @@ import org.jetbrains.kotlin.diagnostics.rendering.RootDiagnosticRendererFactory
1415
import org.jetbrains.kotlin.fir.types.ConeKotlinType
1516
import org.jetbrains.kotlin.name.Name
1617
import org.jetbrains.kotlin.psi.KtAnnotated
18+
import org.jetbrains.kotlin.psi.KtElement
19+
20+
// ###########################################################################
21+
// ### BIG WARNING, LISTEN CLOSELY! ###
22+
// # Do NOT use `PsiElement` for `error0` or any other function #
23+
// # Instead use KtElement, otherwise problems in IDE and in tests may arise #
24+
// ###########################################################################
1725

1826
object FirRpcDiagnostics {
1927
val MISSING_RPC_ANNOTATION by error0<KtAnnotated>()
2028
val MISSING_SERIALIZATION_MODULE by error0<KtAnnotated>()
2129
val WRONG_RPC_ANNOTATION_TARGET by error1<KtAnnotated, ConeKotlinType>()
2230
val CHECKED_ANNOTATION_VIOLATION by error1<KtAnnotated, ConeKotlinType>()
23-
val NON_SUSPENDING_REQUEST_WITHOUT_STREAMING_RETURN_TYPE by error0<PsiElement>()
24-
val AD_HOC_POLYMORPHISM_IN_RPC_SERVICE by error2<PsiElement, Int, Name>()
25-
val TYPE_PARAMETERS_IN_RPC_FUNCTION by error0<PsiElement>(SourceElementPositioningStrategies.TYPE_PARAMETERS_LIST)
26-
val TYPE_PARAMETERS_IN_RPC_INTERFACE by error0<PsiElement>(SourceElementPositioningStrategies.TYPE_PARAMETERS_LIST)
31+
val NON_SUSPENDING_REQUEST_WITHOUT_STREAMING_RETURN_TYPE by error0<KtElement>()
32+
val AD_HOC_POLYMORPHISM_IN_RPC_SERVICE by error2<KtElement, Int, Name>()
33+
val TYPE_PARAMETERS_IN_RPC_FUNCTION by error0<KtElement>(SourceElementPositioningStrategies.TYPE_PARAMETERS_LIST)
34+
val TYPE_PARAMETERS_IN_RPC_INTERFACE by error0<KtElement>(SourceElementPositioningStrategies.TYPE_PARAMETERS_LIST)
2735

2836
init {
2937
RootDiagnosticRendererFactory.registerFactory(RpcDiagnosticRendererFactory)
@@ -32,13 +40,13 @@ object FirRpcDiagnostics {
3240

3341
@Suppress("PropertyName", "detekt.VariableNaming")
3442
class FirRpcStrictModeDiagnostics(val modes: StrictModeAggregator) {
35-
val STATE_FLOW_IN_RPC_SERVICE by modded0<PsiElement>(modes.stateFlow)
36-
val SHARED_FLOW_IN_RPC_SERVICE by modded0<PsiElement>(modes.sharedFlow)
37-
val NESTED_STREAMING_IN_RPC_SERVICE by modded0<PsiElement>(modes.nestedFlow)
38-
val STREAM_SCOPE_FUNCTION_IN_RPC by modded0<PsiElement>(modes.streamScopedFunctions)
39-
val SUSPENDING_SERVER_STREAMING_IN_RPC_SERVICE by modded0<PsiElement>(modes.suspendingServerStreaming)
40-
val NON_TOP_LEVEL_SERVER_STREAMING_IN_RPC_SERVICE by modded0<PsiElement>(modes.notTopLevelServerFlow)
41-
val FIELD_IN_RPC_SERVICE by modded0<PsiElement>(modes.fields)
43+
val STATE_FLOW_IN_RPC_SERVICE by modded0<KtElement>(modes.stateFlow)
44+
val SHARED_FLOW_IN_RPC_SERVICE by modded0<KtElement>(modes.sharedFlow)
45+
val NESTED_STREAMING_IN_RPC_SERVICE by modded0<KtElement>(modes.nestedFlow)
46+
val STREAM_SCOPE_FUNCTION_IN_RPC by modded0<KtElement>(modes.streamScopedFunctions)
47+
val SUSPENDING_SERVER_STREAMING_IN_RPC_SERVICE by modded0<KtElement>(modes.suspendingServerStreaming)
48+
val NON_TOP_LEVEL_SERVER_STREAMING_IN_RPC_SERVICE by modded0<KtElement>(modes.notTopLevelServerFlow)
49+
val FIELD_IN_RPC_SERVICE by modded0<KtElement>(modes.fields)
4250

4351
init {
4452
RootDiagnosticRendererFactory.registerFactory(RpcStrictModeDiagnosticRendererFactory(this))

gradle-conventions-settings/build.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
plugins {
@@ -8,7 +8,6 @@ plugins {
88

99
configurations.configureEach {
1010
resolutionStrategy {
11-
force(libs.kotlin.reflect)
1211
force(libs.kotlin.stdlib)
1312
force(libs.kotlin.stdlib.jdk7)
1413
force(libs.kotlin.stdlib.jdk8)

gradle-conventions-settings/develocity/build.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
plugins {
@@ -8,7 +8,6 @@ plugins {
88

99
configurations.configureEach {
1010
resolutionStrategy {
11-
force(libs.kotlin.reflect)
1211
force(libs.kotlin.stdlib)
1312
force(libs.kotlin.stdlib.jdk7)
1413
force(libs.kotlin.stdlib.jdk8)
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
rootProject.name = "gradle-conventions-settings"
@@ -8,6 +8,4 @@ rootProject.name = "gradle-conventions-settings"
88
apply(from = "src/main/kotlin/conventions-repositories.settings.gradle.kts")
99
apply(from = "src/main/kotlin/conventions-version-resolution.settings.gradle.kts")
1010

11-
val kotlinVersion: KotlinVersion by extra
12-
1311
include(":develocity")

0 commit comments

Comments
 (0)