Kotlin 1.2.20 offers IDE support for the new Kotlin style guide

JAX Editorial Team

© Shutterstock / Michael.P

Kotlin 1.2.20 is a new bugfix and tooling update for Kotlin 1.2. Let’s take a look at what’s in this update.

Kotlin 1.2.20 is here. This bugfix and tooling update for Kotlin 1.2 is compatible with all versions of IntelliJ IDEA from 2017.1 until 2017.3, and also with Android Studio 3.0 and 3.1 Canary.

Dmitry Jemerov, Principal Engineer at JetBrains wrote in the blog post announcing the update that it:

  • Adds support for Gradle build cache
  • Improves incremental compilation for Android and mixed Kotlin/Java projects
  • Provides IDE support for the new Kotlin style guide
  • Adds inlay hints in the editor for implicit parameters and receivers of lambdas, as well as values returned from lambdas
  • Supports development mode in JavaScript DCE Gradle task
  • Introduces new inspections, performance improvements and bug fixes in the IntelliJ plugin

Check out the changelog if you’re interested in the complete list of changes.

SEE ALSO: Kotlin 1.2: Multiplatform projects across the JVM and JavaScript

Compilation performance improvements

In this update, most of the improvements are related to the Gradle plugin. Speaking of, one of the improvements is the support for Gradle build cache.

If you’re using Gradle 4.3 or newer and the build cache is enabled (it’s not by default, requires --build-cache or org.gradle.caching=true), the plugin will reuse compilation results from previous executions of the Kotlin compile task, Jemerov explained.

As mentioned above, “build caching for Kotlin annotation processors is disabled by default because the dependencies of annotation processors cannot be tracked precisely by Gradle, so it may incorrectly reuse results of a previous execution of an annotation processor.”

If you want to enable it anyway, all you need to do is add these lines to the build script:

`kapt {
    useBuildCache = true

Another improvement is more precise tracking of changes in Java files, which allows you to avoid Kotlin recompilation when the changes in Java do not affect Kotlin code.

Keep in mind that this feature is experimental, so you’ll have to add this line to your gradle.properties file if you want to enable it:


Last but not least, changes to Android layout XML files no longer cause recompilation of all Kotlin sources. As of now, only Kotlin files that reference properties generated by Kotlin Android Extensions (kotlinx.android.synthetic.*) are recompiled.

The formatter fully supports the new Kotlin style guide

new official Kotlin style guide was recently released, covering the formatting of Kotlin code and the idiomatic use of language and library features. As of now, the formatter fully supports the new style guide. Plus, IntelliJ IDEA inspections can detect (and correct with quick fixes) many style guide violations can be detected.

Keep in mind that the formatting suggested by the new style guide is different from the default formatting previously used by the Kotlin plugin so you’ll have to apply the new guide explicitly in order to avoid unwanted formatting changes. To do that, go to Settings | Editor | Code Style | Kotlin and use the “Set from…” link to choose the code style.

JavaScript DCE development mode

The JavaScript dead code elimination (DCE) plugin will come in handy if you need to reduce the output size of the Kotlin to JavaScript compiler. The DCE process takes a bit of extra time, Jemerov warned, and the output size doesn’t matter during development, so you can now disable dead code elimination.

In order to do that, you’ll have to use the following option:

runDceKotlinJs.dceOptions.devMode = true 

Check out Dmitry Jemerov’s blog post for the complete list of highlights.

comments powered by Disqus