Skip to content

Commit 467deaf

Browse files
committed
Simplified gradle configurations (#154)
1 parent 0c9e51f commit 467deaf

File tree

62 files changed

+282
-494
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+282
-494
lines changed

build.gradle.kts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
*/
44

55
import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion
6+
import util.kotlinVersionParsed
67

78
plugins {
8-
alias(libs.plugins.kotlin.jvm) apply false
99
alias(libs.plugins.serialization) apply false
1010
alias(libs.plugins.ksp) apply false
1111
alias(libs.plugins.kotlinx.rpc) apply false
1212
alias(libs.plugins.atomicfu) apply false
13-
alias(libs.plugins.detekt) apply false
14-
alias(libs.plugins.kover.root.project) apply false
13+
alias(libs.plugins.conventions.kover)
1514
alias(libs.plugins.binary.compatibility.validator)
1615
}
1716

@@ -41,11 +40,7 @@ apiValidation {
4140
nonPublicMarkers.add(Const.INTERNAL_RPC_API_ANNOTATION)
4241
}
4342

44-
val kotlinVersion: String by extra
45-
46-
if (kotlinVersion >= "1.8.0") {
47-
apply(plugin = libs.plugins.kover.root.project.get().pluginId)
48-
}
43+
val kotlinVersion: KotlinVersion by extra
4944

5045
allprojects {
5146
group = "org.jetbrains.kotlinx"
@@ -57,8 +52,8 @@ println("kotlinx.rpc project version: $version, Kotlin version: $kotlinVersion")
5752
// If the prefix of the kPRC version is not Kotlin gradle plugin version - you have a problem :)
5853
// Probably some dependency brings kotlin with higher version.
5954
// To mitigate so, please refer to `gradle/kotlin-version-lookup.json`
60-
// and it's usage in `gradle-settings-conventions/src/main/kotlin/settings-conventions.settings.gradle.kts`
61-
val kotlinGPVersion = getKotlinPluginVersion()
55+
// and it's usage in `gradle-conventions-settings/src/main/kotlin/settings-conventions.settings.gradle.kts`
56+
val kotlinGPVersion = getKotlinPluginVersion().kotlinVersionParsed()
6257
if (kotlinVersion != kotlinGPVersion) {
6358
error("KGP version mismatch. Project version: $kotlinVersion, KGP version: $kotlinGPVersion")
6459
}

compiler-plugin/build.gradle.kts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44

55
import util.configureMetaTasks
66

7-
plugins {
8-
alias(libs.plugins.conventions.utils)
9-
}
10-
11-
val kotlinVersion: String by extra
7+
val kotlinVersion: KotlinVersion by extra
128
val rpcVersion: String = libs.versions.kotlinx.rpc.get()
139

1410
allprojects {

compiler-plugin/settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
88

99
pluginManagement {
1010
includeBuild("../gradle-conventions")
11-
includeBuild("../gradle-settings-conventions")
11+
includeBuild("../gradle-conventions-settings")
1212
}
1313

1414
plugins {

core/src/commonMain/kotlin/kotlinx/rpc/internal/transport/RPCPluginKey.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import kotlinx.serialization.Serializable
2121
*/
2222
@InternalRPCApi
2323
@Serializable(with = RPCPluginKeySerializer::class)
24-
@Suppress("detekt.MagicNumber")
2524
public enum class RPCPluginKey(override val uniqueIndex: Int, private val associatedPlugin: RPCPlugin): IndexedEnum {
2625
/**
2726
* Failed to decode key, possible due to different endpoint versions.

core/src/jsMain/kotlin/kotlinx/rpc/internal/WithRPCStubObject.js.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ private val KClass<*>.jClass get(): JsClass<*> = asDynamic().jClass_1.unsafeCast
4747
*
4848
* This function uses std-lib's implementation and accounts for the bug in the compiler
4949
*/
50-
@Suppress("detekt.ReturnCount")
5150
internal fun <T : Annotation, R : Any> KClass<*>.findAssociatedObjectImpl(
5251
annotationClass: KClass<T>,
5352
resultKClass: KClass<R>,

detekt/baseline.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
<SmellBaseline>
77
<ManuallySuppressedIssues>
8-
<ID>ReturnCount:ExceptionUtils.jvm.kt$@InternalRPCApi public actual fun SerializedException.deserialize(): Throwable</ID>
98
<ID>CyclomaticComplexMethod:RPCServerService.kt$RPCServerService$@Suppress("detekt.ThrowsCount", "detekt.LongMethod") private fun handleCall(callData: RPCCallMessage.CallData)</ID>
109
<ID>LongMethod:RPCServerService.kt$RPCServerService$@OptIn(InternalCoroutinesApi::class) private fun handleCall(callData: RPCCallMessage.CallData)</ID>
1110
<ID>RethrowCaughtException:KRPCTransportTestBase.kt$KRPCTransportTestBase$throw e</ID>

detekt/config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ potential-bugs:
478478
active: true
479479
MissingPackageDeclaration:
480480
active: true
481-
excludes: ['**/*.kts']
481+
excludes: ['**/*.kts', '**/gradle-conventions-settings/**', '**/gradle-conventions/**']
482482
NullCheckOnMutableProperty:
483483
active: false
484484
NullableToStringCall:
@@ -616,7 +616,7 @@ style:
616616
active: true
617617
maxJumpCount: 3
618618
MagicNumber:
619-
active: true
619+
active: false
620620
excludes: ['**/*test*/**', '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**', '**/*.kts']
621621
ignoreNumbers:
622622
- '-1'
@@ -683,7 +683,7 @@ style:
683683
active: false
684684
ReturnCount:
685685
active: true
686-
max: 2
686+
max: 6
687687
excludedFunctions:
688688
- 'equals'
689689
excludeLabeled: false

gradle-conventions/conventions-utils/build.gradle.kts renamed to gradle-conventions-settings/build.gradle.kts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,17 @@ configurations.configureEach {
1515
}
1616
}
1717

18-
val kotlinVersion: String by extra
18+
val kotlinVersion: KotlinVersion by extra
19+
val isLatestKotlinVersion: Boolean by extra
1920

2021
dependencies {
2122
api(libs.kotlin.gradle.plugin)
2223
api(libs.detekt.gradle.plugin)
2324

24-
if (kotlinVersion >= "1.8.0") {
25+
if (isLatestKotlinVersion) {
2526
api(libs.kover.gradle.plugin)
2627
}
2728

2829
// https://stackoverflow.com/questions/76713758/use-version-catalog-inside-precompiled-gradle-plugin
2930
api(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
3031
}
31-
32-
gradlePlugin {
33-
plugins {
34-
named("conventions-utils") {
35-
version = libs.versions.kotlinx.rpc.get()
36-
}
37-
}
38-
}

gradle-settings-conventions/settings.gradle.kts renamed to gradle-conventions-settings/settings.gradle.kts

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

5-
rootProject.name = "gradle-settings-conventions"
5+
rootProject.name = "gradle-conventions-settings"
66

77
// Code below is a hack because a chicken-egg problem, I can't use myself as a settings-plugin
8-
apply(from="src/main/kotlin/settings-conventions.settings.gradle.kts")
8+
apply(from = "src/main/kotlin/settings-conventions.settings.gradle.kts")

0 commit comments

Comments
 (0)