CiklumJavaSat _5112011:Igor Khotin-Gradle

1,106 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,106
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

CiklumJavaSat _5112011:Igor Khotin-Gradle

  1. 1. Gradlenext generation of build tools Игорь Хотинь E-mail: khotin@gmx.com
  2. 2. Background● 11+ лет в IT-индустрии● 6+ лет с Java● Сторонник гибкого дизайна● Agile-практик
  3. 3. Что мы используем?● Ant?● Maven?● Gradle?● ...
  4. 4. Что нас беспокоит?● Тяжёлые билды● Долгие циклы интеграции● Поддержка билд-проектов● ...
  5. 5. Как это было раньше?
  6. 6. Выбить перфокарты...
  7. 7. Принести оператору
  8. 8. Подождать результат
  9. 9. Забрать распечатки
  10. 10. Отладка?
  11. 11. 1977 – make
  12. 12. 2000
  13. 13. ant Сложность повторное использование тяжёлые build.xml контроль циклов сборки
  14. 14. 2001
  15. 15. maven тяжёлые pom.xml Сложно переопределить поведение по-умолчанию convention over configurationdependency management lost of control
  16. 16. Gradle вчера● Hans Dockter – основатель● Еволюция идей Gant● Начало 2008 – первые версии● Серия стабильных pre-1.0 релизов● 2010 Springy Innovation Award
  17. 17. Gradle сегодня● Релиз 1.0 milestone-3 stable● Активное сообщество● Gradleware● Apache License, Version 2.0
  18. 18. Gradle in the wild Qi4jGroovy Carrier Aluminum Grails Zeppelin GmhH Canoo Spock FCC Griffon EADS GPars Hibernate Gaelyk Spring-SecurityGant Spring-Integration
  19. 19. Who is that Gradle?● Build integration tool● Declarative builds● Groovy-based build DSL● Build-by-convention
  20. 20. Who is that Gradle?● Scalable – multi-project builds● Dependency management● Ease of migration● Embeddable● Deep API
  21. 21. Gradle positioning
  22. 22. Hello Gradlebuild.gradletask hello << { println Hello world!}> gradle -q helloHello Gradle!
  23. 23. gradle task != ant taskgradle task == ant target
  24. 24. Groovy в Gradlebuild.gradletask count << { 4.times { print "$it " }}> gradle -q count0 1 2 3
  25. 25. Dependenciesbuild.gradletask hello << { println Hello world!}task count(dependsOn: hello) << { 4.times { print "$it " }}> gradle -q countHello world!0 1 2 3
  26. 26. Lazy dependenciesbuild.gradletask hello(dependsOn: lazy) << { println Hello world!}task lazy << { println so lazy...}> gradle -q helloso lazy...Hello world!
  27. 27. Java Pluginbuild.gradleapply plugin: java> gradle build...
  28. 28. Java build-cycle customizationbuild.gradleapply plugin: javatest.doFirst { println Before testing...}test.doLast { println ...after testing.}
  29. 29. Reposbuild.gradleapply plugin: javarepositories { mavenCentral()}dependencies { compile group: commons-collections, name: commons-collections, version: 3.2 testCompile group: junit, name: junit, version: 4.+}
  30. 30. Antbuild.gradleant.importBuild build.xmltask ant << { ant.echo(message: hello from Ant) ant.zip(destfile: archive.zip) { fileset(dir: src) { include(name: **.xml) exclude(name: **.java) } }}
  31. 31. Gradle завтра● Сентябрь 2011 - 1.0 RC-1● Ожидаем релиз 1.0 к концу 2012 ● Более тесная интеграция с maven ● Build aggregation ● Gradle daemon ● Gradle 1.0 Plugin System ● Archetypes?
  32. 32. Apache Ant vs. Apache Maven vs. Gradle
  33. 33. 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>...
  34. 34. 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>...
  35. 35. 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>
  36. 36. 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>...
  37. 37. 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>
  38. 38. gradleapply plugin: javaversion="1.0-SNAPSHOT"group="grId"archivesBaseName="coc-comparison"repositories { mavenCentral()}dependencies { compile commons-lang:commons-lang:2.5 testCompile junit:junit:4.8.1}
  39. 39. Ресурсы● www.gradle.org● groovy.codehaus.org● ant.apache.org/ivy
  40. 40. КонтактыE-mail: khotin@gmx.comBlog: www.ikhotin.comTwitter: chaostarterlinkedin.com/pub/igor-khotin/5/193/257
  41. 41. Вопросы?

×