The new Android Build System! - linuxtag.org

52
Hans Dockter CEO, Gradleware Founder Gradle [email protected] The new Android Build System! Friday, May 24, 13

Transcript of The new Android Build System! - linuxtag.org

Page 1: The new Android Build System! - linuxtag.org

Hans DockterCEO, GradlewareFounder [email protected]

The new Android Build System!

Friday, May 24, 13

Page 2: The new Android Build System! - linuxtag.org

Android Build System

Friday, May 24, 13

Page 3: The new Android Build System! - linuxtag.org

Android Build System

=

Friday, May 24, 13

Page 4: The new Android Build System! - linuxtag.org

Android Build System

=

Gradle +

Friday, May 24, 13

Page 5: The new Android Build System! - linuxtag.org

Android Build System

=

Gradle +

most advanced build system(a.k.a. best)

Friday, May 24, 13

Page 6: The new Android Build System! - linuxtag.org

Android Build System

=

Gradle +

most advanced build system(a.k.a. best)

Android Gradle Plugin +IDE integration

Friday, May 24, 13

Page 7: The new Android Build System! - linuxtag.org

Android Build System

=

Gradle +

most advanced build system(a.k.a. best)

Magnificient piece of engineering by the Android Team

Android Gradle Plugin +IDE integration

Friday, May 24, 13

Page 8: The new Android Build System! - linuxtag.org

Show case for a state of the art build system

Friday, May 24, 13

Page 9: The new Android Build System! - linuxtag.org

4

Why a new system?

Friday, May 24, 13

Page 10: The new Android Build System! - linuxtag.org

DemoBasic Android

Friday, May 24, 13

Page 11: The new Android Build System! - linuxtag.org

Tailored Structure &

ProcessFriday, May 24, 13

Page 12: The new Android Build System! - linuxtag.org

• Product Flavors• Build Types• Build Variants• SourceSets• Library Projects• Testing

Friday, May 24, 13

Page 13: The new Android Build System! - linuxtag.org

Product Flavors

• A way to generate several versions of the same app• Source code + resources overlay

o Also custom dependencies• Customize app parameters:

o package nameo min/targetSdkVersiono versionCode/Nameo signing info

Friday, May 24, 13

Page 14: The new Android Build System! - linuxtag.org

BuildType

• Controls how an app is built• Source code + resources overlay

o Also custom dependencies• Customize app parameters:

o debuggable flago native debug compilation flago package suffixo debug signingo proguard options

• 2 default types: debug & release• orthogonal to product flavors

Friday, May 24, 13

Page 15: The new Android Build System! - linuxtag.org

Build Variant

• Build is always a flavor + a type

Debug Release

Free Free-Debug Free-Release

Paid Paid-Debug Paid-Release

Rules to manage overlaybuild type > flavor > main

Friday, May 24, 13

Page 16: The new Android Build System! - linuxtag.org

DemoBuild Variants

Friday, May 24, 13

Page 17: The new Android Build System! - linuxtag.org

Build Variant, cont'd

• Product Flavor groupso add extra dimensions of flavors

Debug Release

Free x86 Free-x86-Debug Free-x86-Release

ARM Free-Arm-Debug Free-Arm-Release

Paid x86 Paid-x86-Debug Paid-x86-Release

ARM Paid-Arm-Debug Paid-Arm-Release

Friday, May 24, 13

Page 18: The new Android Build System! - linuxtag.org

DemoFlavor Groups

Friday, May 24, 13

Page 19: The new Android Build System! - linuxtag.org

SourceSets

src/ main/ AndroidManifest.xml java/ resources/ assets/ ... debug/ ... release/ ... paid/ ... free/ ...

Friday, May 24, 13

Page 20: The new Android Build System! - linuxtag.org

Library Projects

• Binary bundle• Uploadable to Maven, Ivy, ...

o Declare their own dependencies• Contain:

o Compiled Codeo Resourceso + more

§ custom proguard rules?§ custom lint checks?§ annotation processor?§ IDE plugin?

Friday, May 24, 13

Page 21: The new Android Build System! - linuxtag.org

• Embedded in the project• test sourceset is default• test<flavor> sourceset allows flavor specific tests• APK for library project embed the library to test

Testing

Friday, May 24, 13

Page 22: The new Android Build System! - linuxtag.org

Dynamic Build-By-Convention

Friday, May 24, 13

Page 23: The new Android Build System! - linuxtag.org

Performance

Friday, May 24, 13

Page 24: The new Android Build System! - linuxtag.org

DemoIncremental Build

Friday, May 24, 13

Page 25: The new Android Build System! - linuxtag.org

Friday, May 24, 13

Page 26: The new Android Build System! - linuxtag.org

Gradle Daemon

Friday, May 24, 13

Page 27: The new Android Build System! - linuxtag.org

Deep IDE Integration

Friday, May 24, 13

Page 28: The new Android Build System! - linuxtag.org

Relax IDE, ain’t need to be a build tool anymore.

Friday, May 24, 13

Page 29: The new Android Build System! - linuxtag.org

Relax IDE, ain’t need to be a build tool anymore.

Close to canonical build

Friday, May 24, 13

Page 30: The new Android Build System! - linuxtag.org

Relax IDE, ain’t need to be a build tool anymore.

Close to canonical build

Optimized Performance

Friday, May 24, 13

Page 31: The new Android Build System! - linuxtag.org

Relax IDE, ain’t need to be a build tool anymore.

Close to canonical build

More automation

Optimized Performance

Friday, May 24, 13

Page 32: The new Android Build System! - linuxtag.org

Relax IDE, ain’t need to be a build tool anymore.

Close to canonical build

More automation

Optimized Performance

More feedback

Friday, May 24, 13

Page 33: The new Android Build System! - linuxtag.org

Tool Integration =

First Class Gradle citizen

Friday, May 24, 13

Page 34: The new Android Build System! - linuxtag.org

Tool Integration =

First Class Gradle citizen

Provisioning

Friday, May 24, 13

Page 35: The new Android Build System! - linuxtag.org

Tool Integration =

First Class Gradle citizen

Provisioning

Back & Forwardscompatibility

Friday, May 24, 13

Page 36: The new Android Build System! - linuxtag.org

Tool Integration =

First Class Gradle citizen

Provisioning

Back & Forwardscompatibility

Tailored Models

Friday, May 24, 13

Page 37: The new Android Build System! - linuxtag.org

Deep IDE customization

Friday, May 24, 13

Page 38: The new Android Build System! - linuxtag.org

Deep IDE customization

Declarative Elements

Friday, May 24, 13

Page 39: The new Android Build System! - linuxtag.org

Deep IDE customization

Declarative Elements

Programmatic Access

Friday, May 24, 13

Page 40: The new Android Build System! - linuxtag.org

eclipse.classpath.file { whenMerged { classpath -> classpath.entries.findAll { entry -> entry.kind == 'lib' }*.exported = false }}

Friday, May 24, 13

Page 41: The new Android Build System! - linuxtag.org

Android Studiobased on IntelliJ

is available!

Friday, May 24, 13

Page 42: The new Android Build System! - linuxtag.org

Version 0.4

• Proguard Support• NDK Support• Lint Support

Version 0.6

• T.b.d.

Version 0.5

• Emma• AVD Management

Friday, May 24, 13

Page 43: The new Android Build System! - linuxtag.org

Build Masters Delight

Friday, May 24, 13

Page 44: The new Android Build System! - linuxtag.org

DemoGradle Wrapper

Friday, May 24, 13

Page 45: The new Android Build System! - linuxtag.org

Friday, May 24, 13

Page 46: The new Android Build System! - linuxtag.org

DemoInit Scripts

Friday, May 24, 13

Page 47: The new Android Build System! - linuxtag.org

Friday, May 24, 13

Page 48: The new Android Build System! - linuxtag.org

org.gradle.daemon=true org.gradle.java.home=/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home org.gradle.jvmargs=-Xmx512M

Build Environment

Project specific gradle.properties

Friday, May 24, 13

Page 49: The new Android Build System! - linuxtag.org

http://gradlesummit.com

Gradle Summit 2013June 13-14

Santa Clara, CA, USA

Friday, May 24, 13

Page 52: The new Android Build System! - linuxtag.org

Hans DockterCEO, GradlewareFounder [email protected]

Questions?

Friday, May 24, 13