Issues with making a Maven project with Kotlin

Hi all,

I created a new Maven project in IntelliJ IDEA 15.0.3. Then, I added kotlin directories under src/main/ and src/test/.

I created a new .kt file, then had IntelliJ automatically set up the pom.xml file to import the Kotlin dependencies. I also see them under the External Libraries pane.

Unfortunately, I can’t get the project to run if I refer to certain Kotlin stdlib functions (like println()), some of them seem to work fine (like intArrayOf()).

I tried invalidating the caches and restarting, but that didn’t work.

What am I missing? Screenshots attached.

Thanks

I’ve tried these steps and it works fine for me.

When you compile your project with maven (mvn compile in command line), does it succeed?
If yes, you may need to reimport maven projects to IDEA.

mvn compile worked. I removed .idea directory and the .iml file and recreated the project, same thing unfortunately. I also made sure to point IntellJ to my local mvn installation, instead of using the one that ships with IntelliJ.

I have attached the pom.xml file:

pom.xml (2.2 KB)

Edit: I’m going to try reinstalling IntelliJ 15. I had imported some settings from IntelliJ 14, and I’m wondering if that may have caused some issues.

I found if I replaced

<kotlin.version>1.0.0-rc-1036</kotlin.version>

with

<kotlin.version>1.0.0-beta-4589</kotlin.version>

In the pom.xml file, the project compiles and runs successfully from the IDE. I came across this thread: jvm - Kotlin unresolved reference in IntelliJ - Stack Overflow where the response was to make sure that the IDEA Kotlin plugin version and the compiler and runtime versions match.

Where do I set this in IntelliJ, so that I can use the RC version of Kotlin? Note that when I switch between the versions in the pom.xml file, the respective runtime and stdlib jars are downloaded and placed under External Libraries. They are being updated correctly, but the RC version produces the error in the first post above.

Thanks

In IDEA you can check version of Kotlin plugin in “File → Settings → Plugins”.
Find Kotlin plugin there and check what version do you have, update if necessary.

Before update:

After update:

That worked! Thanks @ilya.gorbunov.