Gradle heading 4.0 - #CodeFest
CodeFest 2017
Gradle 3.0 and beyond
Gradle heading 4.0
René Gröschke
WHOAMI
speaker {
name 'René Gröschke'
homebase 'Berlin, Germany'
work 'Principal Engineer @ Gradle Inc.'
twitter '@breskeby'
github 'breskeby'
email 'rene@gradle.com'
}
WE’LLLOOKINTO
Latest features
Next features
Demos
Q&A
STICKERS!
GRADLE(THEMANAGEMENTSUMMARY)
Multi purpose software automation tool
Build, automate and deliver better software, faster
Cross-platform
Language agnostic
Apache v2 licensed
A Build Tool + Cloud Services
MOMENTUM
~30 full time engineers working on Gradle
3.0 released on August 15th 2016
3.4.1 released on March 3rd 2017
3.5-rc-1 released on March 22nd 2017
Releasing every 4 - 6 weeks.
LATESTFEATURES
KOTLINBASEDGRADLEDSL
MOTIVATION
Current DSL was not designed for
performance
tooling friendlyness
Limitations on bringing patterns and techniques from
application level to build level
KOTLIN(MANAGEMENTSUMMARY)
Statically typed
1.0 released in 2016
Driven by pragmatism
Invented and maintained by Jetbrains
Considerable uptake (particularly in the Android community).
ENTICINGOPPORTUNITIES
Proper IDE support
Code completion
Refactoring
Documentation lookup
Crafting DSLs with ease
While keeping build scripts clean and declarative
CURRENTSTATE
Working closely with Jetbrains
Kotlin 1.1.0 support in Gradle 3.5-rc-1
v0.8 in Gradle 3.5-rc-1
KOTLININGRADLE
apply<ApplicationPlugin>()
configure<ApplicationPluginConvention> {
mainClassName = "samples.HelloWorld"
}
configure<JavaPluginConvention> {
setSourceCompatibility(1.7)
}
repositories {
jcenter()
}
dependencies {
testCompile("junit:junit:4.12")
}
WHOSEBUILDISTOOFAST?
PERFORMANCEISAFEATURE
DEDICATEDPERFORMANCETEAM
Better Android dev experience
Faster dependency resolution
Lower con guration time
SOMENUMBERS
AGP version +
Gradle version
AGP 2.2.0 +
Gradle 2.14.1
AGP 2.3 RC1
+ Gradle 3.3
AGP 2.5
Alpha +
Gradle Nightly
AGP version +
Gradle version
AGP 2.2.0 +
Gradle 2.14.1
AGP 2.3 RC1
+ Gradle 3.3
AGP 2.5
Alpha +
Gradle Nightly
Con guration
(i.e. help)
~2 mins ~9 s ~2.5 s
1-line Java
change
(implementation
change)
~2 mins 15 s ~29 s ~6.4 s
COMPOSITEBUILDS
COMPOSITEBUILDS
Have you ever (tried | suffered from | failed on)
including an external project into your build for debugging?
moving separated projects into a big mono repo to make dev
life easier?
to test your gradle plugins in dev against real projects?
COMPOSITEBUILDSTOTHERESCUE
COMPOSITEBUILDS
De ned in the command line:
> gradle --include-build ../my-utils run
Or persistently
// settings.gradle
rootProject.name='adhoc'
includeBuild '../my-app'
includeBuild '../my-utils'
DEMO
COMPILEAVOIDANCE
SOFAR
Task up-to-date check been there forever
Relies on tasks inputs/outputs model
GRADLECANDOBETTER
BETTERCOMPILEAVOIDANCE
Gradle now detects ABI changes
Dramatically improves incremental build performance
DEMO
MOREJAVAGOODNESS
Better incremental java compiler
Working on making incremental compilation default
java-library plugin
less classpath leakage
better poms than maven
apply plugin:'java-library'
dependencies {
api 'org.apache.commons:commons-math3:3.6.1'
implementation 'com.google.guava:guava:21.0'
}
TALKINGABOUTUP-TO-DATECHECKS…
GRADLEISREUSINGRESULTS…
from last time

when we ran this build

on this machine.
GRADLECANDOBETTER
WHYNOT…
from anytime before

when we ran any build

anywhere.
BUILDCACHE(WIP)
$> gradle --build-cache assemble
Build cache is an incubating feature.
Using directory (/Users/rene/.gradle/caches/build-cache-1) as local build cache, push is e
:compileJava FROM-CACHE
:processResources
:classes
:jar
:assemble
BUILD SUCCESSFUL
DISTRIBUTEDBUILDCACHE(WIP)
// settings.gradle
ext.isCiServer = System.getenv().containsKey("CI")
buildCache {
local {
enabled = !isCiServer
}
remote(HttpBuildCache) {
url = 'https://example.com:8123/build-cache/'
push = isCiServer
}
}
TALKINGABOUTBUILDS
WOULDN’TITBENICEIFWECOULD…
COLLABORATE
…easily share builds to debug issues together?
OPTIMIZEBUILDPERFORMANCE
…easily understand where our build time is going and make our
builds faster?
COMPARE
…compare builds within our entire organization?
DISCOVER
…discover
how our software is actually being built within our entire
organization?
where our build time is going and make our builds faster?
INTRODUCINGGRADLEBUILDSCANS
Insights into your build
View and share via URL
Debug, optimize and re ne
Communicate via builds
Analyze all of your builds
GRADLEBUILDSCANS
Try Gradle build scans yourself! https://gradle.com/scans/get-
started
GRADLEINC
Motto: Build Happiness
Mission: To revolutionize the way software is built and shipped.
We’re Hiring: Gradle is hiring front-end, back-end, and core
software engineers. Visit to apply.gradle.org/jobs
THANKYOU!
LINKS
Android Gradle Plugin improvements:
Compiler improvements in Gradle:
Gradle Build Cache:
Gradle Build Scans :
Slides and code :
http://tools.android.com/tech
docs/new-build-system/2-5-alpha-gradle-plugin
https://blog.gradle.org/increment
compiler-avoidance
https://docs.gradle.org/nightly/userguide/userguide_single.html#buil
https://gradle.com
https://github.com/breskeby/talks/tree/master/010
codefest-novosibirsk/

Rene Groeschke