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

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

ukaznil
November 22, 2017

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

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

ukaznil

November 22, 2017
Tweet

More Decks by ukaznil

Other Decks in Programming

Transcript

  1. Gradle is ... • JVMܥͷϏϧυπʔϧ • AntɼMavenɼsbtͱ͔ͱಉ͡ • GroovyϕʔεͷDSLͰهड़ •

    GradleͰͰ͖Δ͜ͱ • ϏϧυͰ͖·͢  (SBEMFͰ,PUMJOαϙʔτ ʢ!ʣ@ • Ϗϧυʹؔ͢ΔϩδοΫΛ૊ΊΔ • ಠࣗtaskͷ࣮૷ɼґଘؔ܎ʢલޙؔ܎ʣͷ੍ޚ • ࣾ಺ϦϙδτϦͷೝূ
  2. 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 
  3. 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
  4. 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
  5. 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
  6. ʢ͓·͚ʣϓϥάΠϯͰڞ༗ 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
  7. ʢ͓·͚ʣϓϥάΠϯͰڞ༗ 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
  8. ϓϥάΠϯͷద༻ 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
  9. ϓϥάΠϯͷద༻ 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
  10. λεΫͷఆٛ 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
  11. λεΫͷఆٛ 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
  12. .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
  13. .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͸͢͜͠໘౗ɻɻɻ