Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

ରԠ؀ڥ • Gradle 4.4 • Gradle Android Plugin 3.2.0-alpha01 • Android Studio 3.1 Preview

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

Α͘ॻ͘΍ͭ • gitͷϋογϡຒΊࠐΜͩΓ def hash = 'git rev-parse --short HEAD'. execute([], project.rootDir).in.text.trim() versionNameSuffix "-$hash"

Slide 7

Slide 7 text

Α͘ॻ͘΍ͭ • APKϑΝΠϧ໊ʹόʔδϣϯೖΕͨΓ android.applicationVariants.all { variant -> variant.outputs.all { outputFileName = "${variant.name}-${variant.versionName}.apk" } }

Slide 8

Slide 8 text

ศརͰ͢ΑͶʂ Ͱ΋…

Slide 9

Slide 9 text

…͋ͪͪ͜Ͱॻ͍ͯΔ?

Slide 10

Slide 10 text

ڞ௨Խ͠Α͏

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

build.gradle • ϧʔτʹ1ͭ + ϓϩδΣΫτ͝ͱʹ1ͭͣͭ ͕جຊ

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

࠷খߏ੒ͷ GradleϓϥάΠϯ

Slide 17

Slide 17 text

A plugin is simply any class that implements the Plugin interface. — Gradle User Manual

Slide 18

Slide 18 text

Hello World!ϓϥάΠϯ class MyPlugin implements Plugin { @Override void apply(Project project) { println "Hello ${project.name}!" } } apply plugin: MyPlugin ✅ ͍͖ͳΓ build.gradle ʹ௚ʹॻ͍ͯOK

Slide 19

Slide 19 text

షΓ෇͚ͯ

Slide 20

Slide 20 text

./gradlew "Hello app!"

Slide 21

Slide 21 text

खܰͰ͠ΐʁ

Slide 22

Slide 22 text

Plugin interface public interface Plugin { void apply(T target); } • apply plugin: ͨ͠ͱ͖ʹݺͼग़͞ΕΔ • ͢΂ͯΛ͜͜Ͱఆٛ͢Δ • ઃఆΛ௥Ճ͢Δ, ৽͍͠λεΫΛ࡞Δ, ίʔϧόοΫΛઃఆ͢Δ, etc.

Slide 23

Slide 23 text

࣮૷Λॻ͍ͯΈΔ ྫ: debugϏϧυΛ෼͔Γ΍͘͢͢ΔϓϥάΠϯ • debugϏϧυ࣌ʹ • versionName ʹ -DEBUG Λ௥Ճ • applicationId ʹ .debug Λ௥Ճ Ͳ͔͜Ͱݟͨͳ? !

Slide 24

Slide 24 text

3෼લʹग़͖ͯͨ΍ͭ ͜ΕΛͳ . android { buildTypes { debug { applicationIdSuffix '.debug' versionNameSuffix '-DEBUG' } } } .ɹ

Slide 25

Slide 25 text

classఆٛ + Project#with{}Ͱғͬͯ͋͛Δ ͜͏͡Ό class AutoDebugSuffixPlugin implements Plugin { void apply(Project target) { target.with { android { buildTypes { debug { applicationIdSuffix '.debug' versionNameSuffix '-DEBUG' } } } } } }

Slide 26

Slide 26 text

׬ˑ੒ ͋ͱ͸͜ͷ Plugin Λ apply ͢Δ apply plugin: AutoDebugSuffixPlugin • όʔδϣϯ໊ʹࣗಈతʹ -DEBUG ͕෇͘!

Slide 27

Slide 27 text

…͍΍ઃఆ͙Β͍͍࣋ͨͤͨ • ʮόʔδϣϯ໊͸ม͑ͨ͘ͳ͍ʯͱ͔ • ͋ΔͰ͠ΐʁ

Slide 28

Slide 28 text

Extension • ઃఆ஋Λ֨ೲ͢ΔΦϒδΣΫτ • ࣮ଶ͸JavaBean(field + getter/setter) • Project ʹ௥ՃͰ͖Δ • ͍ͭ΋ͷ android {} ΋ Extension • AppExtension

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

Extensionͷ࣮૷ class AutoDebugSuffixExtension { boolean updateVersionName = true // σϑΥϧτtrue } • GroovyͳΒ͜Ε͚ͩͰgetter/setter͕ੜ͑Δ • Ϋϥε໊͸ಛʹ੍໿͸ͳ͍ • Extension ͰऴΘΔͷ͕௨ྫ

Slide 31

Slide 31 text

ProjectʹExtensionΛ௥Ճ void apply(Project target) { def extension = target.extensions.create( "autoDebugSuffix", AutoDebuguffixExtension ) } • build.gradle ಺Ͱ autoDebugSuffix {} Λ ఆٛՄೳʹ • if (extension.updateVersionName) Ͱ ධՁ͢Ε͹͍͍…ʁ

Slide 32

Slide 32 text

⾠ εΫϦϓτͷධՁॱং • ʮϏϧυͷઃఆΛߦ͏εΫϦϓτʯ • target.extensions.create ͷ࣌఺ • ·ͩઃఆͷهड़ߦ·Ͱ࣮ߦ͕౸ୡͯ͠ͳ͍

Slide 33

Slide 33 text

class AutoDebugSuffixPlugin implements Plugin { 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 }

Slide 34

Slide 34 text

[3] ͷ࣌఺Ͱ͸ಈ͔ͳ͍ android { buildTypes { debug { applicationIdSuffix '.debug' // ҎԼͷΑ͏ʹॻ͖׵͑ͯ΋ظ଴௨Γʹ͸ಈ͔ͳ͍ if (extension.updateVersionName) { versionNameSuffix '-DEBUG' } } } }

Slide 35

Slide 35 text

͓ؾ࣋ͪ build.gradleΛҰ௨ΓධՁͨ͠ޙͰ ࣮ߦͯ͠΄͍͠ίʔυ͕͋ΔΜͩ…

Slide 36

Slide 36 text

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

Slide 37

Slide 37 text

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' } } } } } }

Slide 38

Slide 38 text

͜ΕͰ • debugϏϧυΛࣗಈͰ෼͚ͯ͘ΕΔ • όʔδϣϯ໊Λ৮ͬͯཉ͘͠ͳ͍ͱ͖͸ autoDebugSuffix.updateVersionName = false ઃఆՄೳͳϓϥάΠϯ͕Ͱ͖ͨʂ

Slide 39

Slide 39 text

ͦΖͦΖ ެ։Ͱ͖Δʁ

Slide 40

Slide 40 text

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

Slide 41

Slide 41 text

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

Slide 42

Slide 42 text

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

Slide 43

Slide 43 text

࡞Γ·͠ΐ͏

Slide 44

Slide 44 text

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

Slide 45

Slide 45 text

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

Slide 46

Slide 46 text

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

Slide 47

Slide 47 text

खܰͳλεΫͷఆٛํ๏ void apply(Project target) { target.task('hello').doLast { println "Hello!" } } ↓ $ ./gradlew hello Hello!

Slide 48

Slide 48 text

ఆٛࡁΈͷλεΫʹ΋ॲཧΛ௥ՃՄೳ • Task#doFirst • λεΫͷઌ಄ʹ௥Ճ • Task#doLast • λεΫͷ࠷ޙʹ௥Ճ • << ͱ΋ॻ͚Δ(Gradle 5.0ͰdeprecatedʹͳΔ)

Slide 49

Slide 49 text

λεΫʹॲཧΛ௥Ճ target.task('hello').doLast { println "Hello!" } target.task('hello').doLast { println "Nice to meet you!" } ↓ $ ./gradlew hello Hello! Nice to meet you!

Slide 50

Slide 50 text

λεΫ͸ಈతʹੜ੒Մೳ ྫ: buildTypes ΍ productFlavors buildTypes { debug {}; release {} } productFlavors { development {}; production {} } ↓ assembleDevelopmentDebug, assembleDevelopmentRelease, assembleProductionDebug, assembleProductionRelease

Slide 51

Slide 51 text

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

Slide 52

Slide 52 text

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

Slide 53

Slide 53 text

ࠓճ࢖͏΋ͷ • AppExtension#applicationVariants • ͢΂ͯͷ ApplicationVariant Λ஌ͬͯΔ • developmentDebug, productionRelease ͳͲ • ApplicationVariant: Ϗϧυʹඞཁͳ৘ใ ✅ assemble λεΫʹΞΫηεͰ͖Δ ✅ outputs ͔Βग़ྗϑΝΠϧʹΞΫηεͰ͖Δ

Slide 54

Slide 54 text

assemble ʹॲཧΛ௥Ճ • applicationVariants.all Ͱྻڍˍ௥Ճ͢Δ void apply(Project target) { target.android.applicationVariants.all { v -> v.assemble.doLast { println "${v.outputs.first().outputFile}" } } } • ApplicationVariant#outputs 㱺ग़ྗϑΝΠϧ৘ใ • obb෼ׂ͞ΕΔ࣌͸ෳ਺͋Δ(Ұ൪ઌ಄͕APK)

Slide 55

Slide 55 text

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 • Ϗϧυ׬ྃ࣌ʹग़ྗઌ͕ग़ΔΑ͏ʹͳͬͨʂ

Slide 56

Slide 56 text

࡞Γ͍ͨػೳ2 ʮࢦఆͨ͠ϑϨʔόʔͷAPKϑΝΠϧͷ৔ॴΛ ɹFinderͰ։͚Δʯ • locate* ͱ͍͏λεΫΛੜ੒ͯ͠ΈΔ • "locate${variant.name.capitalize()}" • variant.name == "devDebug" • variant.name.captialize() == "DevDebug"

Slide 57

Slide 57 text

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() ͕ੜ͑ͯΔ

Slide 58

Slide 58 text

• ./gradlew locateDevelopmentDebug

Slide 59

Slide 59 text

• λεΫ࣮ߦ͕׬ྃͯ͠

Slide 60

Slide 60 text

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

Slide 61

Slide 61 text

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

Slide 62

Slide 62 text

Ϗϧυ׬ྃ࣌ʹ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() } } }

Slide 63

Slide 63 text

• ./gradlew assembleAndLocateDevelopmentDebug

Slide 64

Slide 64 text

• Ϗϧυ͕࣮ߦ͞Εͯ

Slide 65

Slide 65 text

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

Slide 66

Slide 66 text

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

Slide 67

Slide 67 text

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

Slide 68

Slide 68 text

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

Slide 69

Slide 69 text

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

Slide 70

Slide 70 text

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

Slide 71

Slide 71 text

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

Slide 72

Slide 72 text

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

Slide 73

Slide 73 text

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

Slide 74

Slide 74 text

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

Slide 75

Slide 75 text

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

Slide 76

Slide 76 text

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

Slide 77

Slide 77 text

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

Slide 78

Slide 78 text

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

Slide 79

Slide 79 text

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

Slide 80

Slide 80 text

ύοέʔδϯά • ҰൃͰϓϥάΠϯ༻ͷϓϩδΣΫτ͕Ͱ͖Δ ศརίϚϯυ͸ͳ͍ gradle init --type groovy-library͕Ұ൪͍ۙ • ςϯϓϨϓϩδΣΫτΛWeb্Ͱެ։ͯ͠Δํ΋ • ͕ɺࠓճ͸࠷খߏ੒Ͱઆ໌͠·͢

Slide 81

Slide 81 text

ܾΊͱ͘͜ͱ • ϓϥάΠϯID ྫ: sh.nothing.auto-debug-suffix • ΞϧϑΝϕοτɺ਺ࣈɺ.ɺ- • όʔδϣϯ // Πϝʔδ dependencies { classpath 'sh.nothing:auto-debug-suffix:0.1.0' }

Slide 82

Slide 82 text

࠷খݶඞཁͳϑΝΠϧ • src/main/ • groovy/${ϓϥάΠϯ࣮૷Ϋϥε}.groovy • resources/META-INF/gradle-plugins/ ${ϓϥάΠϯID}.properties • settings.gradle • த਎͸ۭͰOK • build.gradle

Slide 83

Slide 83 text

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

Slide 84

Slide 84 text

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

Slide 85

Slide 85 text

build.gradle ࠷௿ݶॻ͘಺༰͸࣍ͷ௨Γ apply plugin: 'groovy' dependencies { compile gradleApi() compile localGroovy() } version = '0.1.0'

Slide 86

Slide 86 text

࣮૷ϑΝΠϧ • ͖ͬ͞·Ͱbuild.gradleͷ࡞ͬͯͨ΍ͭΛίϐϖ! class AutoDebugSuffixPlugin implements Plugin { 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' } } } }

Slide 87

Slide 87 text

Android StudioͰ։͘ • build.gradle ͕Ͱ͖ͨΒ Android Studio Ͱ։͚Δ • ෆ଍͍ͯ͠Δ package ΍ import Λิ׬͢Δ • build.gradle ͷதͰ͸େମ import ͞Εͯͯෆཁ

Slide 88

Slide 88 text

jarͷ࡞੒ • ./gradlew assemble ͨ͠Β jar ͷͰ͖͕͋Γ! • build/libs ͷԼʹͰ͖ͯΔ

Slide 89

Slide 89 text

ϩʔΧϧͰ࢖ͬͯΈΑ͏ • mavenϓϥάΠϯͰϩʔΧϧΠϯετʔϧ͢Δ apply plugin: 'maven' group = 'sh.nothing' archivesBaseName = 'auto-debug-suffix' version = '0.1.0' • install λεΫ͕࢖͑ΔΑ͏ʹͳΔ ࣮ߦ͢Δͱ $HOME/.m2/repository ͷԼʹ഑ஔ

Slide 90

Slide 90 text

࢖ͬͯΈΔ ϩʔΧϧʹଞͷϓϩδΣΫτͷ build.gradle Ͱ buildscript { repositories { mavenLocal() // ϩʔΧϧͷϦϙδτϦΛ࢖͑ΔΑ͏ʹ͢Δ } dependencies { classpath 'sh.nothing:auto-debug-suffix:0.1.0' } } ͱॻ͍ͯɺ apply plugin: 'sh.nothing.auto-debug-suffix'

Slide 91

Slide 91 text

ͳΜͱͳ͘ ͍ͭ΋࢖ͬͯΔײ͡ʹ͍͖ۙͮͯ·ͨ͠Ͷʁ

Slide 92

Slide 92 text

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

Slide 93

Slide 93 text

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

Slide 94

Slide 94 text

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

Slide 95

Slide 95 text

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

Slide 96

Slide 96 text

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

Slide 97

Slide 97 text

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

Slide 98

Slide 98 text

ެ։खॱ 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' } } }

Slide 99

Slide 99 text

ެ։खॱ 5/5 ./gradlew publishPlugins Λ࣮ߦ ͜ΕͰެ։׬ྃʂ͓खܰʂ

Slide 100

Slide 100 text

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

Slide 101

Slide 101 text

Gradle Plugin Portalͷτοϓʹ΋

Slide 102

Slide 102 text

ެ։ͨ͠ϓϥάΠϯͷ࢖͍ํ • ৽͍͠ plugins DSL͕࢖͑Δ dependencies ΍ apply plugin ͕ඞཁͳ͍ • ࢖͍͍ͨϓϩδΣΫτͷ build.gradle ͷઌ಄ʹ plugins { id "sh.nothing.auto-debug-suffix" version "0.1.0" } ͱॻ͚͹ґଘղܾͱ apply ͕ಉ࣌ʹ׬ྃʂ

Slide 103

Slide 103 text

plugins DSLʹ͍ͭͯ The feature is technically still incubating, but it works well, and should be used by most users. • ʮ΄ͱΜͲͷϢʔβʔʹ͸͕͓ͬͪ͜קΊʯ • ·੍ͩ໿͋Γ • version ʹม਺͕࢖͑ͳ͍ • ଞͷ apply plugin ͱͷ૊Έ߹Θͤ →࣍

Slide 104

Slide 104 text

࣮ࡍެ։͠·ͨ͠ ࢖͍ํ 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'

Slide 105

Slide 105 text

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