Guide to build Gradle Plugin for efficient development

Guide to build Gradle Plugin for efficient development

Video: https://www.youtube.com/watch?v=Lo326kQt7L8

[Slides in Japanese] This deck will be presented in DroidKaigi 2018, Day 2 6:30-7:00 pm at Room 3.

0ab502179956dab407e6e146bce304f9?s=128

Yuki Fujisaki

February 09, 2018
Tweet

Transcript

  1. GradleϓϥάΠϯΛ࡞ͬͯ ։ൃޮ཰Λվળ͠Α͏ Yuki Fujisaki @ DeployGate Inc. DroidKaigi 2018, Day

    2, Room #3
  2. ର৅ • Android։ൃ͸ͯ͠Δ • GradleεΫϦϓτΛฤूͨ͠ܦݧ͕ଟগ͋Δ • GradleϓϥάΠϯ͸࡞ͬͨ͜ͱͳ͍

  3. ରԠ؀ڥ • Gradle 4.4 • Gradle Android Plugin 3.2.0-alpha01 •

    Android Studio 3.1 Preview
  4. build.gradleϑΝΠϧ ΧελϚΠζͯ͠Δ? Do you customize build.gradle regularly?

  5. Α͘ॻ͘΍ͭ • debugϏϧυ͚ͩύοέʔδ໊Λม͑ͨΓ buildTypes { debug { applicationIdSuffix '.debug' versionNameSuffix

    '-debug' } }
  6. Α͘ॻ͘΍ͭ • gitͷϋογϡຒΊࠐΜͩΓ def hash = 'git rev-parse --short HEAD'.

    execute([], project.rootDir).in.text.trim() versionNameSuffix "-$hash"
  7. Α͘ॻ͘΍ͭ • APKϑΝΠϧ໊ʹόʔδϣϯೖΕͨΓ android.applicationVariants.all { variant -> variant.outputs.all { outputFileName

    = "${variant.name}-${variant.versionName}.apk" } }
  8. ศརͰ͢ΑͶʂ Ͱ΋…

  9. …͋ͪͪ͜Ͱॻ͍ͯΔ?

  10. ڞ௨Խ͠Α͏

  11. ຊ೔ͷ࿩ 1. GradleϓϥάΠϯɺࢥͬͨΑΓ؆୯ʹ࡞ΕΔ 2. ࡞͔ͬͯΒެ։͢Δ·ͰͷखॱΛશ෦આ໌ʂ 3. ൃදΛฉ͖ऴΘͬͨΒϓϥάΠϯ࡞ऀʹͳΕΔ

  12. Android։ൃޮ཰վળ GradleϓϥάΠϯ։ൃ جૅฤ

  13. build.gradle • ઃఆϑΝΠϧʹݟ͑Δ͚Ͳ • ʮϏϧυͷઃఆΛߦ͏εΫϦϓτʯ • ७વͨΔ Groovy εΫϦϓτ •

    JavaͰ΋ॻ͚Δ͠ɺKotlinͰ΋ॻ͚Δ
  14. build.gradle • ϧʔτʹ1ͭ + ϓϩδΣΫτ͝ͱʹ1ͭͣͭ ͕جຊ

  15. .gradleϑΝΠϧ • ࣮͸ϦϞʔτʹஔ͚Δ apply from: 'https://example.com/mysettings.groovy' • هड़ͨ͠৔ॴͰల։͞Εͨͷͱಉ͡ޮՌ • ࠷ॳͷྫ͙Β͍Ͱ͋Ε͹͜ΕͰڞ௨ԽͰ͖Δ

  16. ࠷খߏ੒ͷ GradleϓϥάΠϯ

  17. A plugin is simply any class that implements the Plugin

    interface. — Gradle User Manual
  18. Hello World!ϓϥάΠϯ class MyPlugin implements Plugin<Project> { @Override void apply(Project

    project) { println "Hello ${project.name}!" } } apply plugin: MyPlugin ✅ ͍͖ͳΓ build.gradle ʹ௚ʹॻ͍ͯOK
  19. షΓ෇͚ͯ

  20. ./gradlew "Hello app!"

  21. खܰͰ͠ΐʁ

  22. Plugin interface public interface Plugin<T> { void apply(T target); }

    • apply plugin: ͨ͠ͱ͖ʹݺͼग़͞ΕΔ • ͢΂ͯΛ͜͜Ͱఆٛ͢Δ • ઃఆΛ௥Ճ͢Δ, ৽͍͠λεΫΛ࡞Δ, ίʔϧόοΫΛઃఆ͢Δ, etc.
  23. ࣮૷Λॻ͍ͯΈΔ ྫ: debugϏϧυΛ෼͔Γ΍͘͢͢ΔϓϥάΠϯ • debugϏϧυ࣌ʹ • versionName ʹ -DEBUG Λ௥Ճ

    • applicationId ʹ .debug Λ௥Ճ Ͳ͔͜Ͱݟͨͳ? !
  24. 3෼લʹग़͖ͯͨ΍ͭ ͜ΕΛͳ . android { buildTypes { debug { applicationIdSuffix

    '.debug' versionNameSuffix '-DEBUG' } } } .ɹ
  25. classఆٛ + Project#with{}Ͱғͬͯ͋͛Δ ͜͏͡Ό class AutoDebugSuffixPlugin implements Plugin<Project> { void

    apply(Project target) { target.with { android { buildTypes { debug { applicationIdSuffix '.debug' versionNameSuffix '-DEBUG' } } } } } }
  26. ׬ˑ੒ ͋ͱ͸͜ͷ Plugin Λ apply ͢Δ apply plugin: AutoDebugSuffixPlugin •

    όʔδϣϯ໊ʹࣗಈతʹ -DEBUG ͕෇͘!
  27. …͍΍ઃఆ͙Β͍͍࣋ͨͤͨ • ʮόʔδϣϯ໊͸ม͑ͨ͘ͳ͍ʯͱ͔ • ͋ΔͰ͠ΐʁ

  28. Extension • ઃఆ஋Λ֨ೲ͢ΔΦϒδΣΫτ • ࣮ଶ͸JavaBean(field + getter/setter) • Project ʹ௥ՃͰ͖Δ

    • ͍ͭ΋ͷ android {} ΋ Extension • AppExtension
  29. Ͳ͏ઃఆΛهड़͍ͨ͠ʁ ྫ͑͹build.gradleʹ͜͏͍͏ײ͡Ͱॻ͖͍ͨ autoDebugSuffix { updateVersionName = false // όʔδϣϯ໊͸มߋͨ͘͠ͳ͍ }

  30. Extensionͷ࣮૷ class AutoDebugSuffixExtension { boolean updateVersionName = true // σϑΥϧτtrue

    } • GroovyͳΒ͜Ε͚ͩͰgetter/setter͕ੜ͑Δ • Ϋϥε໊͸ಛʹ੍໿͸ͳ͍ • Extension ͰऴΘΔͷ͕௨ྫ
  31. ProjectʹExtensionΛ௥Ճ void apply(Project target) { def extension = target.extensions.create( "autoDebugSuffix",

    AutoDebuguffixExtension ) } • build.gradle ಺Ͱ autoDebugSuffix {} Λ ఆٛՄೳʹ • if (extension.updateVersionName) Ͱ ධՁ͢Ε͹͍͍…ʁ
  32. ⾠ εΫϦϓτͷධՁॱং • ʮϏϧυͷઃఆΛߦ͏εΫϦϓτʯ • target.extensions.create ͷ࣌఺ • ·ͩઃఆͷهड़ߦ·Ͱ࣮ߦ͕౸ୡͯ͠ͳ͍

  33. class AutoDebugSuffixPlugin implements Plugin<Project> { void apply(Project target) { //

    [2] Projectʹ `autoDebugSuffix {}` ͕ੜ͑Δ def extension = target.extensions.create( "autoDebugSuffix", AutoDebuguffixExtension) // [3] if (extension.updateVersionName) ͯ͠΋ // ·ͩԼͷઃఆ͕ධՁ͞Ε͍ͯͳ͍ } } // [1] ͜͜Ͱ AutoDebugSuffixPlugin#apply() ͕ݺ͹ΕΔ apply plugin: AutoDebugSuffixPlugin // [4] apply ͔Β໭͖ͬͯͯɺҎԼ͕ධՁ͞ΕΔ autoDebugSuffix { updateDisplayVersion false }
  34. [3] ͷ࣌఺Ͱ͸ಈ͔ͳ͍ android { buildTypes { debug { applicationIdSuffix '.debug'

    // ҎԼͷΑ͏ʹॻ͖׵͑ͯ΋ظ଴௨Γʹ͸ಈ͔ͳ͍ if (extension.updateVersionName) { versionNameSuffix '-DEBUG' } } } }
  35. ͓ؾ࣋ͪ build.gradleΛҰ௨ΓධՁͨ͠ޙͰ ࣮ߦͯ͠΄͍͠ίʔυ͕͋ΔΜͩ…

  36. afterEvaluate ίʔϧόοΫ • build.gradleશମͷධՁޙʹݺͼग़ͯ͘͠ΕΔ • ઃఆ஋ʹґଘͨ͠ಈ࡞Λߦ͏λΠϛϯά

  37. void apply(Project target) { def extension = target.extensions.create( "autoDebugSuffix", AutoDebugSuffixExtension)

    // build.gradleͷධՁ͕ऴΘͬͨޙͰ࣮ߦ͞ΕΔ target.afterEvaluate { project -> project.android { buildTypes { debug { applicationIdSuffix '.debug' // ධՁޙͳͷͰઃఆ஋͕൓ө͞Ε͍ͯΔ if (extension.updateVersionName) { versionNameSuffix '-DEBUG' } } } } } }
  38. ͜ΕͰ • debugϏϧυΛࣗಈͰ෼͚ͯ͘ΕΔ • όʔδϣϯ໊Λ৮ͬͯཉ͘͠ͳ͍ͱ͖͸ autoDebugSuffix.updateVersionName = false ઃఆՄೳͳϓϥάΠϯ͕Ͱ͖ͨʂ

  39. ͦΖͦΖ ެ։Ͱ͖Δʁ

  40. ͪΐͬͱམͪͭ͜͏ • ެ։ͷํ๏͸໿10෼ޙʹઆ໌͠·͢ ͱ͜ΖͰ࿩͸มΘΔ͚Ͳ • APKϑΝΠϧͷग़ྗઌͬͯ஍ຯʹ ๨Ε͕ͪ͡Όͳ͍?

  41. APKϑΝΠϧͷग़ྗઌ productFlavor Ͱ֊૚͕ਂ͘ͳΓ͕ͪ

  42. ͜Μͳػೳཉ͘͠ͳ͍ʁ 1. Ϗϧυ׬ྃ࣌ʹग़ྗઌΛදࣔͯ͘͠ΕΔ 2. ࢦఆͨ͠ϑϨʔόʔͷAPKϑΝΠϧͷ৔ॴΛFinder Ͱ։͚Δ 3. Ϗϧυ׬ྃ࣌ʹࣗಈతʹϑΝΠϧͷ৔ॴΛ։͘Α ͏ʹ΋Ͱ͖Δ

  43. ࡞Γ·͠ΐ͏

  44. Android։ൃޮ཰վળ GradleϓϥάΠϯ։ൃ ࣮ફฤ

  45. ͜͜Ͱ΍Δ͜ͱ • GradleͷλεΫΛ࡞Δ • Gradle Android Pluginͱ࿈ܞ͢Δ

  46. λεΫ • ໊લ෇͖ͷॲཧͷմ • ίϚϯυϥΠϯ͔Βݺͼग़ͤΔ • ґଘؔ܎ΛఆٛͰ͖Δ ྫ ./gradlew assembleDebug

    • debugϏϧυͷAPKΛੜ੒͢Δ
  47. खܰͳλεΫͷఆٛํ๏ void apply(Project target) { target.task('hello').doLast { println "Hello!" }

    } ↓ $ ./gradlew hello Hello!
  48. ఆٛࡁΈͷλεΫʹ΋ॲཧΛ௥ՃՄೳ • Task#doFirst • λεΫͷઌ಄ʹ௥Ճ • Task#doLast • λεΫͷ࠷ޙʹ௥Ճ •

    << ͱ΋ॻ͚Δ(Gradle 5.0ͰdeprecatedʹͳΔ)
  49. λεΫʹॲཧΛ௥Ճ target.task('hello').doLast { println "Hello!" } target.task('hello').doLast { println "Nice

    to meet you!" } ↓ $ ./gradlew hello Hello! Nice to meet you!
  50. λεΫ͸ಈతʹੜ੒Մೳ ྫ: buildTypes ΍ productFlavors buildTypes { debug {}; release

    {} } productFlavors { development {}; production {} } ↓ assembleDevelopmentDebug, assembleDevelopmentRelease, assembleProductionDebug, assembleProductionRelease
  51. ࡞Γ͍ͨػೳ1 ʮϏϧυ׬ྃ࣌ʹग़ྗઌΛදࣔͯ͘͠ΕΔʯ 1. assemble*ͷ࠷ޙʹॲཧΛ௥Ճͯ͠΍Ε͹Αͦ͞͏ 㱺λεΫΛྻڍ͍ͨ͠ 2. ϑΝΠϧ໊Λऔಘͯ͘͠Δඞཁ͕͋Γͦ͏ 㱺ग़ྗઌͷ৘ใ͕ཉ͍͠

  52. Android Plugin DSL Reference https://google.github.io/android-gradle-dsl/current/

  53. ࠓճ࢖͏΋ͷ • AppExtension#applicationVariants • ͢΂ͯͷ ApplicationVariant Λ஌ͬͯΔ • developmentDebug, productionRelease

    ͳͲ • ApplicationVariant: Ϗϧυʹඞཁͳ৘ใ ✅ assemble λεΫʹΞΫηεͰ͖Δ ✅ outputs ͔Βग़ྗϑΝΠϧʹΞΫηεͰ͖Δ
  54. assemble ʹॲཧΛ௥Ճ • applicationVariants.all Ͱྻڍˍ௥Ճ͢Δ void apply(Project target) { target.android.applicationVariants.all

    { v -> v.assemble.doLast { println "${v.outputs.first().outputFile}" } } } • ApplicationVariant#outputs 㱺ग़ྗϑΝΠϧ৘ใ • obb෼ׂ͞ΕΔ࣌͸ෳ਺͋Δ(Ұ൪ઌ಄͕APK)
  55. assembleͯ͠ΈΔͱ $ ./gradlew assembleDevelopmentDebug > Task :app:assembleDevelopmentDebug /Users/tnj/git/MyKotlin/app/build/outputs/apk/development/ debug/app-development-debug.apk BUILD

    SUCCESSFUL in 1s 28 actionable tasks: 1 executed, 27 up-to-date • Ϗϧυ׬ྃ࣌ʹग़ྗઌ͕ग़ΔΑ͏ʹͳͬͨʂ
  56. ࡞Γ͍ͨػೳ2 ʮࢦఆͨ͠ϑϨʔόʔͷAPKϑΝΠϧͷ৔ॴΛ ɹFinderͰ։͚Δʯ • locate* ͱ͍͏λεΫΛੜ੒ͯ͠ΈΔ • "locate${variant.name.capitalize()}" • variant.name

    == "devDebug" • variant.name.captialize() == "DevDebug"
  57. locateλεΫΛ௥Ճ void apply(Project target) { target.android.applicationVariants.all { v -> target.task("locate${v.name.capitalize()}").doLast

    { ["open", "-R", variant.outputs.first().outputFile]. execute() } } } • ϑΝΠϧͷ৔ॴΛ։͘ʹ͸ Mac: open -R, Windows: explorer • List ʹ execute() ͕ੜ͑ͯΔ
  58. • ./gradlew locateDevelopmentDebug

  59. • λεΫ࣮ߦ͕׬ྃͯ͠

  60. • ग़ྗઌΛFinderͰ։͍ͨʂ

  61. ࡞Γ͍ͨػೳ3 ʮϏϧυ׬ྃ࣌ʹࣗಈతʹϑΝΠϧͷ৔ॴΛ։͘Α ͏ʹ΋Ͱ͖Δʯ • ͜Ε·Ͱͷ࣮૷ͷ૊Έ߹Θͤ • ґଘؔ܎Λઃఆͨ͠৽͍͠λεΫΛ࡞Δ • assemble λεΫʹґଘͤ͞Δ

  62. Ϗϧυ׬ྃ࣌ʹFinderΛ։͘ assembleAndLocate* ͱ͍͏λεΫΛ࡞Δ • dependsOn Ͱґଘ͢ΔλεΫΛࢦఆ void apply(Project target) {

    target.android.applicationVariants.all { v -> target.task( "assembleAndLocate${v.name.capitalize()}", dependsOn: v.assemble).doLast { ["open", "-R", v.outputs.first().outputFile]. execute() } } }
  63. • ./gradlew assembleAndLocateDevelopmentDebug

  64. • Ϗϧυ͕࣮ߦ͞Εͯ

  65. • ׬ྃ࣌ʹग़ྗઌΛFinderͰ։͍ͨʂ

  66. Ͱ͖ͨϓϥάΠϯ • Ϗϧυ׬ྃ࣌ʹग़ྗઌΛදࣔͯ͘͠ΕΔ • ࢦఆͨ͠ϑϨʔόʔͷAPKϑΝΠϧͷ৔ॴΛ FinderͰ։͚Δ • Ϗϧυ׬ྃ࣌ʹࣗಈతʹϑΝΠϧͷ৔ॴΛ ։͘Α͏ʹ΋Ͱ͖Δ ศརͳͷͰ͸ʁ

  67. …ͱɺαΫαΫ࡞͖ͬͯ·͕ͨ͠

  68. σόοάͱ͔Ͳ͏ͯ͠Δͷ

  69. σόοάTips 1/2 ʮྫ֎ు͍ͯ΋ BUILD FAILED ͚ͩʂʯ

  70. σόοάTips 1/2 ✅ --stacktrace ΦϓγϣϯΛ෇͚Δ • ελοΫτϨʔεు͘Α͏ʹͳΔ

  71. σόοάTips 2/2 ʮ͋ͷ͞σόοΨͱ͔࢖͑ͳ͍ͷʁʯ • Gradle΋JavaΞϓϦέʔγϣϯ ✅ Android StudioͷσόοΨΛΞλονՄೳ

  72. σόοΨͷ४උ 1/3 • Android Studio ͷ Edit Configuration Λ։͘

  73. σόοΨͷ४උ 2/3 • Add New Configuration Ͱ Remote Λબ୒

  74. σόοΨͷ४උ 3/3 • σϑΥϧτͷઃఆͷ··OK

  75. σόοΨΛ࢖͏ 1/4 • ͍ͭ΋௨ΓʹϒϨʔΫϙΠϯτΛઃఆ͢Δ

  76. σόοΨΛ࢖͏ 2/4 ./gradlew -Dorg.gradle.debug=true --no-daemon • Gradle͕࣮ߦ͞ΕͯɺσόοΨ଴ͪʹͳΔ

  77. σόοΨΛ࢖͏ 3/4 • Android Studio Ͱ Debug... ϘλϯΛԡ͢ • σόοΨ͕Ξλον͞Ε࣮ͯߦ͕ܧଓ͞ΕΔ

  78. σόοΨΛ࢖͏ 4/4 • ϒϨʔΫϙΠϯτͰࢭ·Δ • ஋Λࢀরͨ͠Γɺεςοϓ࣮ߦͨ͠Γ

  79. େମ࡞ΕΔΑ͏ʹͳΓ·ͨ͠Ͷ ެ։͍͖ͯ͠·͠ΐ͏

  80. ύοέʔδϯά • ҰൃͰϓϥάΠϯ༻ͷϓϩδΣΫτ͕Ͱ͖Δ ศརίϚϯυ͸ͳ͍ gradle init --type groovy-library͕Ұ൪͍ۙ • ςϯϓϨϓϩδΣΫτΛWeb্Ͱެ։ͯ͠Δํ΋

    • ͕ɺࠓճ͸࠷খߏ੒Ͱઆ໌͠·͢
  81. ܾΊͱ͘͜ͱ • ϓϥάΠϯID ྫ: sh.nothing.auto-debug-suffix • ΞϧϑΝϕοτɺ਺ࣈɺ.ɺ- • όʔδϣϯ //

    Πϝʔδ dependencies { classpath 'sh.nothing:auto-debug-suffix:0.1.0' }
  82. ࠷খݶඞཁͳϑΝΠϧ • src/main/ • groovy/${ϓϥάΠϯ࣮૷Ϋϥε}.groovy • resources/META-INF/gradle-plugins/ ${ϓϥάΠϯID}.properties • settings.gradle

    • த਎͸ۭͰOK • build.gradle
  83. ${ϓϥάΠϯID}.properties • Gradle͕࣮૷ΫϥεΛݟ͚ͭΔͨΊʹඞཁ • த਎͸ implementation-class= ͷ1ߦ implementation-class=sh.nothing.gradle.AutoDebugSuffixPlugin

  84. ߏ੒ྫ • src/ • main/ • resources/META-INF/gradle-plugins/ sh.nothing.auto-debug-suffix.properties • groovy/sh/nothing/gradle/

    AutoDebugSuffixPlugin.groovy • build.gradle • settings.gradle
  85. build.gradle ࠷௿ݶॻ͘಺༰͸࣍ͷ௨Γ apply plugin: 'groovy' dependencies { compile gradleApi() compile

    localGroovy() } version = '0.1.0'
  86. ࣮૷ϑΝΠϧ • ͖ͬ͞·Ͱbuild.gradleͷ࡞ͬͯͨ΍ͭΛίϐϖ! class AutoDebugSuffixPlugin implements Plugin<Project> { void apply(Project

    target) { def extension = target.extensions.create( "autoDebugSuffix", AutoDebugSuffixExtension) target.afterEvaluate { project -> project.android.buildTypes.debug { applicationIdSuffix '.debug' if (extension.updateVersionName) versionNameSuffix '-DEBUG' } } } }
  87. Android StudioͰ։͘ • build.gradle ͕Ͱ͖ͨΒ Android Studio Ͱ։͚Δ • ෆ଍͍ͯ͠Δ

    package ΍ import Λิ׬͢Δ • build.gradle ͷதͰ͸େମ import ͞Εͯͯෆཁ
  88. jarͷ࡞੒ • ./gradlew assemble ͨ͠Β jar ͷͰ͖͕͋Γ! • build/libs ͷԼʹͰ͖ͯΔ

  89. ϩʔΧϧͰ࢖ͬͯΈΑ͏ • mavenϓϥάΠϯͰϩʔΧϧΠϯετʔϧ͢Δ apply plugin: 'maven' group = 'sh.nothing' archivesBaseName

    = 'auto-debug-suffix' version = '0.1.0' • install λεΫ͕࢖͑ΔΑ͏ʹͳΔ ࣮ߦ͢Δͱ $HOME/.m2/repository ͷԼʹ഑ஔ
  90. ࢖ͬͯΈΔ ϩʔΧϧʹଞͷϓϩδΣΫτͷ build.gradle Ͱ buildscript { repositories { mavenLocal() //

    ϩʔΧϧͷϦϙδτϦΛ࢖͑ΔΑ͏ʹ͢Δ } dependencies { classpath 'sh.nothing:auto-debug-suffix:0.1.0' } } ͱॻ͍ͯɺ apply plugin: 'sh.nothing.auto-debug-suffix'
  91. ͳΜͱͳ͘ ͍ͭ΋࢖ͬͯΔײ͡ʹ͍͖ۙͮͯ·ͨ͠Ͷʁ

  92. ͍Α͍Αੈք΁ ެ։͢Δͱ͖

  93. Gradle Plugin Portal https://plugins.gradle.org/ Ҏલ͸Bintray͔Maven Central΁ͷ Ξοϓϩʔυ͕ඞཁ͚ͩͬͨͲࠓ͸ෆཁ

  94. ެ։खॱ 1/5 https://plugins.gradle.org/user/register ΞΧ΢ϯτΛ࡞Γ·͠ΐ͏

  95. ެ։खॱ 2/5 build.gradle ͷઌ಄ʹهड़ plugins { id "com.gradle.plugin-publish" version "0.9.9"

    }
  96. ެ։खॱ 3/5 ͓΋ΉΖʹ login λεΫΛ࣮ߦ ./gradlew login ϦϯΫ͕දࣔ͞ΕΔ

  97. ϦϯΫΛ։͘ͱ ΞΫϩόςΟοΫʹϩάΠϯ׬ྃʂ

  98. ެ։खॱ 4/5 ެ։ʹඞཁͳઃఆΛॻ͘ pluginBundle { website = 'https://github.com/tnj/auto-debug-suffix' vcsUrl =

    'https://github.com/tnj/auto-debug-suffix' description = 'Automatically add DEBUG suffix...' tags = ['android'] plugins { // ೚ҙͷ໊લͰෳ਺ఆٛՄೳ autoDebugSuffix { id = 'sh.nothing.auto-debug-suffix' displayName = 'Auto Debug Suffix Plugin' } } }
  99. ެ։खॱ 5/5 ./gradlew publishPlugins Λ࣮ߦ ͜ΕͰެ։׬ྃʂ͓खܰʂ

  100. ϓϩϑΟʔϧϖʔδʹ໭Δͱ

  101. Gradle Plugin Portalͷτοϓʹ΋

  102. ެ։ͨ͠ϓϥάΠϯͷ࢖͍ํ • ৽͍͠ plugins DSL͕࢖͑Δ dependencies ΍ apply plugin ͕ඞཁͳ͍

    • ࢖͍͍ͨϓϩδΣΫτͷ build.gradle ͷઌ಄ʹ plugins { id "sh.nothing.auto-debug-suffix" version "0.1.0" } ͱॻ͚͹ґଘղܾͱ apply ͕ಉ࣌ʹ׬ྃʂ
  103. plugins DSLʹ͍ͭͯ The feature is technically still incubating, but it

    works well, and should be used by most users. • ʮ΄ͱΜͲͷϢʔβʔʹ͸͕͓ͬͪ͜קΊʯ • ·੍ͩ໿͋Γ • version ʹม਺͕࢖͑ͳ͍ • ଞͷ apply plugin ͱͷ૊Έ߹Θͤ →࣍
  104. ࣮ࡍެ։͠·ͨ͠ ࢖͍ํ plugins { id "sh.nothing.auto-debug-suffix" version "0.1.0" id "sh.nothing.locate-apk"

    version "0.1.0" apply false } apply plugin: 'com.android.application' apply plugin: 'sh.nothing.locate-apk'
  105. ͓ΘΓʹ • GradleϓϥάΠϯ͸৽͍͠ϑΝΠϧ͑͞ ࡞Δ͜ͱͳ͘࡞Γ࢝ΊΒΕ·͢ • ͲΜͲΜ࡞ͬͯެ։͍͖ͯ͠·͠ΐ͏ • ࠓճͷ΍ͭ • github:tnj/gradle-auto-debug-suffix-plugin

    • github:tnj/gradle-locate-apk-plugin