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

"Gradle meets Kotlin"ってどんな感じ?

Ba4af0fede46022fdb6f5da8819784f9?s=47 ukaznil
November 22, 2017

"Gradle meets Kotlin"ってどんな感じ?

どこでもKotlin #4の資料です。
https://m3-engineer.connpass.com/event/70561/

Ba4af0fede46022fdb6f5da8819784f9?s=128

ukaznil

November 22, 2017
Tweet

Transcript

  1. "Gradle meets Kotlin" ͬͯͲΜͳײ͡ʁ 2017/11/22 Wed. Ͳ͜Ͱ΋Kotlin #4 @ukaznil :

    Tatsuya KONISHI http://ukaznil.com/
  2. Gradle is ... • JVMܥͷϏϧυπʔϧ • AntɼMavenɼsbtͱ͔ͱಉ͡ • GroovyϕʔεͷDSLͰهड़ •

    GradleͰͰ͖Δ͜ͱ • ϏϧυͰ͖·͢  (SBEMFͰ,PUMJOαϙʔτ ʢ!ʣ@ • Ϗϧυʹؔ͢ΔϩδοΫΛ૊ΊΔ • ಠࣗtaskͷ࣮૷ɼґଘؔ܎ʢલޙؔ܎ʣͷ੍ޚ • ࣾ಺ϦϙδτϦͷೝূ
  3. None
  4. ͔͠΋GroovyͰ͋Δɻ ʮϏϧυ͍͚ͨͩ͠ͳͷʹʯ

  5. ຊൃදͷૂ͍ • ʮGradleΑ͘Θ͔ΒΜʯΛ෷১͍ͨ͠
 • GroovyΛॻ͚ͳ͍ͳΒɼ
 KotlinΛॻ͚͹͍͍͡Όͳ͍

  6. it's me !! • Android app dev • झຯͰ6೥ Kotlinྺ2೥

    • ೔ຊAndroidͷձ ֶੜ෦OB • misc • name: Tatsuya KONISHI • major: machine learning • web site: http://ukaznil.com/ , Twitter: @ukaznil • job: '17 ৽ଔ >> γεςϜ։ൃ / AI • langs: Java(5yrs), Kotlin(2yrs), Scala(1yr) Papyrus 
  7. ʲεϥΠυͷݟํʳ ʊGroovy / Kotlinʊ ʹؔ͢Δهड़΍ίʔυ (SPPWZ ,PUMJO println('hello Groovy.') println("hello

    Kotlin.")
  8. build.gradleͷجຊతͳॻ͖ํ buildscript { repositories { maven { url 'https://plugins.gradle.org/m2/' }

    } dependencies { classpath 'com.github.jengelman.gradle.plguins.shadow:2.0.1' } } apply plugin: 'java' apply plugin: 'com.github.johnrengelman.shadow' repositories { jcenter() maven { url 'https://your.domain.com/repo/' } } dependencies { compile 'your.group:your.compile-module:x.y.z' runtime 'your.group:your.runtime-module:x.y.z' } shadowJar { manifest { attributes 'Main-Class': 'com.your.domain.Main' } } (SPPWZ
  9. build.gradleͷجຊతͳॻ͖ํ buildscript { repositories { maven { url 'https://plugins.gradle.org/m2/' }

    } dependencies { classpath 'com.github.jengelman.gradle.plguins.shadow:2.0.1' } } apply plugin: 'java' apply plugin: 'com.github.johnrengelman.shadow' repositories { jcenter() maven { url 'https://your.domain.com/repo/' } } dependencies { compile 'your.group:your.compile-module:x.y.z' runtime 'your.group:your.runtime-module:x.y.z' } shadowJar { manifest { attributes 'Main-Class': 'com.your.domain.Main' } } (SPPWZ
  10. build.gradleͷجຊతͳॻ͖ํ buildscript { repositories { maven { url 'https://plugins.gradle.org/m2/' }

    } dependencies { classpath 'com.github.jengelman.gradle.plguins.shadow:2.0.1' } } apply plugin: 'java' apply plugin: 'com.github.johnrengelman.shadow' repositories { jcenter() maven { url 'https://your.domain.com/repo/' } } dependencies { compile 'your.group:your.compile-module:x.y.z' runtime 'your.group:your.runtime-module:x.y.z' } shadowJar { manifest { attributes 'Main-Class': 'com.your.domain.Main' } } (SPPWZ
  11. ʢ͓·͚ʣϓϥάΠϯͰڞ༗ buildscript { repositories { maven { url 'https:// plugins.gradle.org/m2/'

    } } dependencies { classpath 'your.plugin:1.0' } } apply plugin: 'java' apply plugin: 'your.plugin' repositories { jcenter() } dependencies { compile 'your.group:your.compile- module:x.y.z' runtime 'your.group:your.runtime- module:x.y.z' } class MyP implements Plugin<Project> { @Override void apply(Project project) { // Private repository project.allprojects { p -> p.repositories { maven { url 'https://hoge.com/' credentials { username = 'taro' password = 'kotlin' } } } } // Original task project.task('unhappy-task') { description 'aiueo' dependsOn project.jar } << { throw new GradleException('> <') } } }  (SPPWZ
  12. ʢ͓·͚ʣϓϥάΠϯͰڞ༗ buildscript { repositories { maven { url 'https:// plugins.gradle.org/m2/'

    } } dependencies { classpath 'your.plugin:1.0' } } apply plugin: 'java' apply plugin: 'your.plugin' repositories { jcenter() } dependencies { compile 'your.group:your.compile- module:x.y.z' runtime 'your.group:your.runtime- module:x.y.z' } class MyP implements Plugin<Project> { @Override void apply(Project project) { // Private repository project.allprojects { p -> p.repositories { maven { url 'https://hoge.com/' credentials { username = 'taro' password = 'kotlin' } } } } // Original task project.task('unhappy-task') { description 'aiueo' dependsOn project.jar } << { throw new GradleException('> <') } } }  (SPPWZ
  13. GradleͰ΋Kotlin • ϓϥάΠϯͷద༻ • λεΫͷએݴ • .propertiesϑΝΠϧͷม਺ • ɹ •

    ɹ 
  14. ϓϥάΠϯͷద༻ plugins { id 'java' id 'org.jetbrains.kotlin.jvm' version '1.1.60' }

    plugins { id("java") //id("org.jetbrains.kotlin.jvm") version "1.1.60" kotlin("jvm") version "1.1.60" }  • 'java', 'kotlin'ϓϥάΠϯͰఆٛ͞Ε͍ͯΔλ εΫ౳͕࢖͑ΔΑ͏ʹͳΔ dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$version_kotlin" } (SPPWZ ,PUMJO
  15. ϓϥάΠϯͷద༻ plugins { id 'java' id 'org.jetbrains.kotlin.jvm' version '1.1.60' }

    plugins { id("java") //id("org.jetbrains.kotlin.jvm") version "1.1.60" kotlin("jvm") version "1.1.60" }  • 'java', 'kotlin'ϓϥάΠϯͰఆٛ͞Ε͍ͯΔλ εΫ౳͕࢖͑ΔΑ͏ʹͳΔ dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$version_kotlin" } (SPPWZ ,PUMJO
  16. λεΫͷఆٛ task myGroovyTask { description = 'my task' desctiption 'my

    task' } doLast { //'<< {}' is deprecated println("with groovy") } task("myKotlinTask") { description = "my task" }.doLast { println("with kotlin") }  (SPPWZ ,PUMJO
  17. λεΫͷఆٛ task myGroovyTask { description = 'my task' desctiption 'my

    task' } doLast { //'<< {}' is deprecated println("with groovy") } task("myKotlinTask") { description = "my task" }.doLast { println("with kotlin") }  • Groovy / KotlinͷϓϩύςΟΞΫηεͷҧ͍ description = 'desc' || setDescription('desc') description 'desc' || description('desc') description = "desc" || setDescription("desc") (SPPWZ ,PUMJO
  18. .propertiesϑΝΠϧͷม਺ dependencies { compile "org.jetbrains.kotlin:kotlin- stdlib:$vKotlin" } val vKotlin by

    project val vKotlin: String by extra val verkotlin = extra["vKotlin"] dependencies { compile "org.jetbrains.kotlin:kotlin- stdlib:$vKotlin" }  vKotlin=1.1.60 (SPPWZ ,PUMJO HSBEMFQSPQFSUJFT
  19. .propertiesϑΝΠϧͷม਺ dependencies { compile "org.jetbrains.kotlin:kotlin- stdlib:$vKotlin" } val vKotlin by

    project val vKotlin: String by extra val verkotlin = extra["vKotlin"] dependencies { compile "org.jetbrains.kotlin:kotlin- stdlib:$vKotlin" }  vKotlin=1.1.60 (SPPWZ ,PUMJO HSBEMFQSPQFSUJFT ,PUMJO͸͢͜͠໘౗ɻɻɻ
  20. GradleͰ΋Kotlin • ϓϥάΠϯͷద༻ • λεΫͷએݴ • .propertiesϑΝΠϧͷม਺ • ɹ •

    ɹ 
  21. GradleͰ΋Kotlin • ϓϥάΠϯͷద༻ • λεΫͷએݴ • .propertiesϑΝΠϧͷม਺ • ɹ •

    ɹ 
  22. GradleͰ΋Kotlin • ϓϥάΠϯͷద༻ • λεΫͷએݴ • .propertiesϑΝΠϧͷม਺ • IDE͕ෆ਌੾ •

    ɹ 
  23. IDE͕਌੾@Groovy  (SPPWZ ͳΜͯஸೡͳΤϥʔϝοηʔδʜʜοʂ

  24. IDE͕ෆ਌੾@Kotlin  ,PUMJO 0I

  25. IDE͕ෆ਌੾@Kotlin(͓͔ΘΓ)  ,PUMJO 0IʢBHBJOʣ

  26. GradleͰ΋Kotlin • ϓϥάΠϯͷద༻ • λεΫͷએݴ • .propertiesϑΝΠϧͷม਺ • IDE͕ෆ਌੾ •

    ɹ 
  27. GradleͰ΋Kotlin • ϓϥάΠϯͷద༻ • λεΫͷએݴ • .propertiesϑΝΠϧͷม਺ • IDE͕ෆ਌੾ •

    IDE͕਌੾ 
  28. IDE͕ෆ਌੾@Groovy (SPPWZ NBQͷLFZΛ֮͑ͳ͍ͱ͍͚ͳ͍ͷπϥ͍ɻɻɻ

  29. IDE͕਌੾@Kotlin ,PUMJO FYDMVEF͓͚֮͑͑ͯ͞͹Կͱ͔ͳΔʂ UIBOLTUP֦ுؔ਺

  30. ຊൃදͷ·ͱΊ • ʮGradleΑ͘Θ͔ΒΜʯΛ෷১͍ͨ͠
 㱺 buildπʔϧͷཧղ͸ʮٸ͕͹ճΕʯ
 • GroovyΛॻ͚ͳ͍ͳΒɼ
 KotlinΛॻ͚͹͍͍͡Όͳ͍
 㱺 λεΫ಺ͰΰϦΰϦ͢ΔͳΒԸܙେʁ

  31. "Gradle meets Kotlin" ͬͯͲΜͳײ͡ʁ That's all of 2017/11/22 Wed. Ͳ͜Ͱ΋Kotlin

    #4 @ukaznil : Tatsuya KONISHI http://ukaznil.com/
  32. Thank you, Kotliners !!