top of page

Gradle basics

Actualizado: 26 mar 2019


Welcome to the gradle course. This course will cover:


- The fundamentals of gradle

- How to create Gradle tasks and patterns(reusable tasks)

- How to attach tasks to your build

- How to filter files

- How to change file contents with gradle

Gradle provides a very complete manual that you can visit here:


Gradle is an opensource tool created to automate the building process of multiprojects solutions, the main focus is on Java and Scala, and used DSL syntax based on groovy language.


As interest of this tutorial we are going to create a build script for a 2 module project:

- app

- api




ree
project +api

For this setup, the following gradle files were generated


|

| -> Project:tutorialsApp

| -----> build.gradle

| -----> gradle.properties

| -----> settings.gradle


| -> Module:app

| -----> build.gradle


| -> Module:tutorialsApp

| -----> build.gradle



The following link has a very complete explanation on the parameters of the build.gradle


settings.gradle

- Include modules

include ':app', ':tutorialsapi'


build.gradle

- module - level


apply plugin: 'com.android.application' // plugin: configures the build for an android application android { // platform block compileSdkVersion 28 // Defines the api the app will be compiled with

defaultConfig { // defines parameters for all the build configurations applicationId "com.sati.tutorialsapp" // unique app identifier, used in google-store

minSdkVersion 23 // Lower level api, app won't be available in google app store for // devices with a lower sdk

targetSdkVersion 28 // api level the app is tested - targetSdkVersion = compileSdkVersion versionCode 1 //numeric App version versionName "1.0" // App version - String

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { //Build Configuration block release { //Release Configuration Block minifyEnabled false // if true shrinks code proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

//proguard file } } } dependencies { //Dependencies block implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' }




Comentarios


© 2018 by Alejandro Prieto

  • Facebook Social Icon
  • Twitter Social Icon
  • Google+ Social Icon
bottom of page