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

Improving developer productivity with Gradle Enterprise in 2023

Improving developer productivity with Gradle Enterprise in 2023

This year has been quite an exciting year for Gradle Enterprise features and Gradle Enterprise customers. With Julio representing the Gradle Enterprise Developer Platform Team and Nelson representing the Solutions team and Gradle Enterprise customers, we’ll cover a broad range of developer productivity tips and topics.

We will start by discussing some of the common Gradle issues facing Android developers. We’ll cover some build cache misses and configuration cache issues as well as how to debug them and solve them. After that we’ll dive into the newly released Gradle Enterprise feature most commonly requested Android devs: Artifact Transforms in Build Scans. Then we’ll wrap it up by previewing some upcoming Gradle Enterprise APIs and how to use them in your day to day workflow.

Júlio Zynger

July 07, 2023
Tweet

More Decks by Júlio Zynger

Other Decks in Technology

Transcript

  1. Julio • Previously Android Engineer • Large projects • SoundCloud,

    Autodesk • Developer Produc ti vity Enthusiast • Leading Gradle’s (and previously SoundCloud’s) interdisciplinary Pla tf orm teams • Backstage contributor https://github.com/backstage/backstage Lead Dev Platform Engineer
  2. Nelson • Previously Android Engineer • Large projects • SoundCloud

    • Square • Small startups • Gradle Plugin Maintainer • Fladle - Easily Scale Instrumenta ti on Tests on Firebase https://github.com/runningcode/ fl adle • Gradle Doctor - Ac ti onable Insights for your build https://github.com/runningcode/gradle-doctor Lead Solutions Engineer
  3. We see a lot of builds from 10 person teams

    to 1000+ Android, Gradle and Maven
  4. Cost of Builds 60s waste * 50 builds / day

    * 50 devs 
 = 42 hours lost / day
  5. Cost of Builds 60s waste * 50 builds / day

    * 50 devs 
 = 42 hours lost / day not including lost focus h tt ps:/ /gradle.com/roi-calculator
  6. Cost of Builds 60s waste * 50 builds / day

    * 50 devs 
 = 42 hours lost / day hire 5 new people without paying them! no recruiting h tt ps:/ /gradle.com/roi-calculator
  7. Slow builds are Tech Debt And it always pays off

    And is easy to justify working on it
  8. What is a cache miss? •Expect a cache hit but

    cache key is di ff erent •Task outcome is the same •Only inputs that a ff ect outcome should be tracked
  9. Build Configuration Differences kotlin.incremental=true kotlin.incremental=true CI Local Incremental has no

    effect on outcome of task h tt ps:/ /youtrack.jetbrains.com/issue/KT-40974/isIncrementalCompila ti onEnabled-should-not-be-marked-as-Input
  10. •LiveLiterals$AnalyticsEvent.kt contains fully qualified path •Fix is to disable LiveLiterals

    composeOptions { useLiveLiterals = false } LiveLiterals https://issuetracker.google.com/issues/233716574
  11. KSP Cache misses build.gradle.kts class RoomSchemaArgProvider( @get:InputDirectory @get:PathSensitive(PathSensitivity.RELATIVE) val schemaDir:

    File, ) : CommandLineArgumentProvider { override fun asArguments() = listOf("room.schemaLocation=${schemaDir.path}") } extensions.configure<KspExtension> { arg(RoomSchemaArgProvider(File(projectDir, "schemas"))) } h tt ps:/ /developer.android.com/training/data-storage/room/migra ti ng-db-versions#test
  12. KSP Cache misses build.gradle.kts class RoomSchemaArgProvider( @get:InputDirectory @get:PathSensitive(PathSensitivity.RELATIVE) val schemaDir:

    File, ) : CommandLineArgumentProvider { override fun asArguments() = listOf("room.schemaLocation=${schemaDir.path}") } extensions.configure<KspExtension> { arg(RoomSchemaArgProvider(File(projectDir, "schemas"))) } h tt ps:/ /developer.android.com/training/data-storage/room/migra ti ng-db-versions#test
  13. KSP Cache misses build.gradle.kts class RoomSchemaArgProvider( @get:InputDirectory @get:PathSensitive(PathSensitivity.RELATIVE) val schemaDir:

    File, ) : CommandLineArgumentProvider { override fun asArguments() = listOf("room.schemaLocation=${schemaDir.path}") } extensions.configure<KspExtension> { arg(RoomSchemaArgProvider(File(projectDir, "schemas"))) } h tt ps:/ /developer.android.com/training/data-storage/room/migra ti ng-db-versions#test
  14. KSP Cache misses build.gradle.kts class RoomSchemaArgProvider( @get:InputDirectory @get:PathSensitive(PathSensitivity.RELATIVE) val schemaDir:

    File, ) : CommandLineArgumentProvider { override fun asArguments() = listOf("room.schemaLocation=${schemaDir.path}") } extensions.configure<KspExtension> { arg(RoomSchemaArgProvider(File(projectDir, "schemas"))) } h tt ps:/ /developer.android.com/training/data-storage/room/migra ti ng-db-versions#test
  15. KSP Cache misses build.gradle.kts class RoomSchemaArgProvider( @get:InputDirectory @get:PathSensitive(PathSensitivity.RELATIVE) val schemaDir:

    File, ) : CommandLineArgumentProvider { override fun asArguments() = listOf("room.schemaLocation=${schemaDir.path}") }
  16. KSP Cache misses build.gradle.kts class RoomSchemaArgProvider( @get:InputDirectory @get:PathSensitive(PathSensitivity.RELATIVE) val schemaDir:

    File, ) : CommandLineArgumentProvider { override fun asArguments() = listOf("room.schemaLocation=${schemaDir.path}") }
  17. KSP Cache misses KspSubplugin.kt commandLineArgumentProviders.get().forEach { it.asArguments().forEach { argument ->

    options += InternalSubpluginOption("apoption", argument) } } To be released…
  18. Configuration cache misses Calculating task graph as configuration cache cannot

    be reused because an input to plugin 'com.android.internal.library' has changed. • How to debug? • Check con fi gura ti on cache report?
  19. Configuration cache misses 1. A tt ach Debugger to Gradle

    Build Process 1../gradlew help -Dorg.gradle.debug=true 2. Set breakpoint in ConfigurationCacheFingerprintWriter and ConfigurationCacheFingerprintChecker 3. Print fi les which are changing build/generated/source/kapt/debug read at con fi gura ti on ti me
  20. Con fi gura ti on inputs detec ti on improvements

    Now detects FileCollec ti ons queried at con fi gura ti on ti me h tt ps:/ /docs.gradle.org/8.1/release-notes.html#con fi gura ti on-inputs-detec ti on-improvements Why only in Gradle 8.1?
  21. Why only in Gradle 8.1? h tt ps:/ /youtrack.jetbrains.com/issue/KT-58167/Applying-KAPT-plugin-to-Gradle-8.1-causes-con fi

    gura ti on-cache-miss Using KAPT Gradle plugin with AGP and Gradle 8.1 or higher causes a con fi gura ti on cache miss h tt ps:/ /issuetracker.google.com/issues/285320724 Lint inputs and registerExternalAptJavaOutput are incompa ti ble with Gradle Con fi gura ti on cache Will be fi xed in AGP 8.1.1 and AGP 8.2🤞
  22. Retrieve test suites and test case details, filtering by: -

    test container (e.g test suite, etc) - test outcome (success, failed, flaky etc) - tags - custom values - much more and a combination of all! Gradle Enterprise Test API BETA
  23. Gradle Enterprise Test API BETA What is a fl aky

    test according to Gradle Enterprise? • Non-determinis ti c outcome • Fails and succeeds within the execu ti on of a single Gradle task W
  24. Cross reference with your CI infrastructure… Exposed in API De

    fi ne how fl akiness compares across CI jobs, infrastructure and target matrix
  25. Reach out to us after the talk for access to

    Gradle Enterprise Test API 🥳 BETA
  26. Reach out to us after the talk for Importing Instrumentation

    Test Results to Gradle Enterprise BETA
  27. What are artifact transforms? • Dependency management concept • Changes

    dependency from incorrect format to requested format via Ar ti fact Transforms • Example: classes jar to dex fi le • Users do not directly request transforms • Gradle schedules Transforms between units of work • Transforms can depend on tasks or transforms
  28. Artifact transforms are now visible in Build Scans! 🥳 Must

    use: Gradle Enterprise 2023.1+, Gradle Enterprise Gradle Plugin 3.13+, Gradle Build Tool 8.1+ 
 Only visualizes project ar ti fact transforma ti ons
  29. Why are transforms important in Build Scans? • Understand transform

    dependencies • Understand gaps in ti meline • Understanding ar ti fact transform errors
  30. Artifact transforms upcoming work • Understand transform cacheability and up-to-date

    checks • Improved transform fi lter in ti meline • Support more transform types (je ti fi er transforms are not visible)
  31. Thank you! Gradle Enterprise Trial osacky.com h tt ps:/ /gradle.com/enterprise/trial/

    https:/ /gradle.com/careers/ Gradle is hiring @nellyspageli @juliozynger