11import org.jetbrains.grammarkit.tasks.GenerateLexerTask
22import org.jetbrains.grammarkit.tasks.GenerateParserTask
33import org.jetbrains.intellij.platform.gradle.TestFrameworkType
4+ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
45import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
56
67plugins {
7- id( " org.jetbrains.intellij.platform " ) version " 2.0.1 "
8- id( " org.jetbrains .kotlin.jvm " ) version " 2.0.20 "
9- id( " org.jetbrains .grammarkit" ) version " 2022.3.2.2 "
8+ alias(libs.plugins.intellijPlattform)
9+ alias(libs.plugins .kotlin)
10+ alias(libs.plugins .grammarkit)
1011}
1112
1213repositories {
@@ -18,7 +19,7 @@ repositories {
1819
1920// Java target version
2021java {
21- sourceCompatibility = JavaVersion .VERSION_17
22+ sourceCompatibility = JavaVersion .VERSION_21
2223}
2324
2425sourceSets {
@@ -29,33 +30,36 @@ sourceSets {
2930
3031kotlin {
3132 java {
32- sourceCompatibility = JavaVersion .VERSION_17
33- targetCompatibility = JavaVersion .VERSION_17
33+ compilerOptions {
34+ jvmTarget = JvmTarget .JVM_21
35+ freeCompilerArgs = listOf (" -Xjvm-default=all" )
36+ }
37+ sourceCompatibility = JavaVersion .VERSION_21
38+ targetCompatibility = JavaVersion .VERSION_21
3439 }
3540}
3641
3742dependencies {
3843 intellijPlatform {
39- intellijIdeaCommunity(" 2024.2 .1" )
44+ intellijIdeaCommunity(" 2025.1 .1" )
4045
4146 bundledPlugins(listOf (" com.intellij.java" ))
42- instrumentationTools()
4347
4448 testFramework(TestFrameworkType .Platform )
4549 }
4650
4751 // From Kotlin documentation
48- implementation(" org.jetbrains. kotlin:kotlin-stdlib:1.8.22 " )
52+ implementation(libs. kotlin.stdlib )
4953 // just in case, version number specified in buildscript is used by default
50- implementation(" org.jetbrains. kotlin:kotlin-reflect:1.8.22 " )
54+ implementation(libs. kotlin.reflect )
5155
5256 // IntelliJ test framework needs junit 4.
53- testImplementation(" junit:junit:4.13 " )
54- testRuntimeOnly(" org .junit.vintage:junit-vintage-engine:5.7.0 " )
57+ testImplementation(libs.junit4 )
58+ testRuntimeOnly(libs .junit.vintage.engine )
5559
5660 // Use junit 5.
57- testImplementation(" org .junit.jupiter:junit-jupiter-api:5.7.0 " )
58- testRuntimeOnly(" org .junit.jupiter:junit-jupiter-engine:5.7.0 " )
61+ testImplementation(libs .junit.jupiter.api )
62+ testRuntimeOnly(libs .junit.jupiter.engine )
5963}
6064
6165// Configure Gradle IntelliJ Plugin
@@ -74,39 +78,30 @@ intellijPlatform {
7478}
7579
7680project(" :" ) {
77- val generateLexer = task< GenerateLexerTask >( " generateMyLexer " ) {
78- sourceFile.set(file( " src/main/grammar/KerboScript.flex " ))
79- targetOutputDir .set(file(" src/gen/ksp/kos/ideaplugin/parser " ))
80- // targetClass .set("KerboScriptLexer" )
81- purgeOldFiles.set(true )
82- }
83-
84- val generateParser = task <GenerateParserTask >(" generateMyParser" ) {
81+ val generateLexer =
82+ tasks.register< GenerateLexerTask >( " generateMyLexer " , fun GenerateLexerTask .() {
83+ sourceFile .set(file(" src/main/grammar/KerboScript.flex " ))
84+ targetOutputDir .set(file( " src/gen/ksp/kos/ideaplugin/parser " ) )
85+ purgeOldFiles.set(true )
86+ })
87+
88+ val generateParser = tasks.register <GenerateParserTask >(" generateMyParser" , fun GenerateParserTask .( ) {
8589 sourceFile.set(file(" src/main/grammar/KerboScript.bnf" ))
8690 targetRootOutputDir.set(file(" src/gen" ))
8791 pathToParser.set(" /ksp/kos/ideaplugin/parser/KerboScriptParser.java" )
8892 pathToPsiRoot.set(" /ksp/kos/ideaplugin/psi" )
8993 purgeOldFiles.set(true )
90- }
94+ })
9195
9296 tasks {
9397 withType<KotlinCompile > {
9498 dependsOn(generateLexer, generateParser)
9599 }
96100
97- // Set the compatibility versions to 17
101+ // Set the compatibility versions to 21
98102 withType<JavaCompile > {
99- sourceCompatibility = " 17"
100- targetCompatibility = " 17"
101- }
102-
103- listOf (" compileKotlin" , " compileTestKotlin" ).forEach {
104- getByName<KotlinCompile >(it) {
105- kotlinOptions {
106- jvmTarget = " 17"
107- freeCompilerArgs = listOf (" -Xjvm-default=all" )
108- }
109- }
103+ sourceCompatibility = " 21"
104+ targetCompatibility = " 21"
110105 }
111106
112107 publishPlugin {
0 commit comments