android presentation - gradle ++

Download Android presentation - Gradle ++

Post on 12-Apr-2017

90 views

Category:

Software

5 download

Embed Size (px)

TRANSCRIPT

Gradle

What is this?General purpose build system made in groovy that allows you to execute the needed commands to build software.

Manages:Build processDependenciesProject files

What is this?Similar products:AntMavenGantIvyRakeBuildr...

What is this?Big winIt is a full language itself, not a configuration file.

Gradle just provides a lifecycle and some classes to help you

2. How it works?Manages with some classes:Build processDependenciesProject filesUSING

TasksProjectsRepositoriesDependencies

Key concepts:BuildScriptProjectRepositoriesTasksPlugin2. How it works?

BuildScript2. How it works?Setup script to add dependencies on the building process. Ex. plugin dependencies

Project2. How it works?Element that represents the current project and is considered the top level item. Contains all the important information, plugins, files and source directories.

Repositories2. How it works?Defines which are the sources of the possible dependencies. Ex. MavenCentral, jCenter (bintray)

Tasks2. How it works?Pieces of code that are able to perform some action defined. Tasks can be dependent from each other and they can receive actions before or after.

Plugins2. How it works?Programs that evaluates during the build process and are able to add behaviour and tasks to the current project.

DSL based on Groovy but...You can do whatever you can do in the Groovy languageUse the DSL to make it look like a configuration file3. DSL Syntax

ClassDSL

3. DSL Syntax

ClassDSL

3. DSL Syntax

ClassDSL

3. DSL Syntax

4. Build process lifecycleCompile build in .gradle cacheExecute buildscriptFirst round to configure dependencies and source directoriesafterEvaluate execution to generate tasks based on first stepExecute whatever task you want

5. TaskDeclare a task

5. TaskAdd dependency between tasks

5. Tasktaks.doFirsttask.doLast (item.res.srcDirs = ['res_prod'] }

Flavours to the infinityThe examples before were using 1 flavor to define free/paid and one for buildType.You can define as much as you want: flavorDimensions 'apptype', 'environment','mpayments'This allows you combinations of:apptype+environment+mpayments+buildType. BuildType is always the last.The more flavorDimensions you have, the more number of variants you will be able to create.