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

Gradle build: The time is now

Gradle build: The time is now

Alexey Bykov

January 25, 2023
Tweet

More Decks by Alexey Bykov

Other Decks in Programming

Transcript

  1. 7 Such sample not applies to Reddit or any other

    company I may worked at Build time. Why? ~ 10 engineers ~ 12 m ~ 20 builds (daily)
  2. 8 Such sample not applies to Reddit or any other

    company I may worked at Build time. Why? ~ 1000 builds ~ 200 h Weekly ~ 10 engineers ~ 12 m ~ 20 builds (daily)
  3. 14 Build Sequence of steps to transform 
 source code

    to a final product Step Step Step binary Src
  4. 28 BUILD SUCCESSFUL in 6m 49s 7960 actionable tasks: 130

    executed, 371 from cache, 7459 up-to-date Tasks labels
  5. 29 BUILD SUCCESSFUL in 6m 49s 7960 actionable tasks: 130

    executed, 371 from cache, 7459 up-to-date Tasks labels
  6. 37 Project — Main Gradle API — Set of the

    tasks — 1 to 1 dependency with build.gradle
  7. 40 Plugins — Configuration of settings and tasks — Example:

    * Android Gradle Plugin (AGP) * Kotlin Gradle Plugin (KGP)
  8. Caching Gradle 
 Daemon JVM process * Long-running process *

    Enabled by default * Not stable on the CI
  9. Caching Gradle 
 Daemon JVM process * Long-running process *

    Enabled by default * Not stable on the CI org.gradle.daemon=false #gradle.properties
  10. Caching Incremental 
 cache * Short-term cache * Can be

    easily invalidated * Stores in build folders
  11. Caching In memory In project Gradle 
 Daemon JVM process

    Configuration 
 cache Incremental 
 cache
  12. Caching Local In memory In project Out project Gradle 


    Daemon JVM process Configuration 
 cache Incremental 
 cache Build 
 cache
  13. Caching In memory In project Out project Gradle 
 Daemon

    JVM process Configuration 
 cache Incremental 
 cache Build 
 cache Dependency 
 cache
  14. Caching Local In memory In project Out project Gradle 


    Daemon JVM process Configuration 
 cache Incremental 
 cache Build 
 cache Dependency 
 cache
  15. Caching Local In memory In project Out project Gradle 


    Daemon JVM process Configuration 
 cache Incremental 
 cache Build 
 cache Dependency 
 cache Remote
  16. Caching Local In memory In project Out project Gradle 


    Daemon JVM process Configuration 
 cache Incremental 
 cache Build 
 cache Dependency 
 cache Build 
 cache Remote
  17. Caching Local In memory In project Out project Gradle 


    Daemon JVM process Configuration 
 cache Incremental 
 cache Build 
 cache Dependency 
 cache Build 
 cache Remote
  18. Caching Local In memory In project Out project Gradle 


    Daemon JVM process Configuration 
 cache Incremental 
 cache Build 
 cache Dependency 
 cache Build 
 cache Proxy Remote
  19. Caching Local In memory In project Out project Gradle 


    Daemon JVM process Configuration 
 cache Incremental 
 cache Build 
 cache Dependency 
 cache Build 
 cache Proxy Remote
  20. 101 Properties File to easily configure Gradle Can be: ~./gradle.properties

    Project/gradle.properties Gradle merge them Global > Local
  21. 103

  22. 115 1. Locally ~ daily, on a laptop ~ incremental

    build ~ incremental changes ~ clean build
  23. 116 1. Locally ~ daily, on a laptop ~ incremental

    build ~ incremental changes ~ clean build ~ configuration
  24. 117 1. Locally ~ daily, on a laptop ~ incremental

    build ~ incremental changes ~ clean build ~ no external monitor ~ configuration
  25. 118 1. Locally ~ daily, on a laptop ~ incremental

    build ~ incremental changes ~ clean build ~ no external monitor ~ no android studio ~ configuration
  26. 119 1. Locally ~ daily, on a laptop ~ incremental

    build ~ incremental changes ~ clean build ~ no external monitor ~ no android studio ~ cli ~ configuration
  27. 122 Collect automatically ~ Only if you have > 20

    engineers ~ Tool: Talailot https://github.com/cdsap/Talaiot
  28. 132 Scenario #build cache clean_no_op { tasks = ["clean", "assembleDebug"]

    } no_op { tasks = [“assembleDebug"] } #incremental
  29. 133 Scenario #build cache clean_no_op { tasks = ["clean", "assembleDebug"]

    } no_op { tasks = [“assembleDebug"] } #incremental incremental_changes { tasks = ["assembleDebug"] apply-abi-change-to = “sample/src/main/…TeamsViewModel.kt” }
  30. 134 Scenario no_op { tasks = [“assembleDebug"] } clean_no_op {

    tasks = ["clean", "assembleDebug"] } incremental_changes { tasks = ["assembleDebug"] apply-abi-change-to = "sample/src/main/java/com/alexbykov/oknetwork/data/TeamsViewModel.kt" } #incremental #build cache #incremental changes
  31. 147 Google sheet + Forms ~ Link sheet with forms

    ~ Know form ids and send shorturl.at/mzNOY
  32. 156 Content merging app feature1 Feature3 feature2 R class (app,

    f1,f2,f3) R class (f2, f3) R class (f2, f3) R class (f1)
  33. 171 Version Catalog [libraries] groovy-core = { module = "org.codehaus.groovy:groovy",

    version.ref = "groovy" } groovy-json = { module = "org.codehaus.groovy:groovy-json", version.ref = "groovy" } [versions] groovy = "3.0.5" checkstyle = "8.37"
  34. 179 Java version ~ Have Java 8? —> Java 11

    ~ Have Java 11 —> A/B tests & experiments
  35. 181 Tune gradle properties ~ Always do A/B tests with

    GC -XX:+UseParallelGC -XX:+UseG1GC (default)
  36. 182 Tune gradle properties ~ Always do A/B tests with

    GC ~ A/B tests with heap size org.gradle.jvmargs=-Xmx..G kotlin.daemon.jvmargs=-Xmx..g
  37. 183 Tune gradle properties ~ Always do A/B tests with

    GC ~ A/B tests with heap size ~ Choose proper one for you 1. Kotlin daemon > Gradle Daemon 2. Kotlin daemon < Gradle Daemon 3. Kotlin daemon == Gradle Daemon
  38. 213 Other ~ Extract native to libraries ~ Don’t use

    flavors and build variants ~ Always test an impact before merging ~ Use latest tools ~ Keep things under control