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

Create your custom Gradle plugin - Droidcon 2014

Create your custom Gradle plugin - Droidcon 2014

Code sample: https://github.com/nhachicha/sample_gradle_plugin

Gradle is becoming more & more adopted by developers as their main build system especially after the release of Android Studio.
Thanks to the plugins architecture, Gradle allows users to reuse patterns and practices, avoiding boilerplate build code.

In this session, we will focus on creating a Plugin that cooperate with the existing "android plugin", in order to demonstrate some key concepts like: Tasks, Lifecycle, defining a custom DSL, incremental build and testing ...

we conclude by giving an overview of some useful Plugins that will boost your CI process.

Nabil Hachicha

September 22, 2014
Tweet

More Decks by Nabil Hachicha

Other Decks in Programming

Transcript

  1. About Me Works at The App Business London Open Source

    contributor snappydb.com @nhachicha @nabil_hachicha
  2. Motivation • Keeping the build simple & concise
 • Reduce

    boilerplate build code (no copy/paste)
 • Separation of concern How (Tasks) vs the What (configuration)
  3. Extra properties • User-defined variables • Ex: use it to

    disable or enable the plugin for a specific flavour
  4. Custom Task • Structure your code into classes & methods


    • Maintainability (any method is fully testable)
 • Reusability
  5. DSL • Task add new functionality (ability To Do Things

    - they are unit of works)
 • Extension add new build language elements To Talk about Things
  6. Incremental Build • Input haven't changed & Output is still

    there = Skip redundant work.
 
 but…
 • You need to tell gradle what's the Input & Output