Not sure where the best place to ask is, so will s...
# intellij
m
Not sure where the best place to ask is, so will start here. IntelliJ 2018.3.4 and 2019.1 EAP exhibit this issue. Gradle 4.10.2 and Gradle 5.2.1. build.gradle sets jvmTarget to 1.8. Project compiles fine from CLI. When I import the project into IntelliJ, it’s incorrectly setting the jvmTarget on the module as it remains at 1.6, rather than being set at 1.8. I know this worked correctly in the past, and am not sure when it stopped working. This is a problem with certain inline functions and other things, so IntelliJ always reports errors in a couple of my modules as a result. I can manually change the jvmTarget to workaround it, but everytime I refresh the Gradle project, it obviously gets reverted. Anyone else having issues with this? Have a workaround, or know if there’s a ticket? Because it involves so many things, it’s difficult to search for.
c
I frequently have t do gradle refresh and haven't noticed this problem neither in 2018.* nor in 2019 EAP versions. This is probably specific to your build. Can you share more details? How is your build structured and the snippet where you set the
jvmTarget
?
o
Also have this this issue, appeared yesterday, or may be earlier Nothing helped, nor invalidate caches, nor refresh gradle, nor switch even to community/ultimate/18.3/19.1
m
Well, I guess that’s good news. Thank you for letting me know. Can’t really share build, but at least now I know I’ll have to start digging into it. The jvmTarget is set in a custom plugin. Worked fine before, so perhaps something has broken recently, or changed in the way it needs to be set for IntelliJ to recognize it. Time to start pulling the pieces apart. Although I removed the plugin, and manually defined the jvmTarget using:
Copy code
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
    kotlinOptions {
        jvmTarget = '1.8'
    }
}
o
But checked in clear project with almost same configuration - and it's work also setting target work in with mpp plugin only with plain kotlin plugin it doesn't work in another project, something strange
m
Hmmm, so something unique about my environment then. I just tried an invalidate cache/restart, but that didn’t help. Again, thank you for letting me know it’s working ok for you. I’ll just have to keep digging…
What version of Kotlin are you using? Experimenting with a project, and it works with 1.2.71, and breaks with 1.3.21
And I mean same IntelliJ with same Kotlin plugin, just changing this line:
Copy code
id 'org.jetbrains.kotlin.jvm' version '1.2.71'
in build.gradle
o
1.3.20 and 1.3.21 checked only will try on 1.2.71 now
c
There were some changes for
1.3.21
, for one 1.8 target should now be default, so you could try to remove it altogether
o
1.3.0 and 1.3.10 - also works for me, so problem is in 1.3.20 when remove target for 1.8 on 1.3.20/13.21 - nothing happens, default target is 1.6 also, FYI, I use gradle kotlin script
m
I use gradle groovy script, but at least it appears IntelliJ is consistent across those two. For some reason, it’s not resolving correctly for 1.3.20+. Found a related ticket, so I’ll update it with a sample project. Thank you all for your efforts on this. Much appreciated! https://youtrack.jetbrains.com/issue/KT-24662
o
https://youtrack.jetbrains.com/issue/KT-29564 in related ticket there is a way, how to fix this issue! Thank you!
m
I haven’t turned that on. Is it on by default? I didn’t think it was yet.
o
no, it's false by default, but in my project it was set to true, then i comment this line, and everything now work perfect
m
Doh! yes, this is my issue. When I read about it, I put it into my User gradle.properties… So I have it on for ALL projects. Just disabled, and IntelliJ now working correctly. THANK YOU! side note. I have auto-import turned off. When I saved my user gradle.properties, IntelliJ was aware enough to let me know something had changed, and I should re-import my project.