Let's migrate to build.gradle.kts

Let's migrate to build.gradle.kts

A step-by-step guide of how to migrate to Gradle Kotlin DSL a.k.a. build.gradle.kts in a reproducutive way.

Video available at https://youtu.be/_s-0MbA5Gvw

Presented at DroidKaigi 2019 at Bellesalle Shinjuku Grand Conference Center
https://droidkaigi.jp/2019/en/timetable/70863

0ab502179956dab407e6e146bce304f9?s=128

Yuki Fujisaki

February 08, 2019
Tweet

Transcript

  1. CVJMEHSBEMFLUTʹҠߦ͠Α͏ !UOK :VLJ'VKJTBLJ %FQMPZ(BUF*OD %SPJE,BJHJ %BZ 3PPN

  2. ର৅  build.gradleΛ,PUMJOԽͯ͠Έ͍ͨ  (SBEMF (SPPWZ ͸ͳΜͱͳ͘ॻ͍͍ͯΔ  ,PUMJOͩͬͨΒॻ͚ͦ͏

  3. ͜ͷ෼ͷΰʔϧ  ,PUMJOԽͷϝϦοτΛ஌Δ  build.gradle.ktsʹҠߦ͢Δ࠶ݱՄೳͳखॱΛ஌Δ  Α͋͘Δ໰୊ͱରԠࡦΛ஌Δ ࿩͞ͳ͍͜ͱ  ߴ଎Խʢߏ੒ճආ"1*ͳͲʣ΍ϦϑΝΫλϦϯά

  4. ΞδΣϯμ  (SBEMF,PUMJO%4-ʹ͍ͭͯ  ,PUMJOԽͰخ͍͜͠ͱ  ࣮ࡍͷҠߦ  جૅฤ 

    ࣮ફฤ
  5. ؀ڥ  "OESPJE4UVEJP  "OESPJE(SBEMF1MVHJO  (SBEMF (SBEMF,PUMJO%4-3$  ݱ࣌఺Ͱ࠷৽͸3$

    (SBEMF,PUMJO%4-  ࢖ͬͯΔϓϥάΠϯ͕(SBEMFܥରԠͯ͠Ε͹࠷৽͕Φεεϝ ࡢ೔  ϦϦʔε
  6. None
  7. (SBEMF,PUMJO%4-ʹ͍ͭͯ  (SBEMFͰϦϦʔε   (SBEMFϏϧυεΫϦϓτΛ,PUMJOεΫϦϓτ LUT Ͱॻ͚Δ  (SBEMFຊମػೳͷҰ෦ͱͯ͠ఏڙ͞ΕΔ

     ,PUMJOεΫϦϓτͷίϯύΠϥࣗମ΋ຒΊࠐΈ  (SPPWZ͕%FQSFDBUFEʹͳΔ༧ఆ͸ͳ͍
  8. ,PUMJOʹͳͬͯخ͍͜͠ͱ  %FWFMPQFS&YQFSJFODF͕ߴ͍  ίʔυิ׬͕ޮ͘ɺΤϥʔݕ͕ࠪಇ͍ͯ͘ΕΔ  ॻ͍ͯΔίʔυͷϑΟʔυόοΫ͕ߴ଎  ϝϯς͠΍͍͢ 

    ܕ͕͋ΔɺϦϑΝΫλ͕Ͱ͖Δ
  9. ͭ·Γ*%&͕ͪΌΜͱ࢓ࣄ͢Δ

  10. ઓུ  ४උ·ͣ଍৔Λ੔͑Δ  "(1ରԠ  (SPPWZͷ··Ұ୴εΫϦϓτΛ੔ཧ  ҠߦϏϧυ͕௨Δঢ়ଶΛҡ࣋͠ͳ͕ΒҠߦ 

    શ෦ΛҰ౓ʹ΍Βͳ͍(SPPWZͱ,PUMJOڞଘՄ
  11. جૅฤ Š·ͣϓϨʔϯͳϓϩδΣΫτͰ੒ޭମݧΛੵΉ

  12. ର৅  "OESPJE4UVEJPͰ#BTJD"DUJWJUZϓϩδΣΫτ σϑΥϧτઃఆ -BOHVBHF,PUMJO ͷ··࡞Δ

  13. ͭͷ(SBEMFεΫϦϓτ  "OESPJE(SBEMF1MVHJOΛ࢖ͬ ͨΫϦʔϯͳϓϩδΣΫτ ·ͣ͸Ϗϧυ͕௨ΓɺΞϓϦΛ ىಈͰ͖Δ͜ͱΛ֬ೝ

  14. ༨ஊ 6TF"OESPJE9BSUJGBDUTΛ༗ޮʹͯ͠ΔͱΞϓϦ͕ଈࢮ͠·͢ // ͍͕ͭ͜൜ਓɺ1.1.3ʹ্͛·͠ΐ͏ implementation "androidx.constraintlayout:constraintlayout:1.1.2"

  15. ॻ͖׵͑ͯΈΑ͏  ⾣TFUUJOHTHSBEMF  ⌛ CVJMEHSBEMF  ⌛ BQQCVJMEHSBEMF

  16. TFUUJOHTHSBEMF͸ߦ include ':app'  จࣈྻϦςϥϧ(SPPWZ͸'ͱ"ͷ྆ํɺ,PUMJO͸"ͷΈ  ϝιουݺͼग़͠(SPPWZ͸()ΛলུՄɺ,PUMJOͰ͸ඞਢ ‎"..."ʹͯ͠()Λ෇͚Ε͹ͲͪΒͰ΋ಈ͘

  17. (SPPWZͷ·· ‑ ฤूͨ͠ΒҰ୴ Sync ͠·͢

  18. 4ZODͷํ๏  ώϯτతʹग़ͯ͘Δ4ZOD/PXϦϯΫ

  19. 4ZODͷํ๏  πʔϧόʔͷ4ZOD1SPKFDUXJUI(SBEMF'JMFT ͜ͷϘλϯΛ͓͖֮͑ͯ·͠ΐ͏

  20. ௨ͬͨΒɺϑΝΠϧ໊Λมߋͯ͠ΈΔ  1SPKFDUπϦʔ͔Βsettings.gradleΛϦωʔϜ 4IJGU '  build.gradle.ktsʹม͑·͢  Ҿ਺໊ώϯτ͕ग़͖ͯͯಥવ*%&ͷཧղ౓͕͏ͳ͗ొΓ

  21. ࢼ͠ʹଘࡏ͠ͳ͍ࣝผࢠΛॻ͍ͯΈΔ  (SPPWZWT,PUMJO  ੺͘ͳΔʂؒҧͬͯΔ͜ͱΛͦͷ৔Ͱࢦఠͯ͘͠ΕΔ  τϥΠΞϯυΤϥʔ͕ര଎Խ

  22. ॻ͖׵͍͑ͯ͘  ✅ TFUUJOHTHSBEMF  ⾣CVJMEHSBEMF  ⌛ BQQCVJMEHSBEMF

  23. ϓϩδΣΫτϧʔτͷbuild.gradle

  24. ػցతͳमਖ਼ ਖ਼نදݱνʔτγʔτ  จࣈྻϦςϥϧ'([^']+)'‎"$1"  ϝιουݺͼग़͠(classpath|delete) (\S+)‎$1($2)

  25. 4ZOD௨ͬͨΒϑΝΠϧ໊Λมߋ  1SPKFDUπϦʔ͔Β1SPKFDUͷbuild.gradleΛϦωʔϜ

  26. ౖΒΕΔ  ͦ͏қʑͱ,PUMJOͩͱ͸ೝΊͯ͘Εͳ͍  ͕ɺϦωʔϜ࣌఺Ͱ͸Կ͕ѱ͍ͷ͔ڭ͑ͯ͘ͳ͍

  27. ΤϥʔΛ஌Δ  4ZOD͢ΔͱίϯιʔϧʹΤϥʔ͕ग़Δ  Ұ౓ґଘؔ܎ΛධՁͰ͖Δ·Ͱίʔυʹ৭͕෇͔ͳ͍

  28. ࠷ॳͷนext buildscript { ext.kotlin_version = "1.3.20" // => Unresolved reference:

    ext }  extͳΜͯఆٛ͞Εͯͳ͍ͧͱݴΘΕΔ
  29. ͦ΋ͦ΋extͬͯ  ΞυϗοΫʹ޷͖ͳ஋ΛಥͬࠐΊΔ,FZ7BMVF4UPSF  Project ˺build.gradle ͕ࣗಈతʹ͍࣋ͬͯΔ  extʹηοτͨ͠ޙ͸ProjectͷείʔϓͰ΋ࢀরՄೳ 

    rootProjectͰηοτͨ͠஋͸͢΂ͯͷࢠProject͔Β ΋ݟ͑Δ ࣮ߦॱংͷؔ܎্buildscript {}಺Ͱఆٛ͢Δඞཁ͕͋Δ
  30. ಁաੑ buildscript { ext.kotlin_version = "1.3.20" } // ext είʔϓͰ΋ɺ

    Project είʔϓͰ΋ࢀরͰ͖Δ println ext.kotlin_version // => "1.3.20" println kotlin_version // => "1.3.20" SPPU1SPKFDUͰఆٛͨ͠஋͸ଞͷ1SPKFDU͔Β΋ࢀরͰ͖Δ // app/build.gradle println kotlin_version // => "1.3.20" println rootProject.kotlin_version // => "1.3.20"
  31. Ұํ,PUMJO͸੩తܕ෇͚ݴޠ ͍͖ͳΓ୅ೖ͠Α͏ͱͯ͠΋ະఆٛͷϓϩύςΟͱݟ၏͞ΕΔ

  32. ٹੈओextra  ExtraPropertiesExtensionsͰఏڙ͞ΕΔҕৡϓϩύςΟ  ม਺ͱͯ͠ࢀরͭͭ͠ɺ಺෦Ͱext΁ͷTFUHFUΛҕৡ  ܕਪ࿦͕ޮ͘

  33. ͜͜Λॻ͖׵͑Δ͚ͩͰੈքʹ৭͕ʂ

  34. ࣍ͷนtasksͷमਖ਼ taskͷఆٛͷߏจมߋ // Groovy task clean(type: Delete) {} ɹɹɹɹɹɹ‑ //

    Kotlin tasks.create("clean", type = Delete::class) {} // or task<Delete>("clean") {}
  35. #&'03&CVJMEHSBEMF

  36. "'5&3CVJMEHSBEMFLUT !

  37. ॻ͖׵͍͑ͯ͘  ✅ TFUUJOHTHSBEMF  ✅ CVJMEHSBEMF  ⾣BQQCVJMEHSBEMF

  38. BQQCVJMEHSBEMF

  39. ಉ͡Α͏ʹԼ͝͠Β͑  จࣈྻ  '([^']+)'ˠ"$1"  ϝιουݺͼग़͠  ()Λ෇͚͍ͨɺΜ͚ͩͲʜ

  40. ͜Ε͸୅ೖ ϝιουݺͼग़͠ applicationId "sh.nothing.myapplication" minSdkVersion 21 targetSdkVersion 28 versionCode 1

    versionName "1.0"  ϝιουݺͼग़͠ͷ()ΛলུͰ͖Δ  ϓϩύςΟ୅ೖͷ=ΛলུͰ͖Δ ‎ݟͨ໨ͷ۠ผ͕෇͔ͳ͍ʂ
  41. ެࣜҠߦΨΠυͷઓུ ʮ໎ͬͨΒҰ୴୅ೖʹͯ͠ɺౖΒΕͨΒݺͼग़͠ʹ͢΂͠ʯ

  42. ΋͘͠͸*%&ͷྗʹཔΔ  ϝιουͩͬͨΒ$PNNBOE΋͘͠͸$USMΛԡ͠ͳ͕Β Ϛ΢εΧʔιϧΛ߹ΘͤΔͱఆ͕ٛҾ͚Δ  ͜ͷ৔߹͸setMinifyEnabled(false)

  43. νʔτγʔτ (\w+(?:ion|Files)) (.+)$‎$1($2) ϓϩδΣΫτॳظઃఆͷ··Ͱ͋Ε͹͜ΕͰย෇͖·͢

  44. ௥ՃͷԼ͝͠Β͑  จࣈྻͱϝιουݺͼग़͠ʹՃ͑ͯ  apply plugin:ʹ΋खΛೖΕ͓͖͍ͯͨ

  45. apply plugin:͔Βplugins {}ʹҠߦ // apply plugin: ܈Λ apply plugin: 'com.android.application'

    apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' ɹɹɹɹɹɹ‑ // plugins ߏจʹॻ͖׵͑Δ plugins { id("com.android.application") id("kotlin-android") id("kotlin-android-extensions") }
  46. plugins {}Ҡߦͷഎܠ (SBEMFϓϥάΠϯ͸ίʔυͰ࣮ߦ࣌ʹ௥Ճ͞ΕΔ࢓૊Έ  ྫ"OESPJE(SBEMF1MVHJOͷandroid {}ϒϩοΫ project.extensions.add('android', BaseAppModuleExtension) ‎2Ͳ͏΍ͬͯ͜ΕΛ੩తʹղܾ͢Δͷ͔

  47. "ΞΫηα͕ੜ੒͞ΕΔ  ,PUMJO%4-͕&YUFOTJPO͔Β,PUMJOίʔυΛࣗಈੜ੒  ͨͩ͠QMVHJOTͰఆٛ͞Εͨ΋ͷ͚ͩ  ͳ͓(SBEMF͸ݩʑ(SPPWZͰ΋plugins {}Λਪ঑͍ͯ͠Δ

  48. 4ZOD௨ͬͨΒϑΝΠϧ໊Λมߋ  1SPKFDUπϦʔ͔Β.PEVMFBQQͷbuild.gradleΛϦωʔϜ

  49. 4ZODͯ͠ΤϥʔΛ֬ೝ  ্͔Βॱʹ౗͍ͯ͘͠  ͨ͘͞Μग़Δ͚Ͳɺͭ౗ͤ͹ෳ਺ݮΓ·͢  ࠓճͷ৔߹͸࣮࣭ͭ

  50. Map<K, V>ͷҾ਺ fileTree(dir: "libs", include: ["*.jar"])  ࢖ͬͯͳ͍ͷͰҰ୴ίϝϯτΞ΢τͰ΋Αͦ͞͏  ,PUMJOԽ

    fileTree("dir" to "libs", "include" to listOf("*.jar"))
  51. buildTypes {}ͷఆٛ  release‎getByName("release")ʹ  ΋͠not foundͱݴΘΕͨΒɺcreate("release")ʹ  ͪΐͬͱ໘౗͍͘͞

  52. kotlin_version  ͖ͬ͞΍Γ·ͨ͠ͶrootProjectͷext͸ʜ // ͢΂ͯͷ Project είʔϓͰݟ͑Δ val kotlin_version: String

    by project // ΋͘͠͸ `rootProject.extra` ͔Βऔಘͯ͠΋͍͍Ͱ͢ val kotlin_version: String by rootProject.extra
  53. ͜ΕͰLUTԽ׬ྃ !

  54. جૅฤͷ࿩  ॱংTFUUJOHTHSBEMFˠCVJMEHSBEMFˠBQQCVJMEHSBEMF  (SPPWZͷ··ઌʹԼ͝͠Β͑  จࣈྻΫΦʔτɺϝιουݺͼग़͠ɺplugins  (SBEMFͷ֓೦ͱ(SPPWZͷ,PUMJOԽ 

    extͱextra taskͷఆٛ getByNameͱcreate
  55. جૅฤͷײ૝  ׂͱ୯७ͳஔ͖׵͕͑ଟ͍ײ͡  ࢥͬͯͨΑΓ͸ɺ͍͚ͦ͏ͳײ͡ʁ  ૣ଎ɺࣗ෼ͷϓϩδΣΫτͰࢼͯ͠ΈΑ͏

  56. ࣮ફฤ Š࣮ࡍͷϓϩδΣΫτʹಋೖ͢Δ৔߹ͷোนͱରԠࡦͷ঺հ

  57. ࢼͯ͠ΈΑ͏ͱࢥͬͨɺΜ͚ͩͲͶ

  58. ͍͍ͩͨ͜͜ͰఘΊΔ  ಀ͍͛ͨ  .gradleϑΝΠϧͬͯؾ͕ͭ͘ͱ૿͑ͯΔΑͶ  Ͱ΋ʂ࣮ࡍͷҠߦͷྲྀΕ͸جૅฤͱ·ͬͨ͘ಉ͡ ‎࣮ફฤ్தͷোนͱͯ͋͠Γ͕ͪͳ՝୊ΛऔΓ্͛ͯ঺հ

  59. ࣮ફฤτϐοΫ  "OESPJE(SBEMF1MVHJOʹ্͛Δ  ڊେextΛͳΜͱ͔͍ͨ͠  ࣮͸,PUMJOεΫϦϓτ͔Β(SPPWZεΫϦϓτΛݺ΂Δ  ϑΝΠϧͷ຤ඌʹapply plugin:͕͋Δ

     ͜ͷهड़ಈ͔ͳ͍ɺͲ͏͢Ε͹
  60. ࣮ફฤτϐοΫ  "OESPJE(SBEMF1MVHJOʹ্͛Δ  ڊେextΛͳΜͱ͔͍ͨ͠  ࣮͸,PUMJOεΫϦϓτ͔Β(SPPWZεΫϦϓτΛݺ΂Δ  ϑΝΠϧͷ຤ඌʹapply plugin:͕͋Δ

     ͜ͷهड़ಈ͔ͳ͍ɺͲ͏͢Ε͹
  61. "(1Λʹ্͛Δ  3.3.1ʹͯ͠4ZOD

  62. (SBEMF΋্͛ͯͶͱݴΘΕΔ  (SBEMFҎ্͕ඞཁ  Fix Gradle wrapper and re-import project͢Δ

  63. ͜͜ͰϏϧυ͕௨Βͳ͘ͳΔ৔߹  جຊ͸֤छϓϥάΠϯͷόʔδϣϯΛ্͛ͯղܾ  ./gradlew --stacktrace͋ͨΓ͕ࢀߟʹͳΔ͸ͣ

  64. ࣌఺ͰͷҾ͔͔ͬΓϙΠϯτ  google-servicesҎ্͕ඞਢ Ϗϧυ͸௨ͬͯ΋ΞϓϦ͕མͪͨΓɺ'BCSJD͕͏·͘ಈ͔ͳ ͔ͬͨΓ͢Δ  android-junit5 jacoco-android લऀ͕࠷৽ͷ1.3.2.0ͩͱಈ͔ͳ͍ɺ1.3.1.0ͳΒେৎ෉ *TTVF

  65. 8"3/*/(͕ফ͑ͳ͍  ઃఆ͕ѱ͍Α͏ʹݟ͑Δ͚Ͳɺର৅͸ϓϥάΠϯͷ࣮૷  ϓϥάΠϯ։ൃऀͷΈΜͳ"(1ରԠͯ͘͠ΕཔΉ  ׬શͳΔϒʔϝϥϯ

  66. "(1ʹ্͕ͬͨΒ  settings.gradle͔ΒҠߦ͠͸͡ΊͯΈ·͠ΐ͏  جຊฤͱಉ͡Ͱॠࡴ  include ['"]([^'"]+)['"]ˠinclude("$1")

  67. ࣮ફฤτϐοΫ  "OESPJE(SBEMF1MVHJOʹ্͛Δ  ڊେextΛͳΜͱ͔͍ͨ͠  ࣮͸,PUMJOεΫϦϓτ͔Β(SPPWZεΫϦϓτΛݺ΂Δ  ϑΝΠϧͷ຤ඌʹapply plugin:͕͋Δ

     ͜ͷهड़ಈ͔ͳ͍ɺͲ͏͢Ε͹
  68. ڊେextΛͳΜͱ͔͍ͨ͠

  69. extͷ··ͩͱׂͱਏ͍  ࢀর͕໘౗͍͘͞ val by extra࿈ൃ͠ΜͲ͍ΑͶ  (SPPWZͷ··࢖ͬͯͯ΋ׂͱෆศ ίʔυδϟϯϓͰ͖ͳ͍

  70. ެࣜͷΦεεϝCVJME4SDʹ੾Γग़ ͠·͠ΐ͏  CVJME4SDσΟϨΫτϦ ϏϧυεΫϦϓτ༻ͷಛผͳϓ ϩδΣΫτ தʹஔ͍ͨεΫϦϓτ͸ɺશͯ ͷ1SPKFDU͔ΒࢀরՄೳ ֤छఆ਺΍ࣗ࡞ͷϓϥάΠϯஔ ͖৔ʹ࠷ద

  71. CVJME4SDࣄ࢝Ί  σΟϨΫτϦΛ࡞Δ  buildSrc/  ࠷௿ݶͷϑΝΠϧΛ࡞੒  buildSrc/settings.gradle.kts த਎͸ۭ

     buildSrc/build.gradle.kts
  72. CVJME4SDCVJMEHSBEMFLUT // kotlin-dslΛ༗ޮʹ͢Δ࠷௿ݶͷఆٛ plugins { `kotlin-dsl` } repositories { jcenter()

    }
  73. extͷத਎ΛҠ͢  buildSrc/src/main/kotlinʹDeps.ktΛ࡞੒  object Depsʹvalͱ֤ͯ͠छఆ਺Λఆٛ

  74. ར༻Օॴͷॻ͖׵͑  $kotlinVersion‎${Deps.kotlinVersion}  Ұׅஔ׵ͱ͔ͰؤுΔ  \$(\w+Version)ˠ\$\{Deps.$1\}  rootProject\.ext\.(\w+)ˠDeps.$1

  75. ࢀরͰ͖ΔΑ͏ʹͳͬͯศར

  76. ͳΜ͔໘౗ͦ͘͞͏ͳͷ͕͋Δʜͬͯ࣌ ྫ؀ڥม਺΍gitͷ৘ใΛextʹಥͬࠐΉ  ,PUMJOͰॻ͖׵͑Ε͹͍͍Μ͚ͩͲɺޙճ͠ʹ͍ͨ͠

  77. ผϑΝΠϧʹ੾Γग़ͯ͠͠·͏  ྫ͑͹ͦͷ··ci_vars.gradleͱͯ͠੾Γग़͢  ݩͷ৔ॴʹapply from: "ci_vars.gradle"  ,PUMJOԽͯ͠΋ͦͷ··Ͱ͍͍ 

    apply(from="ci_vars.gradle")  ,PUMJO͔Β(SPPWZͷ(SBEMFϑΝΠϧΛݺ΂Δʂ
  78. ࣮ફฤτϐοΫ  "OESPJE(SBEMF1MVHJOʹ্͛Δ  ڊେextΛͳΜͱ͔͍ͨ͠  ࣮͸,PUMJOεΫϦϓτ͔Β(SPPWZεΫϦϓτΛݺ΂Δ  ϑΝΠϧͷ຤ඌʹapply plugin:͕͋Δ

     ͜ͷهड़ಈ͔ͳ͍ɺͲ͏͢Ε͹
  79. Ұ୴·Δͬͱ੾Γग़ͯ͠͠·͏ͱ͍͏େ୾ͳઓུ΋Մೳ // app/build.gradle.kts apply(from="original.build.gradle") // ͜ͷ1ߦ͚ͩ ‎ͦͷޙplugins {}ͱରԠ͢ΔઃఆΛҰͭͣͭҠ͍ͯ͘͠

  80. ྫkapt {}͚ͩҠߦ // app/build.gradle.kts plugins { kotlin("kapt") } apply(from="original.build.gradle") kapt

    { useBuildCache = true }
  81. ੾Γग़͢ͱ͖ͷ੍໿  buildscript {} ͸੾Γग़ͤͳ͍  ୯७ʹJODMVEFͯ͠ΔΘ͚Ͱͳ͘ϓϥάΠϯѻ͍  ϑΝΠϧ͝ͱʹผͷDMBTTMPBEFSʹͳΔ 

    it instanceOf AppPlugin తͳ൑ఆ͕ਖ਼͘͠ಈ࡞͠ͳ͍  hasPlugin("com.android.application") ͸0,
  82. ࣮ફฤτϐοΫ  "OESPJE(SBEMF1MVHJOʹ্͛Δ  ڊେextΛͳΜͱ͔͍ͨ͠  ࣮͸,PUMJOεΫϦϓτ͔Β(SPPWZεΫϦϓτΛݺ΂Δ  ϑΝΠϧͷ຤ඌʹapply plugin:͕͋Δ

     ͜ͷهड़ಈ͔ͳ͍ɺͲ͏͢Ε͹
  83. ຤ඌʹ͋Δ͜Ε apply plugin: "com.google.gms.google-services"  plugins {}ʹॻ͘ͱͦͷ࣌఺Ͱapply͞Εͯ͠·͏  ਖ਼͘͠ಈ࡞͠ͳ͍

  84. idએݴʹapply falseΛ෇༩  apply plugin:͸ݩͷҐஔʹஔ͍ͨ·· plugins { // Groovy id

    "com.google.gms.google-services" apply false } plugins { // Kotlin id("com.google.gms.google-services") apply false }
  85. ࣮ફฤτϐοΫ  "OESPJE(SBEMF1MVHJOʹ্͛Δ  ڊେextΛͳΜͱ͔͍ͨ͠  ࣮͸,PUMJOεΫϦϓτ͔Β(SPPWZεΫϦϓτΛݺ΂Δ  ϑΝΠϧͷ຤ඌʹapply plugin:͕͋Δ

     ͜ͷهड़ಈ͔ͳ͍ɺͲ͏͢Ε͹
  86. repositories {}ฤ ଟ෼ਅͬઌʹҾ͔͔ͬΔ΍ͭ maven { url "https://plugins.gradle.org/m2/" } ɹɹɹɹɹɹɹɹ‑ maven("https://plugins.gradle.org/m2/")

     RepositoryHandlerExtensions Ͱ֦ு͞Ε͍ͯΔ  maven  ivy
  87. sourceSets {}ฤ sourceSets { // Groovy main.java.srcDirs += 'src/main/kotlin' }

    ɹɹɹɹɹɹɹɹ‑ sourceSets { // Kotlin getByName("main").java.srcDirs("src/main/kotlin") }  (SPPWZ΋·ͬͨ͘ಉ͡ίʔυ͕௨Δ
  88. testOptions {} testOptions { unitTests { /* Closure Λظ଴͞ΕͯΔ */

    } }
  89. ίʔυδϟϯϓͯ͠ΈΔ  UnitTestOptions ܕͷઃఆΛ͢Δ$MPTVSFΒ͍͠  ͜ͷܕ৘ใΛ,PUMJO%4-ʹ༩͑Δඞཁ͕͋Δ

  90. delegateClosureOf<T> Ͱғͬͯ͋͛Δͱ unitTests( delegateClosureOf<UnitTestOptions> {} ) ແࣄઃఆͰ͖ΔΑ͏ʹ

  91. ઃఆ͕·ͬͨ͘ॻ͚ͳ͍ &YUFOTJPO͕ෆՄࢹͳέʔε  ྫHSBEMFBOESPJESJCCPOJ[FSQMVHJO  this: Anyʜͩͱʜ

  92. &YUFOTJPOʹQVCMJD͕໌ࣔ͞Εͯͳ͍΍ͭ  ribbonizerJTOPUBDDFTTJCMFJOBUZQFTBGFXBZCFDBVTF  RibbonizerExtensionJTOPUQVCMJD  (SPPWZͩͱΞΫηεͰ͖ΔΜ͚ͩͲͶʜ

  93. ࠷ޙͷखwithGroovyBuilderΛ࢖͏  จࣈྻͰઃఆ஋ʹΞΫηεʢܕ΍Ҿ਺ͷݕ͕ࠪޮ͔ͳ͍ʣ ribbonizer { forcedVariantsNames("release") } ɹɹɹɹɹɹɹɹɹ‑ ribbonizer {

    withGroovyBuilder { "forcedVariantsNames"("release") } }
  94. ༨ஊ৐Γӽ͑ͯ΋ࡉ͔͍ઃఆ͕Ͱ͖ͳ͔ͬͨͷͰ gradle-android-ribbonizer-pluginʹ͸γϡοͱ1VMM3FRVFTU Λ౤͛·ͨ͠ 

  95. ࣮ફฤ·ͱΊ  ·ͣ"(1ʹ্͛Δ  ڊେextΑΓ΋CVJME4SDʹ͢Δͱศར  apply͸஗Ԇͤ͞ΒΕΔ  େ͖ͳεΫϦϓτ͸੾Γग़ͤΔ 

    Α͋͘Δهड़ͷॻ͖׵͑ύλʔϯΛ೺Ѳ
  96. େମ͜͜·ͰཧղͰ͖ͯΕ͹  ΄ͱΜͲͷbuild.gradleΛ,PUMJOԽͰ͖Δ͸ͣ  Ͳ͏ͯ͠΋μϝͳ෺͸(SPPWZʹ࢒͢

  97. ͓·͚ෆ۩߹ͬΆ͍΋ͷରԠࡦ  ಥવkaptౖ͕Γग़͢  'BCSJD1MVHJOͷalwaysUpdateBuildId্͕ख͘ಈ͔ͳ͍

  98. ಥવLBQUౖ͕Γग़͢ ݱ৅4ZOD͸Ͱ͖͕ͨɺΞϓϦΛϏϧυ͢ΔͱLBQUౖ͕Γग़͠ ͯϏϧυ͕௨Βͳ͍ error: incompatible types: NonExistentClass cannot be converted

    to Annotation @error.NonExistentClass() ^ ݪҼandroid-extensionsͷઃఆ͕൓ө͞Εͳ͍  isExperimental = trueͬͯॻ͍ͯΔͷʹ൓ө͞Εͯͳ͍
  99. ճආࡦ configure(delegateClosureOf<AndroidExtensionsExtension> {}) Ͱғ͏

  100. ,5  IUUQTHJUIVCDPNHSBEMFLPUMJOETMJTTVFT  LPUMJOBOESPJEͷઃఆ஋มߋϋϯυϦϯάपΓͷෆ۩߹

  101. 'BCSJDͷalwaysUpdateBuildId্͕ख͘ಈ͔ͳ͍ Ϗϧυߴ଎Խͷ5JQTͰग़ͯ͘Δ΍ͭ buildTypes { debug { ext.alwaysUpdateBuildId = false }

    } by extraͰઃఆͯ͠΋൓ө͞Εͳ͍
  102. ճආࡦʮͲ͏ͯ͠΋μϝͳ΋ͷ͸ʯύλʔϯ ͜ͷߦ͚ͩผϑΝΠϧʹ੾Γग़ͯ͠BQQMZGSPN͢Δ // fabric.gradle android.buildTypes.debug.ext.alwaysUpdateBuildId = false // build.gradle.kts apply(file="fabric.gradle")

    BuildTypeʹઃఆ͞Εͨextͷ஋Λݟ͍ͯΔ͕ɺ ,PUMJO%4-͔ΒΞΫηεͰ͖ͳ͍
  103. ·ͱΊ

  104. ࿩ͨ͜͠ͱ  ,PUMJOԽͷϝϦοτ  ! ଈ࠲ͷϑΟʔυόοΫɺ ϝϯςφϯεੑ޲্  build.gradle.ktsʹҠߦ͢Δ࠶ݱՄೳͳखॱ 

    ڞ௨ͷखॱ  Α͋͘Δ໰୊ͱରԠࡦ
  105. ෭࣍తޮՌ ! ϏϧυεΫϦϓτʹखΛೖΕΔ৺ཧతোนͷ௿Լ  (SBEMFŧŔŕŪũƄŝſײ

  106. ࢀߟࢿྉ  ,PUMJO$POG5ZQF4BGF#VJME-PHJDXJUI(SBEMF,PUMJO %4-CZ1BVM.FSMJO  .JHSBUJOHCVJMEMPHJDGSPN(SPPWZUP,PUMJO  (SBEMF,PUMJO%4-1SJNFS ެࣜͷ(SBEMF,PUMJO%4-ೖ໳υΩϡϝϯτ ެࣜͷҠߦΨΠυɺ(SPPWZͱ,PUMJO྆ํͰهड़͞ΕͯͯࢀߟʹͳΔ

    ,PUMJO%4-ͷதͷਓͷηογϣϯɺεϥΠυ