Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building Developer Tools with Kotlin and Gradle

Building Developer Tools with Kotlin and Gradle

Kotlin is a new JVM language that offers increased null- and type-safety, support for building custom DSLs, and many functional idioms from Scala and Groovy. But one of the main advantages of using Kotlin is its tooling support. Now with Gradle, automating complex builds is now possible in Kotlin, letting you write tools and build logic in the same language. In this session, I will demonstrate how I rebuilt and maintain AceJump, a popular plugin for the IntelliJ Platform SDK using Kotlin and Gradle. We will discuss strategies for converting your existing Java code to Kotlin, how to configure Gradle to use Kotlin build scripts, and a Gradle plugin for building the IDE. This session will also cover the IntelliJ Platform SDK, a set of APIs that lets you build smarter developer tools ontop of the same platform that powers IntelliJ IDEA and its cousins. Attendees should have some basic familiarity with either Kotlin or Gradle in order to benefit from this session.

Breandan Considine

April 26, 2017
Tweet

More Decks by Breandan Considine

Other Decks in Programming

Transcript

  1. Why Developer Tools? • Syntax manipulation • Typing completions •

    Static code analysis • UI/UX components • Language support • Framework support
  2. Why Kotlin? • IntelliJ Platform / Eclipse integration • Java

    language / JVM interoperability • Simplifies framework interactions • Domain specific languages • Functional programming • Build tools integration
  3. Why Gradle? • Comprehensive tooling support • Cross-platform IDE •

    Gradle tooling API • Language-native buildscripts • Vibrant plugin ecosystem • Gradlew is awesome!
  4. public class Singleton { private Singleton() {} private static instance;

    public static Singleton getInstance() { if(instance == null) instance = new Singleton(); return instance; } public void doSomething() {} } 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: Singleton pattern: Java
  5. public class Singleton { private Singleton() {} private static instance;

    public static Singleton getInstance() { if(instance == null) instance = new Singleton(); return instance; } public void doSomething() {} } 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: Singleton pattern: Java
  6. Extend any library class fun String.wordCount(s: String) { return s.split("

    ") .filter { it.length > 3 } } "hello to the world".wordCount()
  7. UI Configuration 1: val panel = panel { 2: noteRow("Login:")

    3: row("Username:") { userField() } 4: row("Password:") { passwordField() } 5: row { 6: rememberCheckBox() 7: right { 8: link("Forgot?") { browse(forgot) } 9: } 10: } 11: noteRow("No account? $signupLink") 12: }
  8. Gradle Script Kotlin (GSK) buildscript { repositories { gradleScriptKotlin() }

    dependencies { classpath(kotlinModule("gradle-plugin")) } }
  9. Gradle Plugins plugins { id("org.jetbrains.intellij") version "0.2" } apply {

    plugin("org.jetbrains.intellij") plugin("kotlin") }
  10. Gradle IntelliJ Plugin // Also useful for OSS contributors! intellij

    { runIde { args project.projectDir.path } downloadSources = false } // Run `./gradlew runIde` to open project
  11. Links and Resources • Kotlin for Plugin Developers • Kotlin

    Gradle Plugin • Gradle Script Kotlin (GSK) • gradle-intellij-plugin • Kotlin Plugin for Eclipse • goomph: IDE as a build artifact • GIDS Plugin (from live code)