Kotlin 1.3.70 Early Access Preview

Hello! We are happy to announce the first Early Access Preview (EAP) build for Kotlin 1.3.70.

Highlights

  • .gradle.kts support enhancements
    • We are happy to introduce the reworked IDE support for .gradle.kts files. Starting from this EAP, Kotlin plugin imports script dependencies during the Gradle project sync. The change improves user experience with the first script opening significantly. Note that the functionality requires at least Gradle 6.0 and IntelliJ IDEA 2019.2.
    • Also, we minimized the number of requests to the Gradle daemon for script dependencies synchronization. It allowed us to reduce CPU load and speed up highlighting and completion. The change is especially noticeable on large projects.
    • We still work on improving the user experience for script files. If you notice any glitches, please share your feedback with us.
  • Kotlin/JavaScript
    • Optimized bundle for the browser. You can try it by creating a new Kotlin/JS browser project and calling build task. There are two build variants: production and development. Production variant is used by default on build task, and development – on run.
    • Some tasks changed names: browserWebpack is now called browserProductionWebpack, and browserRun is now browserDevelopmentRun. Old tasks are still available, but no longer configurable as webpack tasks. Please update the task names in your build scripts.
    • build/distribution directory now includes resources from src/main/resources (HTML, CSS, images, and so on), so you can simply publish its contents. Of course, gradle run also uses the distribution directory.
    • Now you can declare NPM dependencies right in the root dependencies section:
      dependencies {
          implementation(npm("react", "16.12.0"))
      }
      
    • IDEA Ultimate: you can start the Kotlin/JS debug session by clicking on an icon near the test method name. Also, you can start debugging by manually choosing nodeRun, nodeTest or browserTest task in the Gradle tool window. For browserRun, you can attach debugger after running the development server using the “Attach to Node.js/Chrome” run configuration.
    • Test results for Kotlin/JS and Kotlin/Native are displayed right in the IDE, as it has always been for JVM tests. Besides, we fixed test filtering for Kotlin/JS, so you can run individual tests.

You can find the complete list of changes in the changelog.

Getting the EAP build

For IntelliJ IDEA

You can switch to the Early Access Preview channel in ToolsKotlinConfigure Kotlin Plugin Updates. Change the update channel to ‘Early Access Preview 1.3.x’ and press Check for updates now.

Command-line compiler

Compiler binaries are available on the GitHub release page.

Multi-platform libraries

We prepared a set of multi-platform libraries compatible with this EAP:

For Gradle

Add the https://dl.bintray.com/kotlin/kotlin-eap repository URL to the list of project repositories. Here is how to do this in Gradle:

buildscript {
    ext.kotlin_version = "1.3.70-eap-42"

    repositories {
        maven { url "https://dl.bintray.com/kotlin/kotlin-eap" }
    }

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

apply plugin: "kotlin"

repositories {
    maven { url "https://dl.bintray.com/kotlin/kotlin-eap" }
}

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib"
}

For Maven

As with using Gradle, add the EAP repository:

<project ...>
    <properties>
        <kotlin.version>1.3.70-eap-42</kotlin.version>
    </properties>

    <repositories>
        <repository>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <id>bintray.kotlin.eap</id>
            <name>Bintray Kotlin EAP Repository</name>
            <url>https://dl.bintray.com/kotlin/kotlin-eap</url>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <id>bintray.kotlin.eap</id>
            <name>Bintray Kotlin EAP Repository</name>
            <url>https://dl.bintray.com/kotlin/kotlin-eap</url>
        </pluginRepository>
    </pluginRepositories>

    <dependencies>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib</artifactId>
            <version>${kotlin.version}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-maven-plugin</artifactId>
                <version>${kotlin.version}</version>
                ...
            </plugin>
        </plugins>
    </build>
</project>

We kindly ask you to provide feedback and report issues to our issue tracker. Please don’t forget to specify version of your IDE, Kotlin plugin and build systems, as well as whether the new type inference is enabled or not.

External contributions

We would like to thank all our external contributors whose pull requests were included in this EAP: pyos, Steven Schäfer, Toshiaki Kameyama, Mark Punzalan, Mads Ager, Kristoffer Andersen, Jiaxiang Chen, Ivan Gavrilovic, Kevin Bierhoff, Juan Chen, Jens Klingenberg, Tillmann Berg, Dmitry Borodin, Louis CAD, Jim Sproch, Victor Turansky, Alexander Shustanov, Efeturi Money, Kerooker, Jordan Demeulenaere, Burak Eregar, Dat Trieu, DmiitriiJarosh.

7 Likes

Probably I am just being a bit thick here, but:
What is a “script dependency”? What does it mean to “import during sync”? And most importantly: What exactly is improved significantly (other than “experience”)?

Script Dependencies is a list of external libraries available for the script. For *.gradle.kts scripts they are coming from the applied plugins. Those dependencies are provided by Gradle and are used in IDE for highlighting, completion and other IDE functionalities. Before 1.3.70 Kotlin Plugin requested them on the first script opening. Now it imports all script dependencies during the Gradle Project Sync (Gradle Tool Window -> Refresh button). This means that when the build script is opened Kotlin Plugin doesn’t need anymore to do a request to Gradle. We will describe this mechanism more detailed in the 1.3.70 Blog Post.

Thanks a lot for the explanation!

Does this mean that the reimport of gradle build files is slower now (because it also does script dependency import)?

Performance of gradle sync affects everybody in the team all the time.
Performance of opening build files affects only some people only occasionally.

Don’t think it does. It needed to import the script dependencies at that time anyways, because they are needed to build the gradle.build.kts script. My guess is that they are just saving those dependencies instead of reloading them every time a script is opend.

Yes, @Wasabi375 is right. No overhead expected in Gradle Project Sync.

I have kotlin 1.3.61-release-ij2019.2-1.
When I try to sync in Intellij on either EA 1.3 or EA 1.4 it tells that I have the latest version.

Are there somewhere caches in Intellij that I can clear to get the update?

Works great for the browser() config, what’s the plan on the nodeJs() side?
Is there a plan to add minification and packing for frontend projects?
So we don’t have to move the node_modules folder in production.

Why do you need to minify nodeJs application? AFAIK, generally, they are deployed as is, since the code size is not a problem on the server side.

You are right, they are generally deployed as is since there is not a huge performance impact.
I’m used to using grunt or browserify to reduce the size on disk, and the upload time, having a lot of dependencies and limited disk space.

FYI
If you are using build.gradle.kts like I do, you need to add the kotlin-eap repo to the settings.gradle.kts.
For example:

rootProject.name = "YOUR PROJECT NAME"

pluginManagement {
    repositories {
        jcenter()
        gradlePluginPortal()
        maven(url = "https://dl.bintray.com/kotlin/kotlin-eap")
    }
}