Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Fast and reliable builds with Gradle and Maven

Fast and reliable builds with Gradle and Maven

Having fast and reliable builds has a major influence on developer productivity. Faster builds make feedback cycles shorter by reducing wait times and context switches for developers. If a build is unreliable, developers may re-run the same build over and over again and when that fails, run a clean build and/or clear all the caches. Doing so removes many of the performance optimizations of the build tool, forcing every step of the build to be recomputed which takes much longer than an incremental build.

In this session, we will show you how Gradle Enterprise can be used for both Gradle and Maven to make builds faster and more reliable through build caching and build scans, respectively. The build cache, very different from the m2 cache, stores the outputs of each step of the build on a remote server. These cached outputs can then be used by both developer and CI builds. We’ll also dive into ways to increase the speed and reliability of each step of the build using build scans. Build scans provide insights into where bottlenecks occur and provide the data to optimize problems specific to your build.

Marc Philipp

April 26, 2019
Tweet

More Decks by Marc Philipp

Other Decks in Programming

Transcript

  1. About me speaker { name = "Marc Philipp" home =

    "Karlsruhe, Germany" company = "Gradle Inc." title = "Senior Software Engineer" openSourceRoles = [ "JUnit team lead" ] twitter = "@marcphilipp" github = "marcphilipp" web = uri("https://www.marcphilipp.de") } 2 . 1
  2. How do builds affect developer produc vity? failures: about 20%

    of builds fail due to code defects 5‑10% of a team’s capacity is spent on fixing slowness: a team’s capacity is reduced by 4% for each extra minute of build me unreliability: 5% of a team’s capacity goes into debugging build problems 2 . 3
  3. Incremental builds Gradle can reuse results of the last me

    this build ran on this machine. 3 . 4
  4. Build Cache for Gradle $> gradle ­­build­cache assemble :compileJava FROM­CACHE

    :processResources :classes :jar :assemble BUILD SUCCESSFUL 3 . 9
  5. Build Cache for Gradle out‑of‑the‑box for Java, Groovy, Scala, C++

    and Swi projects supports compile, test and verifica on tasks high‑performance remote backend from Gradle Docker Hub: gradle/build‑cache‑node 3 . 10
  6. Build Cache for Maven custom extension (part of Gradle Enterprise)

    ini al release: March 2019 supported plugins: Java Compiler, Surefire/Failsafe, Javadoc, JAXB, Checkstyle 3 . 11
  7. How does it work? Calculate cacheKey of a task/goal from

    its inputs: cacheKey(javaCompile) = hash(sourceFiles, … ) Store its outputs under cacheEntry: cacheEntry(javaCompile) = fileTree(classFiles) Gradle task Inputs Outputs 3 . 13
  8. What are Build Scans? persistent record of what happened during

    a build permanent and shareable URL for developers and build engineers 4 . 3
  9. Gradle $> gradle build ­­scan ... BUILD SUCCESSFUL in 8m

    22s 418 actionable tasks: 112 executed, 48 from cache, 258 up­ Publishing build scan... https://scans.gradle.com/s/lbmn7n4dngqgq 4 . 4
  10. Maven (with extension registered in .mvn/extensions.xml) $> mvn clean verify

    ... [INFO] ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­ [INFO] BUILD SUCCESS [INFO] ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­ [INFO] Total time: 5.262 s [INFO] Finished at: 2019­04­23T09:55:36+02:00 [INFO] ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­ [INFO] 13 goals, 8 executed, 5 from cache, saving at least [INFO] [INFO] Publishing build scan... [INFO] https://gradle.com/s/ypgljbvelzxzs [INFO] 4 . 5
  11. Build Scans support Gradle and Maven public scans are free

    on without build comparison, performance dashboard etc. Gradle Enterprise provides addi onal features and on‑premise hos ng scans.gradle.com h ps:/ /scans.gradle.com/s/nq7w6cjm72mak/ 4 . 7
  12. Resources Free trainings on , e.g. Build Cache Deep Dive

    Maven + Gradle Enterprise Gradle Build Tool: Gradle Enterprise: h ps:/ /gradle.com/training/ YouTube channel h ps:/ /gradle.org h ps:/ /gradle.com 5 . 1
  13. Дякую! See you tomorrow? 5 From Revolu on to Con

    nuous Evolu on Tomorrow, 16:10, Track C News from JUnit 5.x 5 . 2