Top Banner
21

Kotlin Developer Tools · 2017-07-19 · Building Developer Tools with Kotlinand Gradle Breandan Considine GIDS 2017. ... •Language support •Framework support. Why Kotlin? •IntelliJ

Jul 31, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Kotlin Developer Tools · 2017-07-19 · Building Developer Tools with Kotlinand Gradle Breandan Considine GIDS 2017. ... •Language support •Framework support. Why Kotlin? •IntelliJ
Page 2: Kotlin Developer Tools · 2017-07-19 · Building Developer Tools with Kotlinand Gradle Breandan Considine GIDS 2017. ... •Language support •Framework support. Why Kotlin? •IntelliJ

BuildingDeveloperToolswithKotlin andGradle

BreandanConsidineGIDS2017

Page 3: Kotlin Developer Tools · 2017-07-19 · Building Developer Tools with Kotlinand Gradle Breandan Considine GIDS 2017. ... •Language support •Framework support. Why Kotlin? •IntelliJ

WhyDeveloperTools?• Syntaxmanipulation• Typingcompletions• Staticcodeanalysis• UI/UXcomponents• Languagesupport• Frameworksupport

Page 4: Kotlin Developer Tools · 2017-07-19 · Building Developer Tools with Kotlinand Gradle Breandan Considine GIDS 2017. ... •Language support •Framework support. Why Kotlin? •IntelliJ

WhyKotlin?• IntelliJPlatform/Eclipseintegration• Javalanguage/JVMinteroperability• Simplifiesframeworkinteractions• Domainspecificlanguages• Functionalprogramming• Buildtoolsintegration

Page 5: Kotlin Developer Tools · 2017-07-19 · Building Developer Tools with Kotlinand Gradle Breandan Considine GIDS 2017. ... •Language support •Framework support. Why Kotlin? •IntelliJ

WhyGradle?• Comprehensivetoolingsupport• Cross-platformIDE• Gradle toolingAPI

• Language-nativebuildscripts• Vibrantpluginecosystem• Gradlew isawesome!

Page 6: Kotlin Developer Tools · 2017-07-19 · Building Developer Tools with Kotlinand Gradle Breandan Considine GIDS 2017. ... •Language support •Framework support. Why Kotlin? •IntelliJ

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:

Singletonpattern:Java

Page 7: Kotlin Developer Tools · 2017-07-19 · Building Developer Tools with Kotlinand Gradle Breandan Considine GIDS 2017. ... •Language support •Framework support. Why Kotlin? •IntelliJ

Singleton.doSomething()

Singletonpattern:Java

Singleton.getInstance().doSomething();

Page 8: Kotlin Developer Tools · 2017-07-19 · Building Developer Tools with Kotlinand Gradle Breandan Considine GIDS 2017. ... •Language support •Framework support. Why Kotlin? •IntelliJ

Singleton.doSomething()

object Singleton {fun doSomething() {}

}

Singletonpattern:Kotlin1:2:3:

LazyInitialization

Page 9: Kotlin Developer Tools · 2017-07-19 · Building Developer Tools with Kotlinand Gradle Breandan Considine GIDS 2017. ... •Language support •Framework support. Why Kotlin? •IntelliJ

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:

Singletonpattern:Java

Page 10: Kotlin Developer Tools · 2017-07-19 · Building Developer Tools with Kotlinand Gradle Breandan Considine GIDS 2017. ... •Language support •Framework support. Why Kotlin? •IntelliJ

IntelliJPlatformSDK

ActionManager.getInstance().getAction("MyAction")…

MyAction…

Page 11: Kotlin Developer Tools · 2017-07-19 · Building Developer Tools with Kotlinand Gradle Breandan Considine GIDS 2017. ... •Language support •Framework support. Why Kotlin? •IntelliJ

foo(bar)

bar.foo()

Extensionfunctions

Page 12: Kotlin Developer Tools · 2017-07-19 · Building Developer Tools with Kotlinand Gradle Breandan Considine GIDS 2017. ... •Language support •Framework support. Why Kotlin? •IntelliJ

Extendanylibraryclass

fun String.wordCount(s: String) {return s.split(" ")

.filter { it.length > 3 }}

"hello to the world".wordCount()

Page 13: Kotlin Developer Tools · 2017-07-19 · Building Developer Tools with Kotlinand Gradle Breandan Considine GIDS 2017. ... •Language support •Framework support. Why Kotlin? •IntelliJ

Extendanylibraryclass

val File.extension: Stringget() = name.split(".").last()

myFile.extension

Page 14: Kotlin Developer Tools · 2017-07-19 · Building Developer Tools with Kotlinand Gradle Breandan Considine GIDS 2017. ... •Language support •Framework support. Why Kotlin? •IntelliJ

LazyInitializationval resource: Resource by lazy {println("Initializing…")configureResource()

}

println(resource)println(resource)

Page 15: Kotlin Developer Tools · 2017-07-19 · Building Developer Tools with Kotlinand Gradle Breandan Considine GIDS 2017. ... •Language support •Framework support. Why Kotlin? •IntelliJ

UIConfiguration1: 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: }

Page 16: Kotlin Developer Tools · 2017-07-19 · Building Developer Tools with Kotlinand Gradle Breandan Considine GIDS 2017. ... •Language support •Framework support. Why Kotlin? •IntelliJ

Gradle ScriptKotlin (GSK)

buildscript {repositories {

gradleScriptKotlin()}

dependencies {classpath(kotlinModule("gradle-plugin"))

}}

Page 17: Kotlin Developer Tools · 2017-07-19 · Building Developer Tools with Kotlinand Gradle Breandan Considine GIDS 2017. ... •Language support •Framework support. Why Kotlin? •IntelliJ

GradlePluginsplugins {

id("org.jetbrains.intellij") version "0.2"}

apply {plugin("org.jetbrains.intellij")plugin("kotlin")

}

Page 18: Kotlin Developer Tools · 2017-07-19 · Building Developer Tools with Kotlinand Gradle Breandan Considine GIDS 2017. ... •Language support •Framework support. Why Kotlin? •IntelliJ

GradleIntelliJPluginintellij {

pluginName = "MyPlugin"updateSinceUntilBuild = false

}

group = "com.group"version = "1.0"

Page 19: Kotlin Developer Tools · 2017-07-19 · Building Developer Tools with Kotlinand Gradle Breandan Considine GIDS 2017. ... •Language support •Framework support. Why Kotlin? •IntelliJ

GradleIntelliJPlugin// Also useful for OSS contributors!intellij {

runIde { args project.projectDir.path

}

downloadSources = false }

// Run `./gradlew runIde` to open project

Page 20: Kotlin Developer Tools · 2017-07-19 · Building Developer Tools with Kotlinand Gradle Breandan Considine GIDS 2017. ... •Language support •Framework support. Why Kotlin? •IntelliJ

LinksandResources• KotlinforPluginDevelopers• KotlinGradlePlugin• GradleScriptKotlin (GSK)• gradle-intellij-plugin• KotlinPluginforEclipse• goomph:IDEasabuildartifact

Page 21: Kotlin Developer Tools · 2017-07-19 · Building Developer Tools with Kotlinand Gradle Breandan Considine GIDS 2017. ... •Language support •Framework support. Why Kotlin? •IntelliJ

www.modsummit.com

www.developersummit.com