Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Who is this guy?
We will consult these 3 experts
Linus Torvalds
creator of Linux & Git
We will consult these 3 experts
Linus Torvalds Mark Reinhold
creator of Linux & Git Java's chief architect
We will consult these 3 experts
Linus Torvalds Mark Reinhold Louis van Gaal
creator of Linux & Git Java's chief architect ...
We will consult these 3 experts
Linus Torvalds Mark Reinhold Louis van Gaal
creator of Linux & Git Java's chief architect ...
Changes in
requirements
Changes in requirements
Past
compiling
packaging
Changes in requirements
Present
one project, multiple programming languages
compiling
running automated tests
packaging
in...
Defining builds in
XML
XML
Let's start by being nice:
excels at expressing hierarchical data
XML
Let's start by being nice:
excels at expressing hierarchical data
but...
build scripting logic doesn't easily fit a hi...
What does Linus think of XML?
What does Linus think of XML?
( )
XML is crap. Really. There are no excuses.
XML is nasty to parse for humans, and it's a
...
Build tools:
head to head
Ant vs. Maven according to Mark
Ant vs. Maven according to Mark
( )
What's the difference between Ant and
Maven?
https://www.parleys.com/tutorial/devoxx-f...
Ant vs. Maven according to Mark
( )
What's the difference between Ant and
Maven? The creator of Ant has apologized.
https:...
Build tools head-to-head
Ant Maven Gradle
Build tools head-to-head
Ant Maven Gradle
build script format XML XML Groovy / DSL
Build tools head-to-head
Ant Maven Gradle
build script format XML XML Groovy / DSL
dependencies with Ivy built-in built-in
Build tools head-to-head
Ant Maven Gradle
build script format XML XML Groovy / DSL
dependencies with Ivy built-in built-in...
Build tools head-to-head
Ant Maven Gradle
build script format XML XML Groovy / DSL
dependencies with Ivy built-in built-in...
Build tools head-to-head
Ant Maven Gradle
build script format XML XML Groovy / DSL
dependencies with Ivy built-in built-in...
Build tools head-to-head
Ant Maven Gradle
build script format XML XML Groovy / DSL
dependencies with Ivy built-in built-in...
Build tools head-to-head
Ant Maven Gradle
build script format XML XML Groovy / DSL
dependencies with Ivy built-in built-in...
Build tools head-to-head
Ant Maven Gradle
build script format XML XML Groovy / DSL
dependencies with Ivy built-in built-in...
Gradle at NS
(Dutch Railways)
Gradle at NS (Dutch Railways)
not at all a 'greenfield project'!
1 million lines of code
over 25,000 lines of Ant scriptin...
Migration strategy
Migration strategy
divide the project into components according to
functionality
start Gradling at a small, isolated part
...
Migration strategy
divide the project into components according to
functionality
start Gradling at a small, isolated part
...
Migration strategy
divide the project into components according to
functionality
start Gradling at a small, isolated part
...
Challenges
dependency spaghetti
collaboration with existing Ant code
continuous integration & delivery
Migration result
a component's responsibility has become clearer
a build will only run if the particular component has
cha...
Migration result (lines of code)
Language Lines of code (before) Lines of code (after)
Ant over 25,000 about 15,000
Gradle...
What does Louis think of migrating all Ant
code?
What does Louis think of migrating all Ant
code?
( )
In the Netherlands they say: "That is another
cook."
https://youtu.be...
Wrap-up
Wrap-up
Wrap-up
Ant & Maven:
require hard-to-maintain code
the purpose of a code fragment is not clearly evident
Wrap-up
Ant & Maven:
require hard-to-maintain code
the purpose of a code fragment is not clearly evident
often fail to add...
Wrap-up
Ant & Maven:
require hard-to-maintain code
the purpose of a code fragment is not clearly evident
often fail to add...
Wrap-up (2)
Gradle offers structure and flexibility
tries to combine the power of Ant and Maven
integrates with (almost) a...
Wrap-up (3)
So no drawbacks whatsoever?
Wrap-up (3)
So no drawbacks whatsoever?
Gradle spends a lot of time on configuration parsing (but
this has steadily improv...
Should my project use Gradle?
A brand-new project?
Should my project use Gradle?
A brand-new project?
just do it
Should my project use Gradle?
A brand-new project?
just do it
do it RIGHT NOW
Should my project use Gradle?
An existing project?
Should my project use Gradle?
An existing project?
Will you benefit from Gradles key features? (better
performance, mainta...
Should my project use Gradle?
An existing project?
Will you benefit from Gradles key features? (better
performance, mainta...
Should my project use Gradle?
An existing project?
Will you benefit from Gradles key features? (better
performance, mainta...
Any questions?
Further reading
"Why Build Your Java Projects with Gradle Rather than Ant
or Maven?"
by Benjamin Muschko
( )
Gradle User G...
Thank you :)
You can contact me at:
@hannotify
hanno.embregts@infosupport.com
Migrating 25K lines of Ant scripting to Gradle
Migrating 25K lines of Ant scripting to Gradle
Migrating 25K lines of Ant scripting to Gradle
Migrating 25K lines of Ant scripting to Gradle
Migrating 25K lines of Ant scripting to Gradle
Upcoming SlideShare
Loading in …5
×

Migrating 25K lines of Ant scripting to Gradle

361 views

Published on

Most developers prefer to spend their time writing code instead of performing build script maintenance. Build scripting may be an essential part of the software development process, but it often lacks maintainability which makes applying and deploying changes a tedious job. So it’s important to make sure your build system encourages simplicity and that changes can be made in a fast and straightforward way. Industry standards Ant and Maven are not quite up to the task; Gradle is a better alternative.

This presentation introduces Gradle – a modern build system that supports all JVM Languages – and shares the result of the Ant-to-Gradle migration that was performed at NS (Dutch Railways). The session will focus on the challenges we faced while trying to replace Ant scripting with the Gradle equivalent and how we handled them.

After attending this session, you will have a good understanding of Gradle and its pros and cons compared to Ant and Maven. On top of that, you will be able to migrate your own project to Gradle, even if your project has a huge code base or relies on ancient technologies. The lessons we learnt at NS could be very helpful to your own situation.

Published in: Software

Migrating 25K lines of Ant scripting to Gradle

  1. 1. Who is this guy?
  2. 2. We will consult these 3 experts Linus Torvalds creator of Linux & Git
  3. 3. We will consult these 3 experts Linus Torvalds Mark Reinhold creator of Linux & Git Java's chief architect
  4. 4. We will consult these 3 experts Linus Torvalds Mark Reinhold Louis van Gaal creator of Linux & Git Java's chief architect manager of Manchester United
  5. 5. We will consult these 3 experts Linus Torvalds Mark Reinhold Louis van Gaal creator of Linux & Git Java's chief architect former manager of Manchester United
  6. 6. Changes in requirements
  7. 7. Changes in requirements Past compiling packaging
  8. 8. Changes in requirements Present one project, multiple programming languages compiling running automated tests packaging integrating code as early as possible deploying software to TAP
  9. 9. Defining builds in XML
  10. 10. XML Let's start by being nice: excels at expressing hierarchical data
  11. 11. XML Let's start by being nice: excels at expressing hierarchical data but... build scripting logic doesn't easily fit a hierarchy often it consists of conditional and repeating logic which can be expressed more concisely in a programming language
  12. 12. What does Linus think of XML?
  13. 13. What does Linus think of XML? ( ) XML is crap. Really. There are no excuses. XML is nasty to parse for humans, and it's a disaster to parse even for computers. There's just no reason for that horrible crap to exist. https://plus.google.com/+LinusTorvalds/posts/X2XVf9Q7MfV
  14. 14. Build tools: head to head
  15. 15. Ant vs. Maven according to Mark
  16. 16. Ant vs. Maven according to Mark ( ) What's the difference between Ant and Maven? https://www.parleys.com/tutorial/devoxx-fireside-chat
  17. 17. Ant vs. Maven according to Mark ( ) What's the difference between Ant and Maven? The creator of Ant has apologized. https://www.parleys.com/tutorial/devoxx-fireside-chat
  18. 18. Build tools head-to-head Ant Maven Gradle
  19. 19. Build tools head-to-head Ant Maven Gradle build script format XML XML Groovy / DSL
  20. 20. Build tools head-to-head Ant Maven Gradle build script format XML XML Groovy / DSL dependencies with Ivy built-in built-in
  21. 21. Build tools head-to-head Ant Maven Gradle build script format XML XML Groovy / DSL dependencies with Ivy built-in built-in multi-module builds complex simple simple
  22. 22. Build tools head-to-head Ant Maven Gradle build script format XML XML Groovy / DSL dependencies with Ivy built-in built-in multi-module builds complex simple simple pre-defined structure absent present present
  23. 23. Build tools head-to-head Ant Maven Gradle build script format XML XML Groovy / DSL dependencies with Ivy built-in built-in multi-module builds complex simple simple pre-defined structure absent present present custom structure n/a complex simple
  24. 24. Build tools head-to-head Ant Maven Gradle build script format XML XML Groovy / DSL dependencies with Ivy built-in built-in multi-module builds complex simple simple pre-defined structure absent present present custom structure n/a complex simple verbosity high average low
  25. 25. Build tools head-to-head Ant Maven Gradle build script format XML XML Groovy / DSL dependencies with Ivy built-in built-in multi-module builds complex simple simple pre-defined structure absent present present custom structure n/a complex simple verbosity high average low learning curve shallow steep average
  26. 26. Build tools head-to-head Ant Maven Gradle build script format XML XML Groovy / DSL dependencies with Ivy built-in built-in multi-module builds complex simple simple pre-defined structure absent present present custom structure n/a complex simple verbosity high average low learning curve shallow steep average build order depends-on lifecycles directed acyclic graph
  27. 27. Gradle at NS (Dutch Railways)
  28. 28. Gradle at NS (Dutch Railways) not at all a 'greenfield project'! 1 million lines of code over 25,000 lines of Ant scripting 30 software developers system behaves like a monolith
  29. 29. Migration strategy
  30. 30. Migration strategy divide the project into components according to functionality start Gradling at a small, isolated part focus on code that is used regularly (i.e. on a daily basis)
  31. 31. Migration strategy divide the project into components according to functionality start Gradling at a small, isolated part focus on code that is used regularly (i.e. on a daily basis) verify after each step that: results are exactly the same as before no problems occur in existing Ant code
  32. 32. Migration strategy divide the project into components according to functionality start Gradling at a small, isolated part focus on code that is used regularly (i.e. on a daily basis) verify after each step that: results are exactly the same as before no problems occur in existing Ant code don't fool yourself: not every single line of Ant code should be replaced Ant projects are 'first class citizens'
  33. 33. Challenges dependency spaghetti collaboration with existing Ant code continuous integration & delivery
  34. 34. Migration result a component's responsibility has become clearer a build will only run if the particular component has changed run unit test in parallel (Gradle decides when) dependencies behave transitively
  35. 35. Migration result (lines of code) Language Lines of code (before) Lines of code (after) Ant over 25,000 about 15,000 Gradle 0 1,232
  36. 36. What does Louis think of migrating all Ant code?
  37. 37. What does Louis think of migrating all Ant code? ( ) In the Netherlands they say: "That is another cook." https://youtu.be/x-QRqOndbzw
  38. 38. Wrap-up
  39. 39. Wrap-up
  40. 40. Wrap-up Ant & Maven: require hard-to-maintain code the purpose of a code fragment is not clearly evident
  41. 41. Wrap-up Ant & Maven: require hard-to-maintain code the purpose of a code fragment is not clearly evident often fail to address changing requirements rely heavily on XML
  42. 42. Wrap-up Ant & Maven: require hard-to-maintain code the purpose of a code fragment is not clearly evident often fail to address changing requirements rely heavily on XML Gradle is a better alternative
  43. 43. Wrap-up (2) Gradle offers structure and flexibility tries to combine the power of Ant and Maven integrates with (almost) anything
  44. 44. Wrap-up (3) So no drawbacks whatsoever?
  45. 45. Wrap-up (3) So no drawbacks whatsoever? Gradle spends a lot of time on configuration parsing (but this has steadily improved in the past year) developers need to get used to it migrating existing scripting is a lot of work
  46. 46. Should my project use Gradle? A brand-new project?
  47. 47. Should my project use Gradle? A brand-new project? just do it
  48. 48. Should my project use Gradle? A brand-new project? just do it do it RIGHT NOW
  49. 49. Should my project use Gradle? An existing project?
  50. 50. Should my project use Gradle? An existing project? Will you benefit from Gradles key features? (better performance, maintainability, less verbose, ...)
  51. 51. Should my project use Gradle? An existing project? Will you benefit from Gradles key features? (better performance, maintainability, less verbose, ...) Any technical debt to solve?
  52. 52. Should my project use Gradle? An existing project? Will you benefit from Gradles key features? (better performance, maintainability, less verbose, ...) Any technical debt to solve? use an artifact repository and remove duplicates divide your project into multiple components define a clear structure in your build logic
  53. 53. Any questions?
  54. 54. Further reading "Why Build Your Java Projects with Gradle Rather than Ant or Maven?" by Benjamin Muschko ( ) Gradle User Guide ( ) Gradle Build Language Reference ( ) http://www.drdobbs.com/jvm/why-build-your-java-projects-with-gradle/240168608 http://gradle.org/docs/current/userguide/userguide.html http://gradle.org/docs/current/dsl/index.html
  55. 55. Thank you :) You can contact me at: @hannotify hanno.embregts@infosupport.com

×