Slide 1

Slide 1 text

Gradle: From User to Addict Jake Ouellette @jakeout

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

Simple Possible

Slide 5

Slide 5 text

Knowledge Gap • “Where does this variable live?” • “When does this behavior happen?” • “How do others do what I want to do?”

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

build.gradle

Slide 9

Slide 9 text

build.gradle apply plugin: 'android' android { compileSdkVersion 19 buildToolsVersion "19.0.3" defaultConfig { minSdkVersion 8 targetSdkVersion 19 versionCode 1 versionName "1.0" } buildTypes { release { runProguard false proguardFiles getDefaultProguardFile('proguard- android.txt'), 'proguard-rules.txt' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:19.+' }

Slide 10

Slide 10 text

I want to add a task!

Slide 11

Slide 11 text

build.gradle apply plugin: ‘com.android.application’

Slide 12

Slide 12 text

build.gradle android { compileSdkVersion 19 … }

Slide 13

Slide 13 text

build.gradle 19

Slide 14

Slide 14 text

build.gradle dependencies { compile 'com.android.support:appcompat-v7:19.+' compile fileTree(dir: 'libs', include: ['*.jar']) }

Slide 15

Slide 15 text

build.gradle dependencies { compile 'com.android.support:appcompat-v7:19.+' compile fileTree(dir: 'libs', include: ['*.jar']) }

Slide 16

Slide 16 text

build.gradle dependencies { compile 'com.android.support:appcompat-v7:19.+' compile fileTree(dir: 'libs', include: ['*.jar']) }

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

Overview • Scoping • Timing • Setup of Tasks • Reuse of Behaviors

Slide 20

Slide 20 text

Simple Possible

Slide 21

Slide 21 text

Simple Possible Possimple

Slide 22

Slide 22 text

Scope

Slide 23

Slide 23 text

dependencies { compile 'com.crashlytics.android:crashlytics:1.+' } build.gradle

Slide 24

Slide 24 text

build.gradle android { dependencies { compile 'com.crashlytics.android:crashlytics:1.+' } }

Slide 25

Slide 25 text

build.gradle android { … } dependencies { compile 'com.crashlytics.android:crashlytics:1.+' }

Slide 26

Slide 26 text

{?}

Slide 27

Slide 27 text

example.java new Runnable() { public void run() { … } }

Slide 28

Slide 28 text

example.java final int time = System.currentTimeMillis() new Runnable() { public void run() { … } }

Slide 29

Slide 29 text

example.java final int time = System.currentTimeMillis() new Runnable() { public void run() { System.out.println(time); } }

Slide 30

Slide 30 text

example.java final int time = System.currentTimeMillis() { System.out.println(time); }

Slide 31

Slide 31 text

build.gradle def closure = { println it } closure.call(“dogs”)

Slide 32

Slide 32 text

build.gradle android { … }

Slide 33

Slide 33 text

build.gradle android({ … })

Slide 34

Slide 34 text

android() = android.apply()

Slide 35

Slide 35 text

android.apply({ })

Slide 36

Slide 36 text

android.apply(Closure configuration)

Slide 37

Slide 37 text

build.gradle android { … }

Slide 38

Slide 38 text

build.gradle android { ? }

Slide 39

Slide 39 text

build.gradle { }

Slide 40

Slide 40 text

build.gradle { def a = … println a } local scope

Slide 41

Slide 41 text

build.gradle def a = … { println a } owner scope

Slide 42

Slide 42 text

build.gradle 1) local scope 2) delegate scope 3) owner scope

Slide 43

Slide 43 text

example closure.delegate = android

Slide 44

Slide 44 text

example closure.delegate = it (basically)

Slide 45

Slide 45 text

build.gradle println(android.getClass()) android { println(delegate.getClass()) }

Slide 46

Slide 46 text

command line output class com.android.build.gradle.AppExtension_Decorated class com.android.build.gradle.AppExtension_Decorated println(android.getClass()) android { println(delegate.getClass()) }

Slide 47

Slide 47 text

build.gradle android { compileSdkVersion 3 }

Slide 48

Slide 48 text

build.gradle android { compileSdkVersion 3 }

Slide 49

Slide 49 text

build.gradle android.compileSdkVersion

Slide 50

Slide 50 text

build.gradle android { setCompileSdkVersion(3) }

Slide 51

Slide 51 text

build.gradle android { getCompileSdkVersion() }

Slide 52

Slide 52 text

build.gradle android { defaultConfig { minSdkVersion 8 } }

Slide 53

Slide 53 text

defaultConfig.apply(Closure configuration)

Slide 54

Slide 54 text

build.gradle android { defaultConfig { minSdkVersion 8 } }

Slide 55

Slide 55 text

build.gradle println(android.defaultConfig.getClass()) android { defaultConfig { println(delegate.getClass()) } }

Slide 56

Slide 56 text

command line output class com.android.build.gradle.internal.dsl.ProductFlavorDsl_Decorated class com.android.build.gradle.internal.dsl.ProductFlavorDsl_Decorated println(android.defaultConfig.getClass()) android { defaultConfig { println(delegate.getClass()) } }

Slide 57

Slide 57 text

build.gradle android { defaultConfig { minSdkVersion 8 } }

Slide 58

Slide 58 text

build.gradle android.defaultConfig.minSdkVersion = 8 android{defaultConfig{minSdkVersion 8}} ~=

Slide 59

Slide 59 text

build.gradle android { dependencies { compile 'com.crashlytics.android:crashlytics:1.+' } }

Slide 60

Slide 60 text

build.gradle repositories { maven { url “example" } }

Slide 61

Slide 61 text

def maven(Closure closure)

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

def maven(Closure closure) mutation

Slide 65

Slide 65 text

build.gradle repositories { maven { url “example" maven { url "example2" } } }

Slide 66

Slide 66 text

build.gradle (with annotation) repositories { SEARCHED NEXT maven { SEARCHED FIRST maven { url ‘example2’ } } }

Slide 67

Slide 67 text

build.gradle android { dependencies { compile 'com.crashlytics.android:crashlytics:1.+' } }

Slide 68

Slide 68 text

build.gradle SEARCHED SECOND android { SEARCHED FIRST dependencies { compile 'com.crashlytics.android:crashlytics:1.+' } }

Slide 69

Slide 69 text

Timing

Slide 70

Slide 70 text

apply plugin: ‘android’ android { minSdkVersion 8 }

Slide 71

Slide 71 text

configuration apply plugin: ‘android’ android { minSdkVersion 8 } apply plugin: ‘android’ android { minSdkVersion 8 }

Slide 72

Slide 72 text

configuration apply plugin: ‘android’ android { minSdkVersion 8 } apply plugin: ‘android’ android { minSdkVersion 8 } execution :app:compileDebugAidl :app:compileDebugRenderscript :app:generateDebugBuildConfig :app:generateDebugAssets :app:mergeDebugAssets :app:generateDebugResValues :app:generateDebugResources :app:mergeDebugResources :app:processDebugManifest :app:processDebugResources :app:generateDebugSources :app:compileDebugJava :app:preDexDebug :app:dexDebug :app:processDebugJavaRes :app:validateDebugSigning :app:packageDebug :app:zipalignDebug :app:assembleDebug

Slide 73

Slide 73 text

apply plugin: ‘android’ android { minSdkVersion 8 } task print.doLast{ println(“Hi!”) } assemble.dependsOn(print)

Slide 74

Slide 74 text

configuration apply plugin: ‘android’ android { minSdkVersion 8 } task print.doLast{ println(“Hi!”) } assemble.dependsOn(print) apply plugin: ‘android’ android { minSdkVersion 8 } task print.doLast{ println(“Hi!”) } assemble.dependsOn(print)

Slide 75

Slide 75 text

configuration apply plugin: ‘android’ android { minSdkVersion 8 } task print.doLast{ println(“Hi!”) } assemble.dependsOn(print) apply plugin: ‘android’ android { minSdkVersion 8 } task print.doLast{ println(“Hi!”) } assemble.dependsOn(print) executed execution apply plugin: ‘android’ android { minSdkVersion 8 } task print.doLast{ println(“Hi!”) } assemble.dependsOn(print) :app:compileDebugRenderscript :app:generateDebugBuildConfig :app:generateDebugAssets :app:mergeDebugAssets :app:generateDebugResValues :app:generateDebugResources :app:mergeDebugResources :app:processDebugManifest :app:processDebugResources :app:generateDebugSources :app:compileDebugJava :app:preDexDebug :app:dexDebug :app:processDebugJavaRes :app:validateDebugSigning :app:packageDebug :app:zipalignDebug :app:print :app:assembleDebug

Slide 76

Slide 76 text

afterEvaluate { println android.minSdkVersion } apply plugin: ‘android’ android { minSdkVersion 8 }

Slide 77

Slide 77 text

configuration afterEvaluate { println android.minSdkVersion } apply plugin: ‘android’ android { minSdkVersion 8 } afterEvaluate { println android.minSdkVersion } apply plugin: ‘android’ android { minSdkVersion 8 }

Slide 78

Slide 78 text

configuration afterEvaluate { println android.minSdkVersion } apply plugin: ‘android’ android { minSdkVersion 8 } afterEvaluate { println android.minSdkVersion } apply plugin: ‘android’ android { minSdkVersion 8 } evaluated afterEvaluate { println android.minSdkVersion } apply plugin: ‘android’ android { minSdkVersion 8 }

Slide 79

Slide 79 text

configuration afterEvaluate { println android.minSdkVersion } apply plugin: ‘android’ android { minSdkVersion 8 } afterEvaluate { println android.minSdkVersion } apply plugin: ‘android’ android { minSdkVersion 8 } evaluated execution afterEvaluate { println android.minSdkVersion } apply plugin: ‘android’ android { minSdkVersion 8 } :app:compileDebugRenderscript :app:generateDebugBuildConfig :app:generateDebugAssets :app:mergeDebugAssets :app:generateDebugResValues :app:generateDebugResources :app:mergeDebugResources :app:processDebugManifest :app:processDebugResources :app:generateDebugSources :app:compileDebugJava :app:preDexDebug :app:dexDebug :app:processDebugJavaRes :app:validateDebugSigning :app:packageDebug :app:zipalignDebug :app:assembleDebug

Slide 80

Slide 80 text

Adding a task

Slide 81

Slide 81 text

Adding a task: Cache each build.gradle with a timestamp

Slide 82

Slide 82 text

build.gradle task copyTask(type: Copy)

Slide 83

Slide 83 text

build.gradle task copyTask(type: Copy) << { from ‘build.gradle’ into ‘buildCache’ rename {it + System.currentTimeMillis()} }

Slide 84

Slide 84 text

build.gradle task copyTask(type: Copy) << { from ‘build.gradle’ into ‘buildCache’ rename {it + System.currentTimeMillis()} }

Slide 85

Slide 85 text

build.gradle task copyTask(type: Copy) << { from ‘build.gradle’ into ‘buildCache’ rename {it + System.currentTimeMillis()} }

Slide 86

Slide 86 text

build.gradle task copyTask(type: Copy) << { from ‘build.gradle’ into ‘buildCache’ rename {it + System.currentTimeMillis()} }

Slide 87

Slide 87 text

ideal directory listing buildCache/ build.gradle1399906750071 build.gradle1401281449000 build.gradle1401290623000

Slide 88

Slide 88 text

command line output :app:copyTask UP-TO-DATE BUILD SUCCESSFUL

Slide 89

Slide 89 text

command line output > ls app/buildCache …

Slide 90

Slide 90 text

build.gradle task copyTask

Slide 91

Slide 91 text

No content

Slide 92

Slide 92 text

org.gradle.api Interface Project All Superinterfaces: Comparable, ExtensionAware, PluginAware public interface Project extends Comparable, ExtensionAware, PluginAware This interface is the main API you use to interact with Gradle from your build file. From a Project, you have programmatic access to all of Gradle's features.

Slide 93

Slide 93 text

build.gradle task copyTask

Slide 94

Slide 94 text

org.gradle.api Interface Project All Superinterfaces: Comparable, ExtensionAware, PluginAware public interface Project extends Comparable, ExtensionAware, PluginAware This interface is the main API you use to interact with Gradle from your build file. From a Project, you have programmatic access to all of Gradle's features.

Slide 95

Slide 95 text

Task task(Map args, String name) Creates a Task with the given name and adds it to this project. Task task(Map args, String name, Closure configureClosure) Creates a Task with the given name and adds it to this project. Task task(String name) Creates a Task with the given name and adds it to this project. Task task(String name, Closure configureClosure) Creates a Task with the given name and adds it to this project.

Slide 96

Slide 96 text

build.gradle task copyTask

Slide 97

Slide 97 text

build.gradle task(“copyTask”)

Slide 98

Slide 98 text

build.gradle project.task(“copyTask”)

Slide 99

Slide 99 text

build.gradle task copyTask(type: Copy)

Slide 100

Slide 100 text

build.gradle task(“copyTask”, [“type” : “Copy”]) groovy map

Slide 101

Slide 101 text

Task task(“copyTask”, [“type” : “Copy”])

Slide 102

Slide 102 text

build.gradle def apply(Closure closure)

Slide 103

Slide 103 text

build.gradle task copyTask(type: Copy) { from ‘build.gradle’ into ‘buildCache’ rename {it + System.currentTimeMillis()} }

Slide 104

Slide 104 text

command line output :app:copyTask

Slide 105

Slide 105 text

command line output > ls app/buildCache build.gradle1399906750071

Slide 106

Slide 106 text

build.gradle task copyTask(type: Copy) { from ‘build.gradle’ into ‘buildCache’ rename {it + System.currentTimeMillis()} }

Slide 107

Slide 107 text

build.gradle task copyTask(type: Copy) << { from ‘build.gradle’ into ‘buildCache’ rename {it + System.currentTimeMillis()} }

Slide 108

Slide 108 text

<< { }

Slide 109

Slide 109 text

.doLast({ })

Slide 110

Slide 110 text

apply plugin: ‘android’ android { minSdkVersion 8 } task print << { println(“Hi!”) } assemble.dependsOn(print)

Slide 111

Slide 111 text

configuration apply plugin: ‘android’ android { minSdkVersion 8 } task print << { println(“Hi!”) } assemble.dependsOn(print) apply plugin: ‘android’ android { minSdkVersion 8 } task print << { println(“Hi!”) } assemble.dependsOn(print)

Slide 112

Slide 112 text

configuration apply plugin: ‘android’ android { minSdkVersion 8 } task print << { println(“Hi!”) } assemble.dependsOn(print) apply plugin: ‘android’ android { minSdkVersion 8 } task print << { println(“Hi!”) } assemble.dependsOn(print) executed execution apply plugin: ‘android’ android { minSdkVersion 8 } task print << { println(“Hi!”) } assemble.dependsOn(print) :app:compileDebugRenderscript :app:generateDebugBuildConfig :app:generateDebugAssets :app:mergeDebugAssets :app:generateDebugResValues :app:generateDebugResources :app:mergeDebugResources :app:processDebugManifest :app:processDebugResources :app:generateDebugSources :app:compileDebugJava :app:preDexDebug :app:dexDebug :app:processDebugJavaRes :app:validateDebugSigning :app:packageDebug :app:zipalignDebug :app:print :app:assembleDebug

Slide 113

Slide 113 text

build.gradle task copyTask(type: Copy) { from ‘build.gradle’ into ‘buildCache’ rename {it + System.currentTimeMillis()} }

Slide 114

Slide 114 text

build.gradle task copyTask(type: Copy) { from ‘build.gradle’ into ‘buildCache’ rename {it + System.currentTimeMillis()} }

Slide 115

Slide 115 text

build.gradle task copyTask(type: Copy) { … } << { println(“Execution”) }

Slide 116

Slide 116 text

build.gradle task copyTask(type: Copy) { … } << { println(“Execution”) }

Slide 117

Slide 117 text

build.gradle task copyTask << { // Roll my own }

Slide 118

Slide 118 text

build.gradle Files.copy( new File("build.gradle"), new File(“${project.projectDir}/buildCache/build.gradle" + System.currentTimeMillis()))

Slide 119

Slide 119 text

build.gradle Files.copy( new File("build.gradle"), new File(“${project.projectDir}/buildCache/build.gradle" + System.currentTimeMillis()))

Slide 120

Slide 120 text

build.gradle task copyTask << { Files.copy( new File("build.gradle"), new File(“${project.projectDir}/buildCache/build.gradle" + System.currentTimeMillis())) }

Slide 121

Slide 121 text

TASK

Slide 122

Slide 122 text

TASK @Input @InputDirectory @InputFile @InputFiles

Slide 123

Slide 123 text

TASK @OutputDirectories @OutputDirectory @OutputFile @OutputFiles

Slide 124

Slide 124 text

TASK TASK EXECUTED

Slide 125

Slide 125 text

TASK TASK EXECUTED

Slide 126

Slide 126 text

TASK UP-TO-DATE

Slide 127

Slide 127 text

TASK TASK EXECUTED task emptyTask no inputs no outputs

Slide 128

Slide 128 text

build.gradle task copyTask { inputs.file new File("build.gradle") // outputs } << { // Java file copy code }

Slide 129

Slide 129 text

build.gradle task copyTask { inputs.file new File("build.gradle") // outputs } << { // Java file copy code }

Slide 130

Slide 130 text

build.gradle task copyTask { inputs.file new File("build.gradle"), // outputs } << { // Java file copy code }

Slide 131

Slide 131 text

build.gradle task copyTask(type: Copy) << { from ‘build.gradle’ into ‘buildCache’ rename {it + System.currentTimeMillis()} }

Slide 132

Slide 132 text

TASK TASK EXECUTED

Slide 133

Slide 133 text

TASK UP-TO-DATE task emptyCopy(type: Copy) TASK empty list of inputs empty list of outputs

Slide 134

Slide 134 text

TASK TASK EXECUTED task emptyTask no inputs no outputs

Slide 135

Slide 135 text

build.gradle task emptyCopy(type: Copy) << { }

Slide 136

Slide 136 text

build.gradle task emptyCopy(type: Copy) << { } COPY TASK HAS EMPTY SET OF THINGS TO COPY // CODE WILL NOT EXECUTE

Slide 137

Slide 137 text

build.gradle task copyTask(type: Copy) { from ‘build.gradle’ into ‘buildCache’ rename {it + System.currentTimeMillis()} } Good

Slide 138

Slide 138 text

build.gradle task copyTask(type: Copy) << { from ‘build.gradle’ into ‘buildCache’ rename {it + System.currentTimeMillis()} } BAD

Slide 139

Slide 139 text

build.gradle task copyTask << { Files.copy( new File("build.gradle"), new File(“${project.projectDir}/ buildCache/build.gradle" + System.currentTimeMillis())) } Weird

Slide 140

Slide 140 text

Code Reuse

Slide 141

Slide 141 text

build.gradle task copyTask(type: Copy) { from ‘build.gradle’ into ‘buildCache’ rename {it + System.currentTimeMillis()} } Good

Slide 142

Slide 142 text

build.gradle task copyTask(type: Copy) { from ‘build.gradle’ into ‘buildCache’ rename {it + System.currentTimeMillis()} } Good?

Slide 143

Slide 143 text

build.gradle task copyTask(type: Copy) { from ‘build.gradle’ into ‘buildCache’ rename {it + System.currentTimeMillis()} }

Slide 144

Slide 144 text

build.gradle task copyTask(type: Copy) { from ‘build.gradle’ into ‘buildCache’ rename {it + System.currentTimeMillis()} } task copyTask(type: Copy) { from ‘build.gradle’ into ‘buildCache’ rename {it + System.currentTimeMillis()} } task copyTask(type: Copy) { from ‘build.gradle’ into ‘buildCache’ rename {it + System.currentTimeMillis()} } task copyTask(type: Copy) { from ‘build.gradle’ into ‘buildCache’ rename {it + System.currentTimeMillis()} } task copyTask(type: Copy) { from ‘build.gradle’ into ‘buildCache’ rename {it + System.currentTimeMillis()} } task copyTask(type: Copy) { from ‘build.gradle’ into ‘buildCache’ rename {it + System.currentTimeMillis()} }

Slide 145

Slide 145 text

build.gradle class CacheBuild extends Copy { }

Slide 146

Slide 146 text

build.gradle class CacheBuild extends Copy { { … } }

Slide 147

Slide 147 text

build.gradle class CacheBuild extends Copy { { … } } plain ol’ java initializer

Slide 148

Slide 148 text

build.gradle class CacheBuild extends Copy { { from('build.gradle'); into('buildCache'); rename({ it + System.currentTimeMillis() }) } }

Slide 149

Slide 149 text

build.gradle task cache(type:CacheBuild)

Slide 150

Slide 150 text

App Project Root Library

Slide 151

Slide 151 text

App Project Root Library

Slide 152

Slide 152 text

App Project Root Library Custom Code

Slide 153

Slide 153 text

App Project Root Library

Slide 154

Slide 154 text

App Project Root Library buildsrc/src/main/groovy/CacheBuild.groovy Custom Code

Slide 155

Slide 155 text

App Project Root Library buildsrc/src/main/groovy/CacheBuild.groovy

Slide 156

Slide 156 text

App Project Root Library buildsrc/src/main/groovy/CacheBuild.groovy

Slide 157

Slide 157 text

App Project Root Library buildsrc/src/main/groovy/CacheBuild.groovy day-job/app

Slide 158

Slide 158 text

Local Maven Cache App Project Root Library CacheBuild.jar day-job/app

Slide 159

Slide 159 text

plugin.groovy (‘cache’).dependsOn(compile) assemble.dependsOn(‘cache’) Assemble Compile ‘cache’

Slide 160

Slide 160 text

build.gradle apply plugin: 'BuildCache'

Slide 161

Slide 161 text

Local Maven Cache Library CacheBuild Plugin day-job/app

Slide 162

Slide 162 text

build.gradle class BuildCache implements Plugin { void apply(Project project) { // Create task. project.task(…) // Link task dependencies. assemble.dependsOn(…) }

Slide 163

Slide 163 text

build.gradle class BuildCache implements Plugin { void apply(Project project) { // Create task. project.task(…) // Link task dependencies. assemble.dependsOn(…) } ‘cache’

Slide 164

Slide 164 text

build.gradle class BuildCache implements Plugin { void apply(Project project) { // Create task. project.task(…) // Link task dependencies. assemble.dependsOn(…) } ‘cache’ Assemble Compile

Slide 165

Slide 165 text

build.gradle class BuildCache implements Plugin { void apply(Project project) { // Create task. project.task(…) // Link task dependencies. project.android .applicationVariants.all { … } }

Slide 166

Slide 166 text

build.gradle apply plugin: 'BuildCache'

Slide 167

Slide 167 text

No content

Slide 168

Slide 168 text

No content

Slide 169

Slide 169 text

No content

Slide 170

Slide 170 text

No content

Slide 171

Slide 171 text

No content

Slide 172

Slide 172 text

build.gradle ExampleActivity.onClick() com.crashlytics.obfuscation.

Slide 173

Slide 173 text

build.gradle a.b() com.crashlytics.obfuscation.

Slide 174

Slide 174 text

Compile Task Dependency Graph Crashlytics Task Crashlytics Task

Slide 175

Slide 175 text

Building on top of Android

Slide 176

Slide 176 text

Pay attention to Android Gradle updates

Slide 177

Slide 177 text

0.3 * System requirements: * Gradle 1.3+ (tested on 1.3/1.4). Will not be compatible with 1.5. An update will be required. * Android Platform Tools 16.0.2+ * New Features: * Renderscript support. * Support for multi resource folders. See 'multires' sample. * PNG crunch is now done incrementally and in parallel. * Support for multi asset folders. * Support for asset folders in Library Projects. * Support for versionName suffix provided by the BuildType. * Testing * Default sourceset for tests now src/instrumentTest (instrumentTest for flavors) * Instrumentation tests now: * started from "deviceCheck" instead of "check" * run on all connected devices in parallel. * break the build if any test fails. * generate an HTML report for each flavor/project, but also aggregated. * New plugin 'android-reporting' to aggregate android test results across projects. See 'flavorlib' sample. * Improved DSL: * replaced android.target with android.compileSdkVersion to make it less confusing with targetSdkVersion * signing information now a SigningConfig object reusable across BuildType and ProductFlavor * ability to relocate a full sourceSet. See 'migrated' sample. * API to manipulate Build Variants. * Fixes: * Default Java compile target set to 1.6. * Fix generation of R classes in case libraries share same package name as the app project. 0.2 * Fixed support for windows. * Added support for customized sourceset. (http://tools.android.com/tech-docs/new-build-system/using-the-new-build-system#TOC-Working-with-and-Customizing- SourceSets) * Added support for dependency per configuration. * Fixed support for dependency on local jar files. * New samples "migrated" and "flavorlib"

Slide 178

Slide 178 text

No content

Slide 179

Slide 179 text

Resource Resource Resource Resource Merge Resources Task Android Gradle v0.4

Slide 180

Slide 180 text

java.lang.OutOfMemoryError Merge Resources Task Android Gradle v0.4

Slide 181

Slide 181 text

Resource Resource Resource Resource Merge Resources Task Android Gradle v0.5.4

Slide 182

Slide 182 text

Resource Resource Resource Resource Merge Resources Task Android Gradle v0.5.4 Merged Resource

Slide 183

Slide 183 text

Use extra properties to configure on a per-flavor basis

Slide 184

Slide 184 text

build.gradle android { productFlavors { paid { ext.crashlyticsEnabled = true } free { ext.crashlyticsEnabled = false } } }

Slide 185

Slide 185 text

build.gradle android.productFlavors.each { ext.crashlyticsEnabled }

Slide 186

Slide 186 text

build.gradle apply plugin: ‘com.android.application’ android { productFlavors { paid { } } } apply plugin: ‘io.fabric’

Slide 187

Slide 187 text

build.gradle apply plugin: ‘com.android.application’ android { productFlavors { paid { } } } apply plugin: ‘io.fabric’ apply plugin: ‘com.android.application’

Slide 188

Slide 188 text

build.gradle apply plugin: ‘com.android.application’ android { productFlavors { paid { } } } apply plugin: ‘io.fabric’ apply plugin: ‘com.android.application’ apply plugin: ‘io.fabric’

Slide 189

Slide 189 text

build.gradle apply plugin: ‘com.android.application’ android { productFlavors { paid { } } } apply plugin: ‘io.fabric’ apply plugin: ‘com.android.application’ android { productFlavors { paid { } } } apply plugin: ‘io.fabric’

Slide 190

Slide 190 text

build.gradle apply plugin: ‘com.android.application’ android { productFlavors { paid { } } } apply plugin: ‘io.fabric’ apply plugin: ‘com.android.application’ android { productFlavors { paid { } } } apply plugin: ‘io.fabric’ apply plugin: ‘io.fabric’

Slide 191

Slide 191 text

build.gradle apply plugin: ‘com.android.application’ android { productFlavors { paid { } } } apply plugin: ‘io.fabric’

Slide 192

Slide 192 text

build.gradle apply plugin: ‘com.android.application’ android { productFlavors { paid { } } } android.applicationVariants.all { variant -> // Rename package name } apply plugin: ‘io.fabric’

Slide 193

Slide 193 text

build.gradle apply plugin: ‘com.android.application’ android { productFlavors { paid { } } } android.applicationVariants.all { variant -> // Rename package name } apply plugin: ‘io.fabric’ apply plugin: ‘com.android.application’

Slide 194

Slide 194 text

build.gradle apply plugin: ‘com.android.application’ android { productFlavors { paid { } } } android.applicationVariants.all { variant -> // Rename package name } apply plugin: ‘io.fabric’ apply plugin: ‘com.android.application’ apply plugin: ‘io.fabric’

Slide 195

Slide 195 text

build.gradle apply plugin: ‘com.android.application’ android { productFlavors { paid { } } } android.applicationVariants.all { variant -> // Rename package name } apply plugin: ‘io.fabric’ apply plugin: ‘com.android.application’ android { productFlavors { paid { } } } apply plugin: ‘io.fabric’

Slide 196

Slide 196 text

build.gradle apply plugin: ‘com.android.application’ android { productFlavors { paid { } } } android.applicationVariants.all { variant -> // Rename package name } apply plugin: ‘io.fabric’ apply plugin: ‘com.android.application’ android { productFlavors { paid { } } } apply plugin: ‘io.fabric’ android.applicationVariants.all

Slide 197

Slide 197 text

build.gradle apply plugin: ‘com.android.application’ android { productFlavors { paid { } } } android.applicationVariants.all { variant -> // Rename package name } apply plugin: ‘io.fabric’ apply plugin: ‘com.android.application’ android { productFlavors { paid { } } } apply plugin: ‘io.fabric’ apply plugin: ‘io.fabric’ android.applicationVariants.all

Slide 198

Slide 198 text

build.gradle apply plugin: ‘com.android.application’ android { productFlavors { paid { } } } android.applicationVariants.all { variant -> // Rename package name } apply plugin: ‘io.fabric’ apply plugin: ‘com.android.application’ android { productFlavors { paid { } } } apply plugin: ‘io.fabric’ apply plugin: ‘io.fabric’ android.applicationVariants.all android.applicationVariants.all { variant -> // Rename package name }

Slide 199

Slide 199 text

plugin code.groovy afterEvaluate { // READ PACKAGE NAME } afterEvaluate { // CHANGE PACKAGE NAME }

Slide 200

Slide 200 text

apply plugin: ‘com.android.application’ android { productFlavors { paid { } } } apply plugin: ‘io.fabric’ android.applicationVariants.all { variant -> // Rename package name }

Slide 201

Slide 201 text

apply plugin: ‘com.android.application’ android { productFlavors { paid { } } } apply plugin: ‘io.fabric’ android.applicationVariants.all { variant -> // Rename package name }

Slide 202

Slide 202 text

Simple Possible

Slide 203

Slide 203 text

Simple Possible Simpossible

Slide 204

Slide 204 text

Jake Ouellette @jakeout Senior Software Engineer Twitter

Slide 205

Slide 205 text

No content