1+ import dev.detekt.gradle.Detekt
12import org.gradle.api.tasks.testing.Test
23import 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
1415group = " top.ellan"
1516version = " 1.3.0-SNAPSHOT"
1617
1718val 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()
2124val supportedPaperApiVersion = " 1.20"
2225val 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)
3037val kotlinRuntimeVersion = " 2.4.0"
3138val kotlinSerializationVersion = " 1.11.0"
3239val 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
5971dependencies {
6072 paperweight.paperDevBundle(paperDevBundleVersion)
@@ -94,16 +106,24 @@ kotlin {
94106}
95107
96108paperweight {
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
103116tasks {
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 }
0 commit comments