Ce diaporama a bien été signalé.
Le téléchargement de votre SlideShare est en cours. ×

Gradle 2.Breaking stereotypes

Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Prochain SlideShare
Git.From thorns to the stars
Git.From thorns to the stars
Chargement dans…3
×

Consultez-les par la suite

1 sur 82 Publicité

Plus De Contenu Connexe

Diaporamas pour vous (20)

Publicité

Similaire à Gradle 2.Breaking stereotypes (20)

Plus récents (20)

Publicité

Gradle 2.Breaking stereotypes

  1. 1. Gradle 2. Breaking stereotypes Sergey Morenets, morenets@mail.ru June, 17 2015
  2. 2. About author • Works in IT since 2000 • 11 year of Java SE/EE experience • Regular speaker at Java conferences • Author of “Development of Java applications” and “Main errors in Java programming ”books • Founder of http://it-simulator.com • 3 years of Gradle usage
  3. 3. Agenda
  4. 4. Agenda
  5. 5. Apache Ant • Offers extreme flexibility • Imposes no convention or project standards • Maintenance headache • Support Ruby, Groovy, JavaScript, Judoscript, Jython scripting
  6. 6. Apache Ivy • Agile dependency manager • Transitive dependencies • Ant & Maven integration • Enhanced support of repositories
  7. 7. Apache Maven • Support for dependency management • Standard project layout • Archetypes • Hard customization • Declarative approach • Plugin execution framework
  8. 8. Build systems
  9. 9. Apache Maven
  10. 10. Ant plugin
  11. 11. Groovy plugin
  12. 12. Echo plugin
  13. 13. Gradle
  14. 14. Maven
  15. 15. Gradle
  16. 16. Gradle
  17. 17. Maven
  18. 18. Gradle
  19. 19. Issue #1. XML • Large and complex files are hard to understand • Hierarchical structure limits the expressiveness of the format • Good format for the data and complex for the flow
  20. 20. Hans Dockter • Founder of Gradle and Gradleware • 13 years of experience as a software developer, team leader, architect, trainer, and mentor • Previously worked at Jboss and founded Jboss-IDE • Holds a Diploma in Physics with a minor in Computer Science • Admirer of domain-driven-design
  21. 21. Slogan • Make the impossible possible • Make the possible easy • Make the easy elegant
  22. 22. Solution #1. Groovy • An agile and dynamic language for the Java Virtual Machine • Makes modern programming features available to Java developers with almost-zero learning curve • Provides the ability to statically type check and statically compile your code for robustness and performance • Share base syntax, type system, packages hierarchy with Java • Every Gradle build file is Groovy script
  23. 23. Gradle
  24. 24. Gradle • Development started in Apr 2008 • Current version 2.4 released in May 2015 • Default build tool for Android OS
  25. 25. Gradle overview • A flexible general purpose build tool • Programming tool • Declarative builds and build-by-convention • Multi-project support • Powerful dependency management
  26. 26. Development Version Release date Maven 1.0 2004 Maven 2.0 2005 Maven 3.0 2010 Maven 3.1 2013 Maven 3.3 2015
  27. 27. Development Version Release date Gradle 0.7 2009 Gradle 1.0 2012 Gradle 1.5 2013 Gradle 2.0 2014 Gradle 2.4 2015
  28. 28. Build structure
  29. 29. Hello world $ gradle helloWorld
  30. 30. build.gradle
  31. 31. Maven pom
  32. 32. Sample project
  33. 33. Sample project
  34. 34. Custom task • Writes audit information at the end of the build • Audit information includes project name and build timestamp • Audit files are located in the separate folder
  35. 35. Custom task
  36. 36. Custom task
  37. 37. Cache everything • Remote metadata and artifacts • Transitive dependency resolution • Build execution plan • Plugin inputs and outputs • Test results
  38. 38. Daemon • Improves startup and execution time of Gradle • Initial Gradle command forks daemon process • Subsequent Gradle commands reuse the build daemon • If daemon is currently busy then new daemon process is started on-demand • Useful for small tasks execution • Expires after 3 hours of idle time
  39. 39. gradle.properties • org.gradle.daemon=true • org.gradle.configureondemand=true • org.gradle.parallel=true • org.gradle.java.home=C:Program FilesJavajdk1.8.0_45 • org.gradle.jvmargs=-Xmx100m
  40. 40. Test execution # of threads H2 – time(sec) MySQL – time(sec) 1 24,4 27,5 2 31,1 36,9 4 46,2 51,1 8 71,1 80,5
  41. 41. Plugin • Reusable pieces of build logic • Can be used in different projects/builds
  42. 42. Plugin portal
  43. 43. Custom plugin gradle helloWorld
  44. 44. Maven
  45. 45. Gradle
  46. 46. Integrates with everything
  47. 47. Gradle and Maven
  48. 48. Comparison • Maven 3.3.3 • Gradle 2.4 • JDK 1.8.0.45 • Intel Core i7, 4 cores, 16 GB • Multi-project and single project builds • Optimized and default modes
  49. 49. Multi-project Operation Gradle (opt) Gradle (daemon) Gradle(no daemon) Maven Maven (parall) Build(sec) 8,03 10,73 13,68 12,40 13,02 Inc build(sec) 1,92 2,16 4,74 4,62 4,64 Clean(sec) 1,03 1,20 2,77 1,71 1,70
  50. 50. Gradle Optimized Not optimized
  51. 51. Maven Optimized Not optimized
  52. 52. Single project Operation Gradle (opt) Gradle (daemon) Gradle(no daemon) Maven Maven (parall) Build(sec) 1,41 1,46 4,55 2,38 2,37 Inc build(sec) 0,95 1,01 3,27 0,88 0,86 Clean(sec) 0,89 0,95 2,68 0,24 0,19
  53. 53. Maven converter • maven2Gradle is obsolete now • Build init plugin converts: o POM settings o Dependencies o Properties o Java compiler settings o Single- and multi-project settings o Packaging of sources and tests
  54. 54. Repositories
  55. 55. Maven Scope
  56. 56. Maven Scope
  57. 57. Configurations
  58. 58. Version management
  59. 59. Version management
  60. 60. Profiles • build.gradle • dev-profile.gradle • test-profile.gradle • $ gradle –Pprofile=dev build
  61. 61. Skip tasks • $ gradle -PskipTests
  62. 62. Caching • Gradle caches all compiles scripts by default • Compiled scripts are put into .gradle folder • Gradle uses compiled version if the script hasn’t changed • --recompile-scripts option discards cache
  63. 63. Wrapper • Preferred way of starting a Gradle build • Gradle will be automatically downloaded via wrapper • Includes shell script • Useful for CI tasks
  64. 64. Pros • Native Java/Scala/Groovy support • Ant/Maven/Ivy integration • Full IDE support • Flexible DSL • Multiple third-party plugins(70+) • Declarative & imperative approaches • Rapid development • Performance
  65. 65. Cons • Compilation & run-time issues • Larger learning curve • Less community & industry support
  66. 66. Future
  67. 67. Practice • https://github.com/hibernate/hibernate-orm • https://github.com/SpringSource/spring-framework • https://github.com/gradle/gradle
  68. 68. Q&A • Sergey Morenets, morenets@mail.ru

×