SlideShare a Scribd company logo
1 of 42
Download to read offline
Gradle
next generation of build tools




                        Игорь Хотинь
                      E-mail: khotin@gmx.com
Background
● 11+ лет в IT-индустрии
● 6+ лет с Java

● Сторонник гибкого дизайна

● Agile-практик
Что мы используем?
●   Ant?
●   Maven?
●   Gradle?
●   ...
Что нас беспокоит?
●   Тяжёлые билды
●   Долгие циклы интеграции
●   Поддержка билд-проектов
●   ...
Как это было раньше?
Выбить перфокарты...
Принести оператору
Подождать результат
Забрать распечатки
Отладка?
1977 – make
2000
ant           Сложность
      повторное использование

             тяжёлые build.xml
             контроль циклов сборки
2001
maven                         тяжёлые pom.xml

                  Сложно переопределить
                  поведение по-умолчанию


     convention over configuration


dependency management



          lost of control
Gradle вчера
●   Hans Dockter – основатель
●   Еволюция идей Gant
●   Начало 2008 – первые версии
●   Серия стабильных pre-1.0 релизов
●   2010 Springy Innovation Award
Gradle сегодня
●   Релиз 1.0 milestone-3 stable
●   Активное сообщество
●   Gradleware
●   Apache License, Version 2.0
Gradle in the wild
                             Qi4j
Groovy          Carrier               Aluminum


  Grails      Zeppelin GmhH
                              Canoo       Spock
       FCC              Griffon
                                    EADS
 GPars
                    Hibernate
           Gaelyk              Spring-Security
Gant
              Spring-Integration
Who is that Gradle?
●   Build integration tool
●   Declarative builds
●   Groovy-based build DSL
●   Build-by-convention
Who is that Gradle?
●   Scalable – multi-project builds
●   Dependency management
●   Ease of migration
●   Embeddable
●   Deep API
Gradle positioning
Hello Gradle

build.gradle

task hello << {
    println 'Hello world!'
}

> gradle -q hello
Hello Gradle!
gradle task != ant task


gradle task == ant target
Groovy в Gradle
build.gradle

task count << {
    4.times { print "$it " }
}

> gradle -q count
0 1 2 3
Dependencies
build.gradle
task hello << {
    println 'Hello world!'
}
task count(dependsOn: hello) << {
    4.times { print "$it " }
}

> gradle -q count
Hello world!
0 1 2 3
Lazy dependencies
build.gradle
task hello(dependsOn: 'lazy') << {
    println 'Hello world!'
}
task lazy << {
    println 'so lazy...'
}

> gradle -q hello
so lazy...
Hello world!
Java Plugin
build.gradle

apply plugin: 'java'




> gradle build
...
Java build-cycle customization
build.gradle

apply plugin: 'java'

test.doFirst {
    println 'Before testing...'
}
test.doLast {
    println '...after testing.'
}
Repos
build.gradle
apply plugin: 'java'
repositories {
    mavenCentral()
}
dependencies {
    compile group: 'commons-collections', name:
              'commons-collections', version: '3.2'
    testCompile group: 'junit', name: 'junit',
                                     version: '4.+'
}
Ant
build.gradle
ant.importBuild 'build.xml'

task ant << {
    ant.echo(message: 'hello from Ant')
    ant.zip(destfile: 'archive.zip') {
        fileset(dir: 'src') {
            include(name: '**.xml')
            exclude(name: '**.java')
        }
    }
}
Gradle завтра
●   Сентябрь 2011 - 1.0 RC-1
●   Ожидаем релиз 1.0 к концу 2012
    ● Более тесная интеграция с maven
    ● Build aggregation


    ● Gradle daemon


    ● Gradle 1.0 Plugin System


    ● Archetypes?
Apache Ant vs. Apache Maven vs. Gradle
ant
<?xml version="1.0"?>
<project name="simple" default="dist" basedir=".">
  <property name="src" location="src/main/java"/>
  <property name="srcTest" location="src/test/java"/>
  <property name="build" location="build"/>
  <property name="dist" location="${build}/lib"/>
  <property name="version" value="1.0-SNAPSHOT" />
  <path id="classpath.compile">
    <pathelement location="libs/commons-lang-2.5.jar"/>
  </path>
  <path id="classpath.test">
    <pathelement location="libs/junit-4.8.2.jar"/>
    <pathelement location="libs/commons-lang-2.5.jar"/>
    <pathelement location="${srcTest}"/>
    <pathelement location="${build}/classes"/>
    <pathelement location="${build}/test-classes"/>
  </path>
...
ant
...
  <target name="init">
    <mkdir dir="${build}/classes"/>
    <mkdir dir="${build}/test-classes"/>
  </target>
  <target name="compile" depends="init">
    <javac srcdir="${src}" destdir="${build}/classes">
     <classpath refid="classpath.compile"/>
    </javac>
  </target>
  <target name="testCompile" depends="compile">
    <javac srcdir="${srcTest}" destdir="${build}/test-classes">
     <classpath refid="classpath.test"/>
    </javac>
  </target>
...
ant
...
<target name="test" depends="testCompile">
    <junit fork="yes" haltonfailure="yes">
     <batchtest fork="yes">
       <fileset dir="${srcTest}">
        <include name="**/*Test.java"/>
       </fileset>
     </batchtest>
     <classpath refid="classpath.test"/>
     <formatter type="plain"/>
    </junit>
  </target>
  <target name="dist" depends="test">
    <mkdir dir="${dist}"/>
    <jar jarfile="${dist}/coc-comparison-${version}.jar"
                                       basedir="${build}/classes"/>
  </target>
  <target name="clean"><delete dir="${build}"/></target>
</project>
maven
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
    http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>grId</groupId>
  <artifactId>coc-comparison</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
...
maven
...
  <dependencies>
    <dependency>
     <groupId>commons-lang</groupId>
     <artifactId>commons-lang</artifactId>
     <version>2.5</version>
    </dependency>
    <dependency>
     <groupId>junit</groupId>
     <artifactId>junit</artifactId>
     <version>4.8.1</version>
     <scope>test</scope>
    </dependency>
  </dependencies>
</project>
gradle
apply plugin: 'java'

version="1.0-SNAPSHOT"
group="grId"
archivesBaseName="coc-comparison"

repositories {
    mavenCentral()
}

dependencies {
  compile 'commons-lang:commons-lang:2.5'
  testCompile 'junit:junit:4.8.1'
}
Ресурсы
●   www.gradle.org
●   groovy.codehaus.org
●   ant.apache.org/ivy
Контакты

E-mail: khotin@gmx.com
Blog: www.ikhotin.com
Twitter: chaostarter
linkedin.com/pub/igor-khotin/5/193/257
Вопросы?

More Related Content

More from Ciklum Ukraine

"Through the three circles of the it hell" by Roman Liashenko
"Through the three circles of the it hell" by Roman Liashenko"Through the three circles of the it hell" by Roman Liashenko
"Through the three circles of the it hell" by Roman LiashenkoCiklum Ukraine
 
Introduction to amazon web services for developers
Introduction to amazon web services for developersIntroduction to amazon web services for developers
Introduction to amazon web services for developersCiklum Ukraine
 
Your 1st Apple watch Application
Your 1st Apple watch ApplicationYour 1st Apple watch Application
Your 1st Apple watch ApplicationCiklum Ukraine
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven DevelopmentCiklum Ukraine
 
Back to the future: ux trends 2015
Back to the future: ux trends 2015Back to the future: ux trends 2015
Back to the future: ux trends 2015Ciklum Ukraine
 
Developing high load systems using C++
Developing high load systems using C++Developing high load systems using C++
Developing high load systems using C++Ciklum Ukraine
 
Collection view layout
Collection view layoutCollection view layout
Collection view layoutCiklum Ukraine
 
Introduction to auto layout
Introduction to auto layoutIntroduction to auto layout
Introduction to auto layoutCiklum Ukraine
 
Unit Testing: Special Cases
Unit Testing: Special CasesUnit Testing: Special Cases
Unit Testing: Special CasesCiklum Ukraine
 
Model-View-Controller: Tips&Tricks
Model-View-Controller: Tips&TricksModel-View-Controller: Tips&Tricks
Model-View-Controller: Tips&TricksCiklum Ukraine
 
Future of Outsourcing report published in The Times featuring Ciklum's CEO To...
Future of Outsourcing report published in The Times featuring Ciklum's CEO To...Future of Outsourcing report published in The Times featuring Ciklum's CEO To...
Future of Outsourcing report published in The Times featuring Ciklum's CEO To...Ciklum Ukraine
 
Михаил Попчук "Cкрытые резервы команд или 1+1=3"
Михаил Попчук "Cкрытые резервы команд или 1+1=3"Михаил Попчук "Cкрытые резервы команд или 1+1=3"
Михаил Попчук "Cкрытые резервы команд или 1+1=3"Ciklum Ukraine
 
"To be, rather than to seem” interview with Ciklum VP of HR Marina Vyshegorod...
"To be, rather than to seem” interview with Ciklum VP of HR Marina Vyshegorod..."To be, rather than to seem” interview with Ciklum VP of HR Marina Vyshegorod...
"To be, rather than to seem” interview with Ciklum VP of HR Marina Vyshegorod...Ciklum Ukraine
 

More from Ciklum Ukraine (20)

"Through the three circles of the it hell" by Roman Liashenko
"Through the three circles of the it hell" by Roman Liashenko"Through the three circles of the it hell" by Roman Liashenko
"Through the three circles of the it hell" by Roman Liashenko
 
Introduction to amazon web services for developers
Introduction to amazon web services for developersIntroduction to amazon web services for developers
Introduction to amazon web services for developers
 
Your 1st Apple watch Application
Your 1st Apple watch ApplicationYour 1st Apple watch Application
Your 1st Apple watch Application
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Back to the future: ux trends 2015
Back to the future: ux trends 2015Back to the future: ux trends 2015
Back to the future: ux trends 2015
 
Developing high load systems using C++
Developing high load systems using C++Developing high load systems using C++
Developing high load systems using C++
 
Collection view layout
Collection view layoutCollection view layout
Collection view layout
 
Introduction to auto layout
Introduction to auto layoutIntroduction to auto layout
Introduction to auto layout
 
Groovy on Android
Groovy on AndroidGroovy on Android
Groovy on Android
 
Unit Testing: Special Cases
Unit Testing: Special CasesUnit Testing: Special Cases
Unit Testing: Special Cases
 
Material design
Material designMaterial design
Material design
 
Kanban development
Kanban developmentKanban development
Kanban development
 
Mobile sketching
Mobile sketching Mobile sketching
Mobile sketching
 
More UX in our life
More UX in our lifeMore UX in our life
More UX in our life
 
Model-View-Controller: Tips&Tricks
Model-View-Controller: Tips&TricksModel-View-Controller: Tips&Tricks
Model-View-Controller: Tips&Tricks
 
Unit Tesing in iOS
Unit Tesing in iOSUnit Tesing in iOS
Unit Tesing in iOS
 
Future of Outsourcing report published in The Times featuring Ciklum's CEO To...
Future of Outsourcing report published in The Times featuring Ciklum's CEO To...Future of Outsourcing report published in The Times featuring Ciklum's CEO To...
Future of Outsourcing report published in The Times featuring Ciklum's CEO To...
 
Михаил Попчук "Cкрытые резервы команд или 1+1=3"
Михаил Попчук "Cкрытые резервы команд или 1+1=3"Михаил Попчук "Cкрытые резервы команд или 1+1=3"
Михаил Попчук "Cкрытые резервы команд или 1+1=3"
 
"To be, rather than to seem” interview with Ciklum VP of HR Marina Vyshegorod...
"To be, rather than to seem” interview with Ciklum VP of HR Marina Vyshegorod..."To be, rather than to seem” interview with Ciklum VP of HR Marina Vyshegorod...
"To be, rather than to seem” interview with Ciklum VP of HR Marina Vyshegorod...
 
Why to join Ciklum?
Why to join Ciklum?Why to join Ciklum?
Why to join Ciklum?
 

CiklumJavaSat _5112011:Igor Khotin-Gradle