quarkus: Live reload doesn't work for kotlin, gradle kotlin dsl project

Describe the bug

i always have to restart the app whenever there’s a change

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

No response

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

About this issue

  • Original URL
  • State: open
  • Created 8 months ago
  • Reactions: 1
  • Comments: 18 (5 by maintainers)

Most upvoted comments

But the general problem is indeed that when we detect a change, we are not correctly passing the necessary configuration to the Kotlin compiler.

While I think this is a good workaround, I don’t think this is a satisfying overall fix because it requires a lot of manual configuration. I believe the problem is still Quarkus not passing the same arguments that the regular compiler gets to the dev compiler.

After a long fight with the kotlin compiler options, gradle and the quarkus-gradle-plugin i finally found a workaround, not pretty but it works:

dependencies {
   // ...

    // Important: Kotlin compiler plugin version must be the same as the Kotlin compiler version
    quarkusDev("org.jetbrains.kotlin:kotlin-allopen-compiler-plugin:1.9.10") 
}

// ...

tasks.quarkusDev {
    compilerOptions {
        compiler("kotlin").args(
            listOf(
                "-Xplugin=${configurations.quarkusDev.get().files.find { "kotlin-allopen-compiler-plugin" in it.name }}",
                "-P=plugin:org.jetbrains.kotlin.allopen:annotation=jakarta.ws.rs.Path",
                "-P=plugin:org.jetbrains.kotlin.allopen:annotation=jakarta.enterprise.context.ApplicationScoped",
                "-P=plugin:org.jetbrains.kotlin.allopen:annotation=jakarta.persistence.Entity",
                "-P=plugin:org.jetbrains.kotlin.allopen:annotation=io.quarkus.test.junit.QuarkusTest",
            )
        )
    }
}

Helpful links:

Hope this will be fixed soon, we are migrating all our quarkus projects to Gradle and this issue sounds that it will cause additional problems.

demo.zip

You can:

  • unpack the app
  • run curl localhost:8080/hello
  • Change RestResponse.ok("a") to RestResponse.ok("b")
  • run curl localhost:8080/hello again, which should crash the app.

Let me know if this helps.