Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Gradle – Build Happiness (German)
Search
Marc Philipp
January 28, 2019
Programming
1
180
Gradle – Build Happiness (German)
Introduction to the Gradle Build Tool, Build Scans and the Build Cache
Marc Philipp
January 28, 2019
Tweet
Share
More Decks by Marc Philipp
See All by Marc Philipp
Catching up with JUnit
marcphilipp
0
72
Catching up with JUnit 5
marcphilipp
1
97
The JUnit Crew Presents What's New
marcphilipp
2
40
Behind the scenes of JUnit 5 – running an independent open source project by example
marcphilipp
0
65
Running an independent open source project by example
marcphilipp
1
51
Automatisierte Tests mit Machine Learning und verteilter Ausführung beschleunigen
marcphilipp
1
220
Meet the JUnit Team in Person!
marcphilipp
1
140
JUnit 5 wird 5 (JUG Frankfurt)
marcphilipp
0
120
Speeding up tests with machine learning and distributed execution
marcphilipp
0
98
Other Decks in Programming
See All in Programming
“いい感じ“な定量評価を求めて - Four Keysとアウトカムの間の探求 -
nealle
2
11k
TypeScriptでDXを上げろ! Hono編
yusukebe
3
730
型で語るカタ
irof
0
640
Google Agent Development Kit でLINE Botを作ってみた
ymd65536
2
260
テスト駆動Kaggle
isax1015
1
520
The Evolution of Enterprise Java with Jakarta EE 11 and Beyond
ivargrimstad
0
210
マッチングアプリにおけるフリックUIで苦労したこと
yuheiito
0
130
テストから始めるAgentic Coding 〜Claude Codeと共に行うTDD〜 / Agentic Coding starts with testing
rkaga
15
5.5k
#QiitaBash MCPのセキュリティ
ryosukedtomita
1
1.5k
NPOでのDevinの活用
codeforeveryone
0
880
はじめてのWeb API体験 ー 飲食店検索アプリを作ろうー
akinko_0915
0
140
VS Code Update for GitHub Copilot
74th
2
670
Featured
See All Featured
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.8k
How to train your dragon (web standard)
notwaldorf
96
6.1k
Reflections from 52 weeks, 52 projects
jeffersonlam
351
21k
Designing Experiences People Love
moore
142
24k
GraphQLとの向き合い方2022年版
quramy
49
14k
Docker and Python
trallard
45
3.5k
What's in a price? How to price your products and services
michaelherold
246
12k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
The Cult of Friendly URLs
andyhume
79
6.5k
Transcript
GRADLE – BUILD HAPPINESS MARC PHILIPP, GRADLE INC.
MARC PHILIPP So ware Engineer bei Gradle, Inc. JUnit Maintainer
seit 2012 Twi er: Web: @marcphilipp marcphilipp.de
✋ SHOW OF HANDS
WAS IST GRADLE?
WAS IST GRADLE? Basiert auf der Java Virtual Machine (JVM)
Implemen ert in Java 100% Open Source (Apache 2.0) und kostenlos Gradle ist ein Build‑ und Automa sierungswerkzeug.
VIELSEITIG EINSETZBAR Java‑Ökosystem: Java, Groovy, Kotlin, Scala, … Na ve
Projekte: C, C++, Swi , … Android Sons ges: Go, Asciidoctor, …
GRADLE IN ZAHLEN Mehr als 7M Downloads/Monat OSS‑Projekt #17 weltweit
35+ Gradle Engineers 300K Builds/Woche @ LinkedIn
GRADLE INC. Vision: Build Happiness Mission: Accelerate Developer Produc vity
Produkte: Build Scans and Enterprise Build Cache [Consul ng, Support, Development Services etc.] [Training: online, öffentlich und in‑house]
AGENDA Kurze Einführung in Gradle Gradle Plugins Inkrementelle Builds Build
Scans Build Cache
KURZE EINFÜHRUNG IN GRADLE
HELLO WORLD tasks.register("helloWorld") { // in build.gradle doLast { println("Hello
World!") } } $ gradle helloWorld > Task :helloWorld Hello World! BUILD SUCCESSFUL in 0s 1 actionable task: 1 executed
TASKS Ein Gradle‑Build führt einen/mehrere Tasks aus. Tasks können von
anderen Tasks abhängen. Tasks haben Inputs und Outputs.
BUILDSCRIPTS Ein Gradle‑Projekt wird mi els Buildscripts konfiguriert: settings.gradle[.kts] :
Konfiguriert, welche Subprojekte Teile des Builds sind. build.gradle[.kts] : Konfiguriert Plugins und Tasks, die im Build verwendet werden.
GRADLE WRAPPER ./gradlew <tasks> sta gradle <tasks> Ermöglicht Ausführung des
Builds ohne vorherige Installa on von Gradle: Lädt ggfs. die benö gte Version herunter. Entwickler und Build‑Server verwenden immer diesselbe Version.
DATEISTRUKTUR $ gradle init --dsl=kotlin --type=java-application \ --test-framework=junit --package=com.example \
--project-name=new-project BUILD SUCCESSFUL in 0s 2 actionable tasks: 2 executed ├── build.gradle.kts // Buildscript ├── gradle/wrapper // Wrapper JAR und Konfiguration ├── gradlew // Wrapper script für Linux/macOS ├── gradlew.bat // Wrapper script für Windows ├── settings.gradle.kts // Settings └── src // Java source tree ├── main │ ├── java │ └── resources └── test ├── java └── resources
SETTINGS.GRADLE.KTS rootProject.name = "new-project"
BUILD.GRADLE.KTS plugins { java // zum Kompilieren von Java-Quellcode application
// zum Generieren von Startup-Scripts } repositories { jcenter() // zum Auffinden von Dependencies } dependencies { implementation("com.google.guava:guava:26.0-jre") testImplementation("junit:junit:4.12") } application { // Extension des 'application'-Plugins mainClassName = "com.example.App" }
GROOVY VS. KOTLIN DSL Buildscript verwenden eine Domain‑Specific‑ Language (DSL).
Ursprünglich wurde dazu Groovy verwendet. Groovy: Dynamisch typisiert, IDE‑Support schwierig Seit Gradle 5.0 gibt es eine stabile DSL in Kotlin.
GRADLE PLUGINS
PLUGINS Definieren Tasks, z.B. compileJava Stellen Möglichkeiten zur Konfigura on
bereit, z.B. die application ‑Extension Wenden andere Plugins an plugins { java // zum Kompilieren von Java-Quellcode application // zum Generieren von Startup-Scripts }
EIGENE PLUGINS Ziel: Vereinheitlichung der Build‑Logik über Projekt‑ Grenzen hinweg
plugins { id("com.example.myplugin") version "1.0" } public class MyPlugin implements Plugin<Project> { @Override public void apply(Project project) { project.getPluginManager().apply(JavaPlugin.class); project.getTasks().register("myTask", task -> ...); // ... } }
PLUGIN PORTAL Über 3000 Community‑Plugins
INKREMENTELLE BUILDS
INKREMENTELLE BUILDS Führe nur Tasks aus, die von Änderungen zwischen
zwei Builds betroffen sind. Behalte die Ergebnisdateien aller Tasks die up‑to‑ date sind.
ERSTER BUILD $ ./gradlew --console=plain build > Task :compileJava >
Task :processResources NO-SOURCE > Task :classes > Task :jar [...] > Task :compileTestJava > Task :testClasses > Task :test > Task :check > Task :build BUILD SUCCESSFUL in 5s 7 actionable tasks: 7 executed
INKREMENTELLER BUILD $ ./gradlew --console=plain build > Task :compileJava UP-TO-DATE
> Task :processResources NO-SOURCE > Task :classes UP-TO-DATE > Task :jar UP-TO-DATE [...] > Task :compileTestJava UP-TO-DATE > Task :testClasses UP-TO-DATE > Task :test UP-TO-DATE > Task :check UP-TO-DATE > Task :build UP-TO-DATE BUILD SUCCESSFUL in 0s 7 actionable tasks: 7 up-to-date
WENN WIR ZEIT HÄTTEN… Compile avoidance & incremental compiler Gradle
Daemon Con nuous Builds Composite Builds Tooling API / IDE integra on Worker API
BUILD SCANS
BUILD SCAN: AKTIVIERUNG › $ ./gradlew build --scan BUILD SUCCESSFUL
in 1s 7 actionable tasks: 5 executed, 2 up-to-date Publishing build scan... https://gradle.com/s/lu7dxy7quyoju h ps:/ /gradle.com/s/lu7dxy7quyoju
BUILD SCAN: TIMELINE
BUILD SCAN: DEPENDENCIES
BUILD SCANS (KOSTENLOS) Beschleunigen die Lösung von Build‑Problemen Einfach mit
Kollegen teilbarer Link Kostenlose Nutzung auf scans.gradle.com
ENTERPRISE BUILD SCANS Gradle Enterprise bietet zusätzliche Features: Hos ng
auf eigenem Server Vergleich zweier Build Scans Entwicklung von Build‑Metriken über die Zeit
BUILDS ÜBER DIE ZEIT
VERGLEICH ZWEIER BUILDS
BUILD CACHE
MORGENS HALB 10 IN DEUTSCHLAND… Give every developer back one
hour a day! $ git pull [...] 185 files changed, 4320 insertions(+), 1755 deletions(-) $ ./gradlew --build-cache sanityCheck BUILD SUCCESSFUL in 1m 11s 1338 actionable tasks: 238 executed, 1100 from cache
BUILD CACHE Verwende Ergebnisse aller vorherigen Builds
INPUTS → TASK → OUTPUTS Berechne cacheKey eines Tasks aus
dessen Inputs: cacheKey(javaCompile) = hash(sourceFiles, …) Verwende Ergebnisdateien als cacheEntry: cacheEntry(javaCompile) = fileTree(classFiles)
REMOTE BUILD CACHE
LOKAL UND REMOTE CI‑Server speichern Task‑Ergebnisse im Remote Build Cache
Lokale Builds verwenden Ergebnisse aus dem Remote Build Cache Ergebnisse werden für zukün ige Builds im lokalen Build Cache gespeichert
GRADLE ENTERPRISE
NEU: JETZT AUCH FÜR APACHE MAVEN™ › 0:00 / 0:34
h ps:/ /gradle.com/blog/maven/
GRADLE ENTERPRISE KUNDEN › gradle.com
Q & A