• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Gradle
 

Gradle

on

  • 1,190 views

Introduction to build automation tool Gradle.

Introduction to build automation tool Gradle.

Statistics

Views

Total Views
1,190
Views on SlideShare
1,190
Embed Views
0

Actions

Likes
1
Downloads
47
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Gradle Gradle Presentation Transcript

    • Gradle v.1.0 Andrii Khaisin Provectus IT 27.07.2013
    • About me Senior Software Developer at Provectus IT for Men's Wearhouse
    • Gradle in a few words • Gradle is task oriented build tool. • Gradle has a set of default plugins which define conventions and standard life cycle of project build. • Gradle build scripts are Groovy scripts which customize default workflow for your needs. • Gradle works well for Java projects and for non Java projects as well.
    • What we need from a build tool • Ability to create and support build scripts • Ability to define projects hierarchy for multi module build • Ability to manage project dependencies • Ability to implement custom build logic • Ability to extend available plugins • Ability to develop new own plugins • Ability to support build configurations
    • Lets some practice • Projects structure • Build running • Groovy is everywhere • Tasks • Plugin usage • Repositories • Dependencies • Custom plugin
    • Projects structure • Project object model • Convention over configuration • Customize project model with build.gradle • Split big scripts into parts • Put submodule related script into separate file or keep everything in one file.
    • Projects structure example project/ api/ src/ build.gradle data/ src/ war/ src/ main/ test/ build.gradle settings.gradle
    • Build running Gradle Installing approaches • Locally installed Gradle distribution • Gradle Wrapper - Keep it with you project and wrapper solve all other tasks as Gradle version, downloading Gradle and etc. • GVM - Groovy enVironment Manager Gradle launch gradle <params> [task1, [task2, taks3, ...]]
    • Groovy is everywhere • Gradle scripts are Groovy scripts • Gradle works in JVM • All Java world in your hands
    • Groovy is everywhere example // Somewhere in build.gradle def env = System.getenv(); System.getenv().each { println it } def user = env['USER']; if (user != null) { println "User: $user"; }
    • Tasks • Task is a named piece of work • Tasks have relations between each other • Tasks creates steps by step process of project build
    • Tasks example def env; def user; task prepareEnv << { env = System.getenv(); } task prepareUser (dependsOn: 'prepareEnv') << { user = env['USER']; } task printEnv (dependsOn: 'prepareEnv') << { env.each { println it } } task printUser (dependsOn: 'prepareUser' ) << { if (user != null) { println "User: $user"; } }
    • Plugins usage 1. Declare that certain plugin will be used apply plugin: 'java' – adds Java lifecircle 2. Configure properties of this plugin 3. Launch task defined by this plugin
    • Java plugin and its tasks Java plugin define set of tasks and dependencies between the. In the way there is create lifecircle similar to lifecircle available in Maven
    • Repositories repositories { mavenLocal() mavenCentral() mavenRepo name: "lib", url:"libs" mavenRepo url: "http://repo.company.com/maven" ivy { url "http://repo.company.com/ivy" } // Any custom defined source of artifacts }
    • Dependencies • Dependency is described by group, name, version and other optional attributes • Dependency types are configurable by plugins • Java plugin adds compile, runtime, testCompile, testRuntime • Gradle support dependency version ranges • transitive dependency management
    • Dependencies example allprojects { dependencies { compile ''commons-collections:commons-collections:3.1'' testCompile group: 'junit', name: 'junit', version: '4.+' } } project(':api') { dependencies { compile ''javax.xml.ws:jaxws-api:$wsVersion'' } } project(':server') { dependencies { runtime ''com.sun.xml.ws:jaxws-rt:$wsVersion'' } }
    • Custom plugins and tasks There are places where custom plugins could be stored: • build.gradle • apply from: 'other.gradle' • buildSrc folder which is automatically used as a sources of additional scripts • Remotelocal repositories
    • Custom plugins - buildSrc buildSrc/ - Additional module with build script sources src/ main/ groovy/ Wsdl2JavaPlugin.groovy test/ build.gradle - more configuration if needed api/ data/ server/ build.gradle settings.gradle
    • Custom plugins - wsdl2java def class Wsdl2JavaPlugin implements Plugin<Project> { void apply(Project project) { // Take configuration of WSDL file path // Inject task in build life cycle project.tasks.processResources.dependsOn Wsdl2JavaTask // Generate sources and add theirs folder to Sources Set } } // Then somewhere in the project project(':api') { apply plugin: 'wsdl2java' wsdl2java src:"api/src/main/resources/wsdl/Service.wsdl" }
    • Gradle is • powerful • simple • compact • evolving • possible to debug Gradle is just fun!
    • That's all :)
    • Links Build tools • http://www.gradle.org/ • http://buildr.apache.org/ • http://rubyforge.org/projects/rake • http://ant.apache.org/ • http://maven.apache.org/ • http://www.gnu.org/software/make/ • http://www.cmake.org/