Skip to content

Commit

Permalink
feat: add kotlin compiler args to gradle plugin
Browse files Browse the repository at this point in the history
Fixes #2343
  • Loading branch information
taefi committed Jan 14, 2025
1 parent 52484b9 commit 0755b2c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/java/gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
id 'maven-publish'
id 'idea'
id 'com.gradle.plugin-publish' version '0.11.0'
id 'org.jetbrains.kotlin.jvm' version '1.9.20-Beta2'
id 'org.jetbrains.kotlin.jvm' version '1.9.25'
id 'org.jetbrains.dokka' version '1.9.0'
}

Expand Down Expand Up @@ -66,14 +66,14 @@ repositories {
}

dependencies {
implementation('org.jetbrains.kotlin:kotlin-stdlib:1.9.20')
implementation('org.jetbrains.kotlin:kotlin-stdlib:1.9.25')
implementation("com.vaadin:hilla-endpoint:$version")
implementation("com.vaadin:hilla-engine-core:$version")
implementation("com.vaadin:flow-gradle-plugin:$flowVersion")
implementation("org.springframework.boot:spring-boot-loader-tools:$springBootVersion")

testImplementation("junit:junit:4.13.2")
testImplementation("org.jetbrains.kotlin:kotlin-test:1.9.20")
testImplementation("org.jetbrains.kotlin:kotlin-test:1.9.25")
}

idea {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import com.vaadin.hilla.engine.EngineConfiguration
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.file.DuplicatesStrategy
import org.gradle.api.internal.provider.DefaultListProperty
import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.tasks.Copy
import org.gradle.api.tasks.SourceSet
Expand Down Expand Up @@ -56,6 +57,16 @@ public class HillaPlugin : Plugin<Project> {
}
}

// Configure Kotlin-specific tasks only if Kotlin JVM plugin is applied
project.plugins.withId("org.jetbrains.kotlin.jvm") {
project.tasks.named("compileKotlin").configure { task ->
val compilerOptions = task.javaClass.getMethod("getCompilerOptions").invoke(task)
val freeCompilerArgs = compilerOptions.javaClass.getMethod("getFreeCompilerArgs")
.invoke(compilerOptions) as DefaultListProperty<String>
freeCompilerArgs.addAll(listOf("-Xjsr305=strict", "-Xemit-jvm-type-annotations"))
}
}

project.tasks.withType(Jar::class.java) { task: Jar ->
task.mustRunAfter("vaadinBuildFrontend")
}
Expand Down

0 comments on commit 0755b2c

Please sign in to comment.