Skip to content

Commit af070fd

Browse files
committed
fix detekt java 25 build
1 parent 64e3ec8 commit af070fd

2 files changed

Lines changed: 53 additions & 30 deletions

File tree

build.gradle.kts

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import dev.detekt.gradle.Detekt
12
import org.gradle.api.tasks.testing.Test
23
import top.ellan.mahjong.build.MahjongTaskRegistration
34

@@ -8,25 +9,31 @@ plugins {
89
kotlin("plugin.serialization") version "2.4.0"
910
id("io.papermc.paperweight.userdev") version "2.0.0-SNAPSHOT"
1011
id("com.diffplug.spotless") version "7.2.0"
11-
id("io.gitlab.arturbosch.detekt") version "1.23.7"
12+
id("dev.detekt") version "2.0.0-alpha.4"
1213
}
1314

1415
group = "top.ellan"
1516
version = "1.3.0-SNAPSHOT"
1617

1718
val minimumPaperDevBundleVersion = "1.20.1-R0.1-SNAPSHOT"
18-
val paperDevBundleVersion = providers.gradleProperty("mahjongPaperDevBundle")
19-
.orElse(minimumPaperDevBundleVersion)
20-
.get()
19+
val paperDevBundleVersion =
20+
providers
21+
.gradleProperty("mahjongPaperDevBundle")
22+
.orElse(minimumPaperDevBundleVersion)
23+
.get()
2124
val supportedPaperApiVersion = "1.20"
2225
val paperApiVersion = supportedPaperApiVersion
23-
val javaTargetVersion = providers.gradleProperty("mahjongJavaTarget")
24-
.map(String::toInt)
25-
.orElse(17)
26-
.get()
27-
val toolchainJavaVersion = providers.gradleProperty("mahjongJavaToolchain")
28-
.map(String::toInt)
29-
.orElse(if (Runtime.version().feature() >= javaTargetVersion) Runtime.version().feature() else javaTargetVersion)
26+
val javaTargetVersion =
27+
providers
28+
.gradleProperty("mahjongJavaTarget")
29+
.map(String::toInt)
30+
.orElse(17)
31+
.get()
32+
val toolchainJavaVersion =
33+
providers
34+
.gradleProperty("mahjongJavaToolchain")
35+
.map(String::toInt)
36+
.orElse(if (Runtime.version().feature() >= javaTargetVersion) Runtime.version().feature() else javaTargetVersion)
3037
val kotlinRuntimeVersion = "2.4.0"
3138
val kotlinSerializationVersion = "1.11.0"
3239
val mahjongUtilsVersion = "0.7.7"
@@ -49,12 +56,17 @@ repositories {
4956
}
5057

5158
// Codegen + native build tasks are registered via buildSrc convention helpers.
52-
val codegenTasks = MahjongTaskRegistration.registerCodegenTasks(
53-
project, generatedResourcesDir, project.version.toString()
54-
)
55-
val nativeTasks = MahjongTaskRegistration.registerNativeTasks(
56-
project, generatedNativeResourcesDir
57-
)
59+
val codegenTasks =
60+
MahjongTaskRegistration.registerCodegenTasks(
61+
project,
62+
generatedResourcesDir,
63+
project.version.toString(),
64+
)
65+
val nativeTasks =
66+
MahjongTaskRegistration.registerNativeTasks(
67+
project,
68+
generatedNativeResourcesDir,
69+
)
5870

5971
dependencies {
6072
paperweight.paperDevBundle(paperDevBundleVersion)
@@ -94,16 +106,24 @@ kotlin {
94106
}
95107

96108
paperweight {
97-
javaLauncher = javaToolchains.launcherFor {
98-
languageVersion.set(toolchainJavaVersion.map(JavaLanguageVersion::of))
99-
}
109+
javaLauncher =
110+
javaToolchains.launcherFor {
111+
languageVersion.set(toolchainJavaVersion.map(JavaLanguageVersion::of))
112+
}
100113
reobfArtifactConfiguration = io.papermc.paperweight.userdev.ReobfArtifactConfiguration.MOJANG_PRODUCTION
101114
}
102115

103116
tasks {
117+
withType<Detekt>().configureEach {
118+
jvmTarget.set(javaTargetVersion.toString())
119+
}
120+
104121
withType<org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile>().configureEach {
105122
compilerOptions {
106-
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.fromTarget(javaTargetVersion.toString()))
123+
jvmTarget.set(
124+
org.jetbrains.kotlin.gradle.dsl.JvmTarget
125+
.fromTarget(javaTargetVersion.toString()),
126+
)
107127
}
108128
}
109129

@@ -134,7 +154,7 @@ tasks {
134154
"h2Version" to h2Version,
135155
"hikariVersion" to hikariVersion,
136156
"kotlinRuntimeVersion" to kotlinRuntimeVersion,
137-
"kotlinSerializationVersion" to kotlinSerializationVersion
157+
"kotlinSerializationVersion" to kotlinSerializationVersion,
138158
)
139159
}
140160
}
@@ -163,7 +183,10 @@ tasks {
163183
systemProperty("mahjong.perf.batchSize", providers.gradleProperty("perfBatchSize").orElse("200").get())
164184
systemProperty(
165185
"mahjong.perf.reportDir",
166-
layout.buildDirectory.dir("reports/performance").get().asFile.absolutePath
186+
layout.buildDirectory
187+
.dir("reports/performance")
188+
.get()
189+
.asFile.absolutePath,
167190
)
168191
shouldRunAfter(test)
169192
}

config/detekt.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@ complexity:
66
active: true
77
LongMethod:
88
active: true
9-
threshold: 200
9+
allowedLines: 200
1010
LongParameterList:
1111
active: true
12-
functionThreshold: 12
13-
constructorThreshold: 12
12+
allowedFunctionParameters: 12
13+
allowedConstructorParameters: 12
1414
ComplexCondition:
1515
active: true
16-
threshold: 8
16+
allowedConditions: 8
1717
CyclomaticComplexMethod:
1818
active: true
19-
threshold: 30
19+
allowedComplexity: 30
2020
TooManyFunctions:
2121
active: false
2222
LargeClass:
2323
active: true
24-
threshold: 600
24+
allowedLines: 600
2525
NestedBlockDepth:
2626
active: true
27-
threshold: 8
27+
allowedDepth: 8
2828

2929
style:
3030
active: true

0 commit comments

Comments
 (0)