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

EAP 1: 1.3.70-eap-42
EAP 2: 1.3.70-eap-184
EAP 3: 1.3.70-eap-274

For IntelliJ IDEA

You can switch to the Early Access Preview channel in Tools → Kotlin → Configure 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-274"

    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-274</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 the 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.

8 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.

1 Like

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.

1 Like

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

1 Like

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.

1 Like

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")
    }
}
3 Likes

I’ve been trying it out, I have some questions and feedback.

  1. Is there a way to add a build variant other than development/production? And how do you get the list of current build variants?

  2. It seems that the build/distribution task doesn’t have the correct dependencies, it will copy the resources if they have already been processed, but on a clean build they won’t copy.

  3. There isn’t a separation for distributions dev/prod.

  4. The kotlin plugin 1.3.70 now runs the default gradle task on refresh/import. Is this intentional? I had some default tasks set up instead of :help and now I have to change that.

  5. It would be very helpful to have a new project template for js/browser that has a simple index.html and have it work with the run tasks.

  1. Currently, we have only 2 built-in build variants: development and production. Customizing and adding new variants not supported yet. Can you describe your use case?
  2. Can you please fill an issue in http://kotl.in/issue? cc @Alexey.Belkov
  3. Yes, only production build is treated as build for distribution. Why you need dev distribution?
  4. This seems IntelliJ issue, sorry https://youtrack.jetbrains.com/issue/IDEA-231214 fix in progress
  5. We already have it: https://kotlinlang.org/docs/reference/js-project-setup.html. But the current project wizard is somewhat messy and it is hard to find JS, yes. We are working on a new project wizard, hopefully, it will be released in 1.3.70 also.

This seems like a bug. Can you please fill an issue in http://kotl.in/issue? cc @Alexey.Belkov

I updated my intellij to 2019.3.1 and its fixed now.
Based upon the number of likes (0), the fact that if you upgrade intellij you will receive it and the amount of information I probably can give (I think it’s almost nothing), I think I will skip this issue.

  1. It’s not so much that I need something other than dev and prod, I guess the main thing is that if I make custom tasks that use these build variants, I’d like an enumeration instead of assuming they exist. That list is available internally to kotlin, but I don’t know how to get that configuration information. This isn’t that important though, listOf(“development”, “production”) works well enough for now.
  1. Yeah, I’ll see if I even still have that problem, I found a big bug in my build code where I was doing configurations.all {} instead of configurations.forEach {} That seemed to cause some instabilities that may be related.

  2. I only need to distribute production code, but I need to launch and iterate on development code. How do you do this without a task to put the js and resources together?

  3. Thanks!

  4. The last time I tried that template it didn’t have an index.html at all (this was in 1.3.61), I wanted a template with an index.html that pointed to the correct js file from webpack and could be launched with the js browser development run task. Has this been updated in the 1.3.70 idea plugin?

1 Like

Thank you for feedback.

  1. You can run development server via ./gradlew run -t. It runs webpack-dev-server, which bundle your code in dev mode. And -t flag is responsible for live reload of your application with changes in your code.

seems that the build/distribution task doesn’t have the correct dependencies, it will copy the resources if they have already been processed, but on a clean build they won’t copy.

You’re right, it is bug

1 Like

1.3.70 EAP 2 is out!

Artifact version: 1.3.70-eap-184.
You can find the list of changes in the changelog.

Do we have an estimate on when this would be publicly released? Thank you!

1 Like