Search code examples
gradleintellij-ideakotlinmicronaut

IntelliJ - Gradle - Kotlin - Micronaut - Changing files does not re-generate classes on "run"


I have a Kotlin-Micronaut v.1.0.2 project in IntelliJ and with Gradle v5.3. My running application has for example the following controller:

@Controller("/api/test")
class TestController {

    @Get
    fun helloWorld() = "Hello World"
}

In case I change any of this code, for example change the return value or add another REST method (e.g. POST), the necessary code will only be generated on a ./gradlew clean build. Hitting "Run" in IntelliJ will not generate the necessary endpoints for me (e.g. on adding a POST endpoint and trying to curl it, I get "Method not allowed" until I clean build).

Do you have any suggestions?


Solution

  • Enable Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Gradle | Runner | Delegate IDE build/run actions to Gradle option. This way IDE will use Gradle to generate and build classes according to logic of Gradle plugins you are using.