Kotlin M5.2: IntelliJ IDEA 12.1 and Gradle

Another update of Kotlin comes out today. Welcome Kotlin M5.2. 

Support for New IntelliJ IDEA

Koltin M5.2 supports (in fact, requires) the recently released IntelliJ IDEA 12.1.

The Kotlin IDE improvements include:

  • Kotlin classes in the Class Hierarchy view. Just hit Ctrl+H on a class name to see its descendants and/or parents.
  • Folding for imports (you don’t have to scroll through imports to get to your code any more).
  • New UI for Kotlin library configuration: you can now control library names and location, and kotlin-runtime.jar is not copied to your project by default. It just works.
  • Support for JavaScript-targeted modules is significantly improved.
  • Optimizing imports on the fly: IDE Settings -> Editor -> Auto Import -> Optimize imports on the fly.
  • New quick fixes: place the cursor on an error, and hit Alt+Enter.

SAM Constructors

When using Java libraries, you can now create an instance of a SAM interface (one with a Single Abstract Method) by calling its name and passing a function literal. For example:

This works only for Java classes. In fact, it is not a part of the language, but a feature of how Java classes are loaded into Kotlin: we define a synthesized function

So whenever you import Runnable, the function is there too, and you can use it.

This is the first chunk of SAM-conversion support for Java. Real SAM conversions will come soon, and you’ll be able to say simply

New Gradle Plugin

Starting with M5.2, in addition to the long-available Maven plugin, there’s a Gradle plugin for Kotlin from JetBrains.

Here’s an example for building a Kotlin module with Gradle:

More examples & docs can be found here.

Reminder: KAnnotator

Don’t forget that you now have KAnnotator at your service.

Have a nice Kotlin!

About Andrey Breslav

Andrey is the lead language designer of Kotlin at JetBrains.
This entry was posted in Releases and tagged . Bookmark the permalink.

8 Responses to Kotlin M5.2: IntelliJ IDEA 12.1 and Gradle

  1. Mario Arias says:

    How the SAM will work with methods that take parameters?, for example:

    interface Foo{
    int bar(String baz);

  2. Mario Arias says:

    Cool, now half of my project class are useless… 😀

  3. he guangyu says:

    Is kotlin plugin compatible with Android Studio?
    I have found scala plugin in Android Studio, but I don’t find kotlin plugin there.

  4. Stephen Samuel says:

    Any plans to introduce auto import for unambiguous imports?

  5. Pingback: Roadmap de #kotlin | Kotlin.es

Comments are closed.