Top 10 reasons to migrate to Gradle

Post on 12-Apr-2017

1,254 views 0 download

transcript

Top 10 reasons to migrate to Gradle

Sergey Morenets, morenets@mail.ruOctober, 11 2015

About author• Works in IT since 2000• 12 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

Agenda

Agenda

Build systems

Google trends

Job trends

Reasons• Actuality• Programmability• Compactness• JVM-based and Java-based• DSL and API• Plugins• Integration• Configurations• Flexibility• Performance

Gradle• Development started in Apr 2008• Current version 2.7 released in September 2015• Default build tool for Android OS

Slogan• Make the impossible possible• Make the possible easy• Make the easy elegant

Build structure

Actuality

Version Release dateMaven 1.0 2004Maven 2.0 2005Maven 3.0 2010Maven 3.1 2013Maven 3.3 2015

Actuality

Version Release dateGradle 0.7 2009Gradle 1.0 2012Gradle 1.5 2013Gradle 2.0 2014Gradle 2.7 2015

Programmability

Programmability

Compactness

Ant plugin

Groovy plugin

Echo plugin

Gradle

Maven

Gradle

Maven

Gradle

Maven

Gradle

Transitive

Maven. Step #1

Maven. Step #2

Gradle

JVM and Java-based

DSL and API

DSL

Plugin• Reusable pieces of build logic• Can be used in different projects/builds• Script and binary plugins• 110 built-in and 580 custom plugins

Maven

Gradle

Plugin portal

Custom plugin

gradle helloWorld

Language plugins

Java Groovy

Scala C/C++

Objective-C

Integrates with everything

Version management

Version management

Maven Scope

Configurations

Performance

Cache everything

• Remote metadata and artifacts• Transitive dependency resolution• Build execution plan• Plugin inputs and outputs• Test results

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

gradle.properties

• org.gradle.daemon=true• org.gradle.configureondemand=true• org.gradle.parallel=true• org.gradle.java.home=C:\\Program Files\\Java\\

jdk1.8.0_60\\• org.gradle.jvmargs=-Xmx100m

Test execution

# of threads

H2 – time(sec) MySQL – time(sec)

1 24,4 27,52 31,1 36,94 46,2 51,18 71,1 80,5

Comparison• Maven 3.3.3• Gradle 2.7• JDK 1.8.0.60• Intel Core i7, 4 cores, 16 GB• Multi-project and single project builds• Optimized and default modes

Multi-project

• Optimization in Gradle speeds up 2-3 times• Gradle in optimized mode works 1.5 – 2.5 times

faster than Maven in any mode

Operation Gradle (opt)

Gradle (daemon)

Gradle Maven

Maven (parall)

Build(sec) 6,45 7.29 12,16 10,53 11,23Inc build(sec)

1,42 1,59 4,29 3,79 3,83

Clean(sec) 0,93 1,02 2,75 1,48 1,44

Gradle

Optimized Not optimized

Maven

Optimized Not optimized

Single project

• Optimization in Gradle speeds up 2-2.5 times• Gradle in optimized mode works 1.5 – 2 times

faster than Maven in any mode

Operation Gradle (opt)

Gradle (daemon)

Gradle Maven

Maven (parall)

Build(sec) 5,19 5,13 9,99 6,69 6,46Inc build(sec)

1,38 1,40 4,08 3,27 3,08

Clean(sec) 0,87 0,87 2,58 1,24 1,21

Behind the scene

Future

No migration• Trivial project• Maintenance phase• A lot of Maven plugins

Theory

Practice• https://github.com/hibernate/hibernate-orm• https://github.com/SpringSource/spring-

framework• https://github.com/gradle/gradle

Q&A

• Sergey Morenets, morenets@mail.ru