35

In IntelliJ you can set the target Java version like this:

enter image description here

Unfortunately I don't see a place where I can do the same for Kotlin. This makes it not possible for me to use Quasar-Kotlin. I want to switch to M14 even though I have 1.0 beta installed. How can I change back?

After changing the build.gradle file back to M14 I am greeted with compilation errors in my project.

enter image description here

My build.gradle: https://gist.github.com/Jire/5b517fd767ad498bc18f

dafnap
  • 15
  • 4
Jire
  • 9,680
  • 14
  • 52
  • 87

5 Answers5

72

Go to Intellij Preferences -> Build, Execution, Deployment -> Kotlin Compiler. Update Language version and Api version to the one you wish.

(You can also use cmd + shift + A and type Kotlin Compiler to get to this preference)

enter image description here

Defuera
  • 5,356
  • 3
  • 32
  • 38
14

Precondition:

The compiler bundled to Kotlin plugin (IDE) must be greater or equal than external compiler (project) used for building modules. So update Intellij IDEA to be compatible with the most up-to-date plugins.

Help > Check for Updates

Check for Updates

Note: If you do not have the most updated version in Language and API version you will not be able to see the latest version of the plugin.


1- Install a new version of the compiler

  • Languages & Frameworks > Kotlin
  1. Check version: 1.3.61
  2. Update channel: Early Access Preview 1.4x and press Check again
  3. A new version 1.4-M3-xxx is available and press Install
  • Invalidate Caches & Restart

  • Observe in Languages & Frameworks > Kotlin that:

You have the latest version of the plugin installed.

  • Build, Execution, Deployment > Compiler > Kotlin Compiler
  1. Language and API version: Change from 1.2 To Latest stable 1.4-M3 (if the Latest stable 1.4-M3 version do not appear, so update the IDE)

Finally, check version in Project Settings > Modules > Module SDK > Kotlin SDK: 1.4-M3

2- Update compiler version in project

I recommend is to synchronize gradle with a non-existent version in order to clean the external libraries. This is because it could happen that our libraries continue to use the old version of the compiler after updating.

  1. For example: change from 1.4-M3 to 1.4.20-M1

build.gradle.kts

plugins {
    kotlin("jvm") version "1.4-M3" apply false 
}
  1. It is important to synchronize with a wrong version like X to clean the external libraries with which we would get the following message.

build.gradle.kts

plugins {
    kotlin("jvm") version "X" apply false 
}

Message

  1. Then we define and synchronize with the new version.

build.gradle.kts

plugins {
    kotlin("jvm") version "1.4.20-M1" apply false 
}

GL

Kotlin versions

Braian Coronel
  • 22,105
  • 4
  • 57
  • 62
11

You can't do this at the moment. Building your project in IntelliJ IDEA always uses the version of the Kotlin compiler bundled with the plugin, regardless of what your build.gradle file says. If you need to downgrade to M14, you need to install the M14 version of the plugin.

yole
  • 92,896
  • 20
  • 260
  • 197
  • How can I downgrade to the M14 version of the plugin? – Jire Oct 22 '15 at 18:10
  • 1
    I have v1.0.0-beta of the plugin installed and I am able to run his build.gradle without any problems. – Jeremy Lyman Oct 22 '15 at 18:13
  • To downgrade you'd have to manually install the plugin right? I wonder if I can build and you cant due to the gradle cache mentioned in your output? Maybe Yole can provide more insight. – Jeremy Lyman Oct 22 '15 at 18:27
2

The kotlin versions are defined in your build.gradle file.

See the following example :

build.gradle

Jeremy Lyman
  • 3,084
  • 1
  • 27
  • 35
  • This is what I thought however I had changed the version to the latest M14 and it no longer will compile. `build.gradle` seems to specify the library version of Kotlin rather than the compiler. My `build.gradle`: https://gist.github.com/Jire/5b517fd767ad498bc18f – Jire Oct 22 '15 at 17:50
  • Updated original question with image of build attempt. – Jire Oct 22 '15 at 17:52
  • Yes, I am using the latest IntelliJ EAP and Kotlin plugin. – Jire Oct 22 '15 at 17:56
  • Try syncing gradle, gradle clean and if all else, deleting your build directory? – Jeremy Lyman Oct 22 '15 at 18:04
  • Tried and it did not work. @yole says that it's not possible yet and that I'd have to downgrade to the M14 version. – Jire Oct 22 '15 at 18:11
1

File => Settings => Build,Execution,Deployment => Compiler => Kotlin Compiler. you getlike this image, and here you camchange version of kotlin compiler. enter image description here

Mounir bkr
  • 1,069
  • 6
  • 6