81
Etienne Studer VP of Product Tooling, Gradle Inc. Elegant Builds at Scale

Elegant Builds at Scale - Jfokus · Introduction to Gradle Gradle for Android Gradle C/C++ Workshop Advanced Gradle Fundamentals Advanced Extending Gradle Mastering Dependencies and

  • Upload
    others

  • View
    51

  • Download
    0

Embed Size (px)

Citation preview

Etienne Studer VP of Product Tooling, Gradle Inc.

Elegant Builds at Scale

Etienne Studer VP of Product Tooling, Gradle

Hans DockterCEO and Founder of Gradle

New companyGradleware Inc. —> Gradle, Inc.

New Twitter handle@gradleware —> @gradle

New domaingradle.com

New brand

BuildHappiness.

5,400,000 in 2014

800,000 in May 2015>1,000,000/m since October

Downloads

Build Infrastructure

–Johnny Appleseed

“Type a quote here.”

XXXL

Complexity

0

8

15

23

30

2011 2013

Release cycle (days) Two Releases per

day

15 daysInventory Term 0.5 days

Performance

Minimize the build time while using as little memory as needed.

Goal

Typically, not much changes in the build between consecutive invocations of the build.

When little changes in the build, little work should be done by the build.

Observation

Performance enhancements are achieved through evolutionary improvements and

revolutionary changes.

Approach

• Build configuration

• Dependency resolution

• Task Execution

Apply To

• Fix hotspots

• Cache and reuse

• Work in parallel

• Work in background

Daemon

http://www.gradle.org/docs/current/userguide/gradle_daemon.html

• ~/.gradle/gradle.properties org.gradle.daemon=true

• GRADLE_OPTS -Dorg.gradle.daemon=true

• Command Linegradlew tasks --daemon (--no-daemon)

Incremental build

Do not execute a given task if both its input and its output have not changed since the previous run.

Inputs —> Task —> Outputs

Optimize file change detection usingfile size, modification time, and content hash.

Continuous Mode

./gradlew build -t

Project Substitution

configurations.all { resolutionStrategy.dependencySubstitution { substitute module("org.utils:api") with project(":api") substitute project(":impl") with module("org.utils:impl:1.3") }}

https://docs.gradle.org/current/userguide/dependency_management.html#client-modules

Android Studio 2.0

Command Line gradle installDebug, 1 LOC added, Gradle 2.9

0

4.5

9

13.5

18

Dexing Install Other Overall

7.1

3.62.5

1

13.8

3.6

9.2

1

17.3

3.6

9.2

4.5

GP 1.3.1 GP 2.0.0-alpha1 Near Future

Estimate for Cold Swap & Emulator 2 Install

Android Studio post-2.0

Command Line gradle assembleDebug, 1 LOC changed, Gradle 2.9

0

2.25

4.5

6.75

9

Dexing Install Other Overall

7.1

3.6

2.5

1

9

5.5

2.5

1

Near Future Gradle 2.1 Near Future Gradle 2.9

Gradle performance

Without Improvements 30% slower

New Configuration Model

Apply the concepts already available in the Execution phase to the Configuration phase.

Describe what the model should look like and Gradle will provide the implementation.

Goal

Managed types@Managedinterface Picture {

String getName() void setName(String name)

List<String> getTags()

}

Pluginclass PicturesPlugin extends RuleSource { @Model void createPicture(Picture picture) {} @Mutate void configurePicture(Picture picture) { picture.name = 'mypic.jpg' picture.tags.addAll(['nature', 'night']) }}

DSLmodel { picture(Picture) { name = 'mypic.jpg' tags.addAll(['night', 'moon']) } }

Report

• Richer modeling

• Cleaner modeling

• Collaborative modeling

• Comprehensible model

Modeling

Performance

Modeling

JVM Software Model

model { components { service(JvmLibrarySpec) { sources { java { source.srcDir 'src/service/java' dependencies { library 'org.eclipse.jetty:jetty-servlet: 9.3.5.v20151012' exported(true) library 'org.apache.httpcomponents:httpclient: 4.5.1' } } } api { exports 'org.gradle.example.service' } targetPlatform 'java7' targetPlatform 'java8' } } }

Service

model { components { client(JvmLibrarySpec) { sources { java { source.srcDir 'src/client/java' dependencies { project ':service' library 'service' } } } targetPlatform 'java6' targetPlatform 'java7' targetPlatform 'java8' targetPlatform ‘java9' } }}

Client

Variant-aware dependency mgmt.

Compiler Avoidance

1

2 876543 9

10

11

12

13

15

14

16 191817

Company Standards

High-level DSL

products {

product(‘foo) {

europe {

host = ‘alpha’

}

asia {

host = ‘beta’

}

}

}

Dependency Management

Policies

http://www.gradle.org/docs/current/userguide/init_scripts.html

gradle.taskGraph.whenReady {

allprojects { Project project ->

def androidExtension = project.extensions.findByName('android')

if (androidExtension) {

def release = androidExtension.buildTypes.find { def buildType ->

buildType.name == 'release'

}

if(!release?.runProguard){

def msg = "Build type '$release.name' must run proGuard."

throw new IllegalStateException(msg)

}

}

}

}

Custom Gradle Distribution

http://www.gradle.org/docs/current/userguide/init_scripts.html

GRADLE_HOME/init.d/*.gradle

Wrapping Gradle

IDE Integration

Extensibility

Custom Build Environment

Composite Builds

Coming son

Distributed Cache/Builds

Gradle Saas

Gradle Expertise

Introductory & IntermediateIntroduction to Gradle

Gradle for AndroidGradle C/C++ Workshop

Advanced Gradle FundamentalsAdvanced

Extending GradleMastering Dependencies and Multi-project Builds

Standardizing Enterprise BuildsContinuous Delivery with Gradle

Etienne Studer VP of Product Tooling, Gradle Inc.

Elegant Builds at Scale