Micronaut-core: Improve Kotlin setup instructions for IntelliJ in guide

Created on 29 Jun 2018  路  4Comments  路  Source: micronaut-projects/micronaut-core

Task List

  • [x] Steps to reproduce provided
  • [x] Full description of the issue provided (see below)

Steps to Reproduce

  1. Create a new micronaut project:
    bash mn create-app micronaut-example --features kotlin --build maven
  2. Import project to Intellij
  3. Enable Annotation Processing in Intellij (as described here)
  4. Create the HelloController as indicated by the docs
  5. Configure the server to run on port 8080 in application.yml file
  6. Run the main method from inside Intellij
  7. Create a http test in Intellij, i.e. create a file called test.http with the following content:
    http GET http://localhost:8080/hello Accept: */*
  8. Run test.http

Expected Behaviour

Expecting the HelloController to return "Hello World"

Actual Behaviour

GET http://localhost:8080/hello

HTTP/1.1 404 Not Found
Date: Fri, 29 Jun 2018 09:11:14 GMT
content-type: application/json
content-length: 82

{
  "_links": {
    "self": {
      "href": "/hello",
      "templated": false
    }
  },
  "message": "Page Not Found"
}

Response code: 404 (Not Found); Time: 269ms; Content length: 82 bytes

Note that it works if I run the jar file manually from the command-line after having executed mvn clean install.

Environment Information

  • Operating System: MacOS
    -Intellij Version: Intellij Ultimate 2018.1.5
  • Micronaut Version: 1.0.0.M2
  • JDK Version: 1.8.0_144
kotlin docs question

Most helpful comment

@graemerocher - The guides talk about IntelliJ configuration for gradle. Anything has to be done for maven? I enabled annotation processing but running into the same problem as in this issue. Doing it through command line maven works fine, but running Application.kt through IntelliJ will not work until and unless I run it through the command line first.

Edit: Never mind. I am running the the maven install command through intellij just like the gradle "classes" task. I get this these warnings though.

[WARNING] 'tools.jar' was not found, kapt may work unreliably
[INFO] Applied plugin: 'all-open'
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.jetbrains.kotlin.kapt3.base.javac.KaptJavaFileManager (file:/Users/satb/.m2/repository/org/jetbrains/kotlin/kotlin-annotation-processing-maven/1.3.0/kotlin-annotation-processing-maven-1.3.0.jar) to method com.sun.tools.javac.file.BaseFileManager.handleOption(com.sun.tools.javac.main.Option,java.lang.String)
WARNING: Please consider reporting this to the maintainers of org.jetbrains.kotlin.kapt3.base.javac.KaptJavaFileManager
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[WARNING] warning: Supported source version 'RELEASE_8' from annotation processor 'org.jetbrains.kotlin.kapt3.base.ProcessorWrapper' less than -source '1.9'
[WARNING] warning: Supported source version 'RELEASE_8' from annotation processor 'org.jetbrains.kotlin.kapt3.base.ProcessorWrapper' less than -source '1.9'
[WARNING] warning: Supported source version 'RELEASE_8' from annotation processor 'org.jetbrains.kotlin.kapt3.base.ProcessorWrapper' less than -source '1.9'

Edit 2: Looks like java 9 isn't supported with kapt? Wow! Oracle is dropping support for java 8 and we still cannot move past it. Dropping to java 8 on the "Maven Runner" of IntelliJ made those warnings go away

I've observed that the memory requirements for a single hello world controller example is 165 MB on the Mac with Kotlin. Is that normal? To me it looks a little on the high side.

All 4 comments

Please see the section https://docs.micronaut.io/latest/guide/index.html#kotlin under "Kotlin, Kapt and IntelliJ"

Hopefully IntelliJ will add direct support in the future for Kapt without requiring an external build step

Thanks a lot for the fast reply. One suggestion might be to include this link in the guide. I assume that most people, like me, just read the guide and assume it to work.

Thanks for the feedback, will get it done.

@graemerocher - The guides talk about IntelliJ configuration for gradle. Anything has to be done for maven? I enabled annotation processing but running into the same problem as in this issue. Doing it through command line maven works fine, but running Application.kt through IntelliJ will not work until and unless I run it through the command line first.

Edit: Never mind. I am running the the maven install command through intellij just like the gradle "classes" task. I get this these warnings though.

[WARNING] 'tools.jar' was not found, kapt may work unreliably
[INFO] Applied plugin: 'all-open'
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.jetbrains.kotlin.kapt3.base.javac.KaptJavaFileManager (file:/Users/satb/.m2/repository/org/jetbrains/kotlin/kotlin-annotation-processing-maven/1.3.0/kotlin-annotation-processing-maven-1.3.0.jar) to method com.sun.tools.javac.file.BaseFileManager.handleOption(com.sun.tools.javac.main.Option,java.lang.String)
WARNING: Please consider reporting this to the maintainers of org.jetbrains.kotlin.kapt3.base.javac.KaptJavaFileManager
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[WARNING] warning: Supported source version 'RELEASE_8' from annotation processor 'org.jetbrains.kotlin.kapt3.base.ProcessorWrapper' less than -source '1.9'
[WARNING] warning: Supported source version 'RELEASE_8' from annotation processor 'org.jetbrains.kotlin.kapt3.base.ProcessorWrapper' less than -source '1.9'
[WARNING] warning: Supported source version 'RELEASE_8' from annotation processor 'org.jetbrains.kotlin.kapt3.base.ProcessorWrapper' less than -source '1.9'

Edit 2: Looks like java 9 isn't supported with kapt? Wow! Oracle is dropping support for java 8 and we still cannot move past it. Dropping to java 8 on the "Maven Runner" of IntelliJ made those warnings go away

I've observed that the memory requirements for a single hello world controller example is 165 MB on the Mac with Kotlin. Is that normal? To me it looks a little on the high side.

Was this page helpful?
0 / 5 - 0 ratings