Use Kotlin in Platform

Hi, recently I’m trying to learn new JVM language: Kotlin.
And although still learning, I notice that this language is really powerful. And the thing I like, really 100% interoperable with Java.

I’m trying to use it in my project, and it works well. I was wondering if CUBA team want to automate it with Studio. But if you wanna know, here’s what I do:

  • Use IntelliJ IDEA, for the Kotlin plugin is already included
  • Modify build.gradle, as following:

buildscript {
    ....
    dependencies {
        classpath "com.haulmont.gradle:cuba-plugin:$cubaVersion"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
        classpath "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlinVersion"
    }
}
...
apply(plugin: 'org.jetbrains.kotlin.jvm')

....
configure([globalModule, coreModule, guiModule, webModule, portalModule]) {
    ....
    apply(plugin: 'org.jetbrains.kotlin.jvm')
    ....
    dependencies {
        ...
        compile ('org.jetbrains.kotlin:kotlin-stdlib-jre8:1.1.1')
    }
}

And based on the tutorial in Kotlin Website, you can directly use Java classes, interfaces, and annotations just like that.

That’s why I really like it.

Hi, I’m really interested to see kotlin support in CUBA, especially in Studio (code generation et al). Given that the app is not OSS, I can’t extend it myself, so I’d like to see a feature request opened for this…

I’m pretty confident that kotlin will be more and more adopted by the enterprise as well small shops (esp. after google announcement at IO), and as for me I stopped writing java code almost altogether.

Regarding the platform itself, I don’t think it should be anything that hard to support kotlin, I used it with Spring and other complex frameworks with almost any issue.

Thanks
Paolo

Hi guys,
The feature request is opened - see the link to YouTrack. Let’s collect more votes for this idea.

6 Likes

:ticket: See the following issue in our bug tracker:

https://youtrack.cuba-platform.com/issue/STUDIO-3719

Thanks Yosi! I applied your build.gradle changes and kotlin was up&running in no time :smile:

Konstantin, how to add votes to this idea? I checked the youtrack issue but I have no clue how to vote it up!

cheers

Hi,

we are voting right here in Ideas category:

image

Just click on Vote button in the topic title.

2 Likes

I’ve just been looking at the Gradle build stuff, and I notice that a few Kotlin related tasks have been added. What are they for?

We’re working on Kotlin support. The work is in progress.

Epics in framework and studio:

https://youtrack.cuba-platform.com/issue/STUDIO-3719

We’ll describe everything in the release notes as soon as it’s ready

1 Like

This is excellent news!

2 Likes

Hot deploy feature for Kotlin-based screens’ controllers would be extremely useful!

A post was split to a new topic: Semi-colon after the package statement