Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

What's new in Gradle 4.0

795 views

Published on

What the Gradle team have shipped since Gradle 3.0, featuring performance features like compile avoidance, user experience features like the Kotlin DSL, and brand new tools like the Java 9 support

Published in: Software
  • Be the first to comment

What's new in Gradle 4.0

  1. 1. What's new in Gradle 4.0 Eric Wendelin — JavaOne 2017
  2. 2. Eric Wendelin @eriwen
  3. 3. 3-minute Gradle Overview
  4. 4. From mobile apps to microservices, from small startups to big enterprises, Gradle helps teams build, automate and deliver beGer soHware, faster. Automate Everything Integrates with other tools like Docker for development or opera7ons. Integrates with and delegates to NPM, MSBuild, Ant, and other tools. Build Anything Support for Java, C/C++, Python, JavaScript, Go, and other languages. Go monorepo, mul7-repo, or anywhere in-between. Trusted by Millions Official build tool for Android 4M+ downloads per month #17 on BaOery OSS Index Gradle Overview
  5. 5. Languages built by Gradle 4% 7% 13% 21% 55% GITHUB PUBLIC SOURCE BYTES Java C JS/CSS/HTML C++ Groovy/Kotlin/Other #BigQuery hOps://git.io/vQfUx
  6. 6. Gradle Build Anatomy 3-phase build: IniKalizaKon → evaluate seNngs ConfiguraKon → build task graph ExecuKon → execute task graph Evaluate Gradle scripts Execute tasksBuild DAG
  7. 7. Incremental Builds TaskInputs Outputs UP-TO-DATE EXECUTE same contents ? same contents ?
  8. 8. Gradle 3.0 => Sep 19, 2016 Gradle 4.0 => Jun 14, 2017 Gradle 4.2.1 => Current Version Brief Gradle Version History
  9. 9. ‣ Incremental Compile ‣ Compile Avoidance ‣ Build Cache ‣ Parallelism Shipped since Gradle 3.0 Performance ✦ Buildship 2.0 ✦ Kotlin DSL ✦ Improved CLI ✦ Build Scans User Experience ❖ Java Library Plugin ❖ Java 9 Support ❖ NaKve Build Features ❖ Composite Builds New Tools
  10. 10. Shipped since Gradle 3.0 ‣ Incremental Compile ‣ Compile Avoidance ‣ Build Cache ‣ Parallelism Performance ✦ Buildship 2.0 ✦ Kotlin DSL ✦ Improved CLI ✦ Build Scans User Experience ❖ Java Library Plugin ❖ Java 9 Support ❖ NaKve Build Features ❖ Composite Builds New Tools
  11. 11. Incremental CompilaKon Performance
  12. 12. • Analyze class dependencies to opKmize
 which classes are recompiled • Fast in-memory cache of class ABIs inside daemon Incremental Compila7on for Java
  13. 13. Lorem ipsum Lorem ipsum Lorem ipsum Incremental Compila7on
  14. 14. Incremental Compila7on tasks.withType(JavaCompile) { options.incremental = true }
  15. 15. Recommended JavaOne Talk: Maximizing Incrementality with Gradle - Cedric Champeau at 12:15pm tomorrow [CON2992] Incremental Compila7on
  16. 16. Compile Avoidance Performance
  17. 17. Gradle recognizes ABI breaking changes, and will trigger recompilaKon only when ABI is changed. Compile Avoidance
  18. 18. Compile Avoidance Example Does MyApp need to be recompiled? No!
  19. 19. edub.me/compile-avoidance
  20. 20. Build Cache Performance
  21. 21. buildCache { local { enabled = !isCI } remote(HttpBuildCache) { url = "https://my.ge.server/cache/" push = isCI } } CI Remote Cache Local Cache Developer Build Cache
  22. 22. As of Gradle 4.2, Java and Scala toolchains are cacheable by default. We're working on leveraging this for all sensible tasks.
  23. 23. Self-hosted Build Scans Collect build history across all Gradle builds. Export build data; perform trend analysis and data-driven engineering effec7veness. gradle.com/build-scans Enterprise Build Cache Easy installa7on and maintenance tools for the Gradle Build Cache. Enjoy much faster builds by reusing task outputs across machines. gradle.com/build-cache Support and ConsulQng Get help migra7ng or upgrading Gradle. Expert build op7miza7on, saving 7me and improving developer happiness. gradle.org/services Gradle Enterprise Enterprise-grade Build Cache & Build Scans
  24. 24. gradle.com/build-cache
  25. 25. Parallelism Performance
  26. 26. Parallel Dependency Downloads
  27. 27. Worker API Without Worker API Using Worker API
  28. 28. edub.me/worker-api
  29. 29. Other Performance Improvements Performance
  30. 30. • Faster configuraKon • Faster gradle tasks • Faster archive processing • Faster daemon communicaKon • lots more... Performance Improvements
  31. 31. Gradle 4.2 is 2-100x faster than Gradle 3.0 when using all of the new performance features — upgrade! Summary
  32. 32. Shipped since Gradle 3.0 ‣ Incremental Compile ‣ Compile Avoidance ‣ Build Cache ‣ Parallelism Performance ✦ Buildship 2.0 ✦ Kotlin DSL ✦ Improved CLI ✦ Build Scans User Experience ❖ Java Library Plugin ❖ Java 9 Support ❖ NaKve Build Features ❖ Composite Builds New Tools
  33. 33. Java Library Plugin New Tools
  34. 34. compile: dependencies needed to compile
 runtime: dependencies needed to run project Java Library Plugin Not sufficient!
  35. 35. There are at least 2 kinds of Java projects: applicaQons (standalone, no API) 
 libraries (exposes an API) Java Library Plugin
  36. 36. // For Java Libraries that expose an API - apply plugin: "java" + apply plugin: "java-library" dependencies { - compile "org.apache.commons:commons-math3:3.6.1" - compile "com.google.guava:21.0" + api "org.apache.commons:commons-math3:3.6.1" + implementation "com.google.guava:21.0" }
  37. 37. edub.me/java-library-plugin
  38. 38. Java 9 Support New Tools
  39. 39. Gradle 4.2.1 provides runKme support for Java 9 applicaKons and libraries. It does not have first-class support for Java 9 modules yet. Java 9 Support
  40. 40. 1. Add module-info.java 2. Modify JavaCompile tasks to produce modules 3. Modify compile test tasks to patch modules 4. Modify Test tasks to consume patched modules Adop7ng Java 9 modules using Gradle
  41. 41. Using Java 9 modules with Gradle ext.moduleName = "org.gradle.actors" compileJava { inputs.property("moduleName", moduleName) doFirst { options.compilerArgs = ["--module-path", classpath.asPath] classpath = project.files() } }
  42. 42. Java 9 Support plugins { id "org.gradle.java.experimental-jigsaw" version "0.1.1" } DO NOT USE THIS PLUGIN IN PRODUCTION!
  43. 43. edub.me/gradle-java9
  44. 44. NaKve Build Features New Tools
  45. 45. • Parallel compilaKon and linking by default • VS2015 Support • Build Dependents Na7ve Build Features
  46. 46. Composite Builds New Tools
  47. 47. gradle myTask --include-build ../separate-project
  48. 48. | X Composite Builds • Combine independent Gradle builds • SubsKtute binary with project dependencies • Quick local experimentaKon • Cross-repository refactoring • Smooth migraKon from monolith to mulK-repo • Faster plugin prototyping
  49. 49. edub.me/composite-builds
  50. 50. Shipped since Gradle 3.0 ‣ Incremental Compile ‣ Compile Avoidance ‣ Build Cache ‣ Parallelism Performance ✦ Buildship 2.0 ✦ Kotlin DSL ✦ Improved CLI ✦ Build Scans User Experience ❖ Java Library Plugin ❖ Java 9 Support ❖ NaKve Build Features ❖ Composite Builds New Tools
  51. 51. Buildship 2.0 User Experience
  52. 52. • Composite Build support • Fresh new design • --offline mode support Buildship 2.0
  53. 53. Kotlin DSL User Experience
  54. 54. • Auto-compleKon and content assist • Quick documentaKon • NavigaKon to source • Refactoring and more Kotlin DSL
  55. 55. edub.me/kotlin-dsl-samples
  56. 56. Improved CLI User Experience
  57. 57. git.io/gradle-compleKon • CompleKon for tasks, flags, and common properKes • Available for bash and zsh • Kotlin build scripts support • ~20x faster than alternaKves for medium to large projects
  58. 58. Build Scans User Experience
  59. 59. • Persistent • Shareable • Customizable • Fast Build Scans
  60. 60. • Trend analysis • A/B tesKng (Build Comparison) • Flaky test detecKon • Engineering workflow opKmizaKon Pufng Build Scans Together
  61. 61. gradle.com/build-scans gradle myTask --scan
  62. 62. ‣ Incremental Compile ‣ Compile Avoidance ‣ Build Cache ‣ Parallelism Shipped since Gradle 3.0 Performance ✦ Buildship 2.0 ✦ Kotlin DSL ✦ Improved CLI ✦ Build Scans User Experience ❖ Java Library Plugin ❖ Java 9 Support ❖ NaKve Build Features ❖ Composite Builds New Tools
  63. 63. • gradle.org/guides — Get started using various technologies with Gradle • gradle.org/training — Monthly free online training with core engineers • gradle.com/enterprise — Build together; not alone Learn More
  64. 64. @eriwen
  65. 65. @gradle
  66. 66. w Thank You Eric Wendelin — @eriwen

×