Kotlin logo

Kotlin

A concise multiplatform language developed by JetBrains

Events

Gradle Meets Kotlin

Back at JavaOne 2015, during a lunch break we started chatting with Hans Dockter, CEO of Gradle. A couple of days after the conference, a few of us were at the Gradle offices talking about what would be the beginning of the collaboration between JetBrains and Gradle; to bring first-class tooling and support for a static language to Gradle.

Today, at the Kotlin Night in San Francisco, Hans Dockter demoed the first milestone of writing a Gradle build script using Kotlin.

import org.gradle.api.plugins.*
import org.gradle.api.tasks.wrapper.*
import org.gradle.script.lang.kotlin.*

apply<ApplicationPlugin>()

configure<ApplicationPluginConvention> {
    mainClassName = "samples.HelloWorld"
}

repositories {
    jcenter()
}

dependencies {
    "testCompile"("junit:junit:4.12")
}

Gradle allows developers and build engineers to deal with complex build automation scripts. As complexity grows, having a language that is statically typed can help detect potential misconfigurations at compile time, contributing in reducing runtime issues. Static typing also opens up the door to more sophisticated tooling. All this, combined with key characteristics of Kotlin that enable easy creation of DSLs, can provide Gradle users benefits while maintaining the level of fluency they are accustomed to.

For the past 6 months, we’ve been working closely with the Gradle team, in particular with Chris Beams and Rodrigo de Oliveira, in bringing Kotlin to Gradle. It has been a tremendously rewarding experience because it has also helped us see use-case scenarios for making scripting in Kotlin a first-class citizen.

We are very excited for what Gradle has in store and are happy to continue collaborating with their team closely in bringing a great experience to Gradle users.

For more information and how to get the bits to start playing with this, make sure you read the blog post by the Gradle team for more details. In addition, if you are on the public Kotlin Slack, there’s a newly created #gradle channel for discussions.

image description