Rock the Gradle, Rule the World

Rock the Gradle, Rule the World

Cf95f93e78f6d6dd0630049396f723c6?s=128

Xavier Gouchet

April 01, 2019
Tweet

Transcript

  1. Rock the Gradle Rule the world

  2. About… Lead Android Engineer at WorkWell Fluent in Android since

    Cupcake 2
  3. A brief introduction 1

  4. Dependency Management System What is Gradle General Purpose Build management

    4
  5. 5 General purpose Language agnostic Feature agnostic

  6. 6 Dependency management system Knows how to graph and resolve

    dependencies ◇ code ◇ tasks ◇ …
  7. 7 Build management Based on tasks created by plugins

  8. Configuration Gradle flow Initialisation Execution 8

  9. 9 Initialisation Launches the JVM (with proper params) Analyse the

    working directory Reads the settings.gradle file Creates the Project object(s) that will be used Compiles, test and add buildSrc to the classpath
  10. 10 Configuration Execute all the build.gradle scripts in the project

    Create all the Task objects and configure the Project object(s) Resolves the tasks dependencies
  11. 11 Execution List the Task to run based on the

    invocation (and their dependencies) Execute each of the tasks
  12. Meet the buildSrc folder 2

  13. Project structure ┬ MyProject ├┬ app/ │├── src/ │└── build.gradle

    ├┬ buildSrc/ │├── src/ │├── build.gradle │└── settings.gradle ├─ build.gradle └─ settings.gradle 13
  14. Purposes… ◇ Better dependency management ◇ Helper classes / methods

    ◇ Custom tasks in dedicated classes ◇ Custom plugin ■ Locally versionned with the project 14
  15. How does it work? ◇ Works like any module in

    your project ◇ Compiled and tested before any gradle task ◇ Groovy, Java, Kotlin, … ◇ Any public class / method becomes availble in gradle scripts 15
  16. “ A change in buildSrc causes the whole project to

    become out-of-date. 16
  17. apply plugin: 'groovy' dependencies { compile gradleApi() compile localGroovy() }

    17 Default build.gradle
  18. Writin a Plugin 3

  19. Hands On 19

  20. Thanks! Any questions? ◇ https://github.com/xgouchet/RockTheGradle ◇ @xgouchet 20