SlideShare une entreprise Scribd logo
1  sur  44
Télécharger pour lire hors ligne
Why Gradle?
Peter Ledbrook
e: peter@cacoethes.co.uk
w: http://www.cacoethes.co.uk
t: @pledbrook
When did it all begin?
• Programmable
machines have a long
history
• Mechanised
instruments
• Looms
Late 18th/early 19th centuries
Punched
cards
First used for looms in 18th Century France - Jacquard Loom 1801
IBM introduced punched card format 1928 - 80 columns!
Text mode column width for DOS, Unix etc.
Imagine creating by hand
Keypunch machines (a little like typewriters) for creating them
Errors mean throwing away the card and doing it again
Fortran and Cobol started with punched cards
Fixing card decks
What if your cards are dropped on the floor?
This is an IBM 082 Sorter
Automation of a very error-prone manual process
Magnetism saves the day!
Finally, R/W data and code. The dawn of text editors.
C/C++
Multi-platform
builds!
Compiler
Linker
Source
.so/.dll & .exe
Make
*.c: *.o
cc …
myapp: app.o mylib.o …
ld …
+ manual custom dependencies
Focus mainly on compilation and linking
Make has powerful model based on file dependencies
Maintenance was a lot of work
Make
*.c: *.o
cc …
myapp: app.o mylib.o …
ld …
What’s this?
+ manual custom dependencies
Tabs were the bane of Make file writers
Java
• Compiler handles .java to .class
dependencies
• JAR as ‘module’ unit
• Several standard deployment types
- Applet
- WAR
- Standalone app
Publish == prod server, installer, JAR, zip package, etc.
A standard build
Compile Test Package Publish?
A simplification from the days of C
Interesting point: does the packaging actually require the tests to run?
What will builds look like in 5
years time?
Our builds last a long time
You want a tool that can grow and adapt
One that handles all sorts of build processes
Even Java builds are evolving
Model as a graph
Step
Step Step
Step
Step
All build processes can be modeled as a Directed Acyclic Graph (DAG) of steps
This is the Gradle model (a task == a step)
But we don’t want to set up all
those steps!
Gradle Conventions
apply	 plugin:	 "java"

group	 =	 "org.example"

version	 =	 "0.7.1"

sourceCompatibility	 =	 "1.7"

targetCompatibility	 =	 "1.7"

Java build conventions
provided by plugin
Gradle Conventions
• compileJava (src/main/java)
• compileTestJava (src/test/java)
• test (added as dependency of check)
- test reports in build/reports/test
• jar (added as dependency of assemble)
- created in build/libs
• javadoc
Not all builds are the same
Java build evolved
Compile Test Package Publish?
Dev setup Run
QA
SCM Tags
Deployment
Docs
Generators
JS + CSS
Builds are incorporating more and more steps
Android is an example of a quite different Java build
Custom build
publishPdf
publishGuide
apiDocs
fetchGrailsSource
grails-doc
project
expensive,
so optional
build
A build to generate the Grails user guide
Automation of all steps
No standard tasks
Task graph is a suitable model
Mixed build
C/C++
DLL/SO
Java
Debian packages
Executable
Build barrier
Build barrier
I’ve worked with or know of several projects that have native + Java parts
Each transfer between different build systems is like a baton handover - with the potential for the baton to be dropped.
The build tool should not
dictate the build process
Goals of a build
What do we want out of our build processes?
Automation
People are fallible
Muscle memory can help
e.g. tying shoe laces
Not usually applicable in software development
Automation
• Humans are fallible
• Every manual step adds to the fragility of
the build
• Muscle memory can help, but rarely
applicable
People are fallible
Muscle memory can help
e.g. tying shoe laces
Not usually applicable in software development
Mistakes == Lost time
(and possibly money)
Errors made deploying to beta.grails.org and grails.org
Long path between updating source code and starting the server with changes
Stress and downtime
Does your build have manual
steps? If so, why?
For example, copying files around, entering parameter values, running external scripts, etc.
Custom tasks in Gradle
task	 publishGuide	 <<	 {

	 	 	 	 //	 Generate	 HTML	 from	 .gdoc

}

build.dependsOn	 publishGuide
buildSrc/src/groovy/pkg/PublishGuideTask.groovy
pkg.PublishGuideTask in a JAR
Don’t reinvent the wheel
http://plugins.gradle.org/
Gradle Plugin Portal
This is searchable
Contains many (but not all) publicly available plugins
You can publish your own too
Repeatability
Same inputs should result in
same outputs
In other words, repeatable builds
Environment should not be a factor
Does the build behave differently on different platforms?
Consider “works for me” with local Maven cache
Depends on tasks
• Are tasks environment-dependent?
• Do system properties or environment
variables have an effect?
• What about number of cores?
• Order of tests?
Gradle can’t help much with this - except for task ordering
Task ordering
• mustRunAfter/shouldRunAfter
• No task dependencies
task	 integTest	 {

	 	 	 	 ...

}

task	 packageReports	 {

	 	 	 	 mustRunAfter	 integTest

	 	 	 	 ...

}

`packageReports` does not depend on `integTest`
But if both are executed, `packageReports` must come after `integTest`
shouldRunAfter is less strict - mostly to optimise feedback
Task ordering
• finalizedBy
• Ensures execution of the finalizer task
task	 integTest	 {

	 	 	 	 finalizedBy	 packageReports

	 	 	 	 ...

}

task	 packageReports	 {

	 	 	 	 ...

}

`packageReports` does not depend on `integTest`
If `integTest` runs, then `packageReports` will run too, always after `integTest`
Gradle cache
• Origin checks
• Artifact checksums
• Concurrency safe
• Avoid mavenLocal()!
Dependency cache can be a big impediment to repeatability
Resolution strategy
configurations.all	 {

	 	 resolutionStrategy	 {

	 	 	 	 failOnVersionConflict()

	 	 	 	 force	 'asm:asm-all:3.3.1',

	 	 	 	 	 	 	 	 	 	 'commons-io:commons-io:1.4'

}
Override version to use
for specific dependencies
Fail the build if any
version conflicts
Defaults to ‘newest’ strategy
Fine-grained control over dependency versions
Automatic conflict resolution error-prone
Resolution strategy
configurations.all	 {

	 	 eachDependency	 {	 details	 ->

	 	 	 	 if	 (details.requested.name	 ==	 'groovy-all')	 {

	 	 	 	 	 	 details.useTarget(

	 	 	 	 	 	 	 	 	 	 group:	 details.requested.group,

	 	 	 	 	 	 	 	 	 	 name:	 'groovy',

	 	 	 	 	 	 	 	 	 	 version:	 details.requested.version)

	 	 	 	 }

	 	 }

}
Control modules with
different names, same classes
A painful problem to debug
Efficiency
Some tasks take significant amounts of time to execute
Why run them each time?
Think Ant/Maven incremental compilation
Incremental build
:lazybones-app:compileJava

:lazybones-app:compileGroovy	 UP-TO-DATE

:lazybones-app:processResources	 UP-TO-DATE

:lazybones-app:classes	 UP-TO-DATE

:lazybones-app:jar	 UP-TO-DATE

:lazybones-app:startScripts	 UP-TO-DATE

:lazybones-app:installApp	 UP-TO-DATE

BUILD	 SUCCESSFUL

Total	 time:	 2.178	 secs
UP-TO-DATE
Don’t execute tasks you don’t have to
Task inputs & outputs
class	 BintrayGenericUpload	 extends	 DefaultTask	 {

	 	 	 	 @InputFile	 File	 artifactFile

	 	 	 	 @Input	 	 	 	 	 String	 artifactUrlPath

	 	 	 	 @Optional

	 	 	 	 @Input	 	 	 	 	 String	 repositoryUrl

	 	 	 	 …⋯

}
Use of annotations makes task support incremental build
Inputs and outputs can be values, files, directories
A build should be…
Automated
Repeatable
Efficient
On top of this, Gradle gives you
• a rich API for modelling your build process
• full dependency management
• Java ecosystem integration
- IDEs, CI, static analysis tools, etc.
• Flexible publishing (Maven, Ivy,AWS S3)
• Many useful plugins to save you work
Summary
• End-to-end process is the build
• 80-20 rule (80% standard 20% custom)
• Automate everything == save time
• Invest in build as if it’s part of your code
base
• Building software requires a rich model
Thank you!
e: peter@cacoethes.co.uk
w: http://www.cacoethes.co.uk
t: @pledbrook

Contenu connexe

Tendances

An Introduction to Gradle for Java Developers
An Introduction to Gradle for Java DevelopersAn Introduction to Gradle for Java Developers
An Introduction to Gradle for Java DevelopersKostas Saidis
 
Exploring the power of Gradle in android studio - Basics & Beyond
Exploring the power of Gradle in android studio - Basics & BeyondExploring the power of Gradle in android studio - Basics & Beyond
Exploring the power of Gradle in android studio - Basics & BeyondKaushal Dhruw
 
Efficient JavaScript Unit Testing, May 2012
Efficient JavaScript Unit Testing, May 2012Efficient JavaScript Unit Testing, May 2012
Efficient JavaScript Unit Testing, May 2012Hazem Saleh
 
Managing big test environment and running tests with Jenkins, Jenkins Job bui...
Managing big test environment and running tests with Jenkins, Jenkins Job bui...Managing big test environment and running tests with Jenkins, Jenkins Job bui...
Managing big test environment and running tests with Jenkins, Jenkins Job bui...Timofey Turenko
 
Cool JVM Tools to Help You Test
Cool JVM Tools to Help You TestCool JVM Tools to Help You Test
Cool JVM Tools to Help You TestSchalk Cronjé
 
Modularizing your Grails Application with Private Plugins - SpringOne 2GX 2012
Modularizing your Grails Application with Private Plugins - SpringOne 2GX 2012Modularizing your Grails Application with Private Plugins - SpringOne 2GX 2012
Modularizing your Grails Application with Private Plugins - SpringOne 2GX 2012kennethaliu
 
Gradle - time for a new build
Gradle - time for a new buildGradle - time for a new build
Gradle - time for a new buildIgor Khotin
 
Continuous Integration using Cruise Control
Continuous Integration using Cruise ControlContinuous Integration using Cruise Control
Continuous Integration using Cruise Controlelliando dias
 
Idiomatic gradle plugin writing
Idiomatic gradle plugin writingIdiomatic gradle plugin writing
Idiomatic gradle plugin writingSchalk Cronjé
 
Gradle in 45min - JBCN2-16 version
Gradle in 45min - JBCN2-16 versionGradle in 45min - JBCN2-16 version
Gradle in 45min - JBCN2-16 versionSchalk Cronjé
 
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle build tool that rocks with DSL JavaOne India 4th May 2012Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle build tool that rocks with DSL JavaOne India 4th May 2012Rajmahendra Hegde
 
Dsc Charusat Learning React Part 1
Dsc Charusat Learning React Part 1 Dsc Charusat Learning React Part 1
Dsc Charusat Learning React Part 1 JainamMehta19
 
Introducing Playwright's New Test Runner
Introducing Playwright's New Test RunnerIntroducing Playwright's New Test Runner
Introducing Playwright's New Test RunnerApplitools
 

Tendances (19)

Building with Gradle
Building with GradleBuilding with Gradle
Building with Gradle
 
Gradle in 45min
Gradle in 45minGradle in 45min
Gradle in 45min
 
Learn react-js
Learn react-jsLearn react-js
Learn react-js
 
An Introduction to Gradle for Java Developers
An Introduction to Gradle for Java DevelopersAn Introduction to Gradle for Java Developers
An Introduction to Gradle for Java Developers
 
Exploring the power of Gradle in android studio - Basics & Beyond
Exploring the power of Gradle in android studio - Basics & BeyondExploring the power of Gradle in android studio - Basics & Beyond
Exploring the power of Gradle in android studio - Basics & Beyond
 
Efficient JavaScript Unit Testing, May 2012
Efficient JavaScript Unit Testing, May 2012Efficient JavaScript Unit Testing, May 2012
Efficient JavaScript Unit Testing, May 2012
 
Introduction of React.js
Introduction of React.jsIntroduction of React.js
Introduction of React.js
 
Managing big test environment and running tests with Jenkins, Jenkins Job bui...
Managing big test environment and running tests with Jenkins, Jenkins Job bui...Managing big test environment and running tests with Jenkins, Jenkins Job bui...
Managing big test environment and running tests with Jenkins, Jenkins Job bui...
 
Cool JVM Tools to Help You Test
Cool JVM Tools to Help You TestCool JVM Tools to Help You Test
Cool JVM Tools to Help You Test
 
Modularizing your Grails Application with Private Plugins - SpringOne 2GX 2012
Modularizing your Grails Application with Private Plugins - SpringOne 2GX 2012Modularizing your Grails Application with Private Plugins - SpringOne 2GX 2012
Modularizing your Grails Application with Private Plugins - SpringOne 2GX 2012
 
Gradle - time for a new build
Gradle - time for a new buildGradle - time for a new build
Gradle - time for a new build
 
Gradle
GradleGradle
Gradle
 
Continuous Integration using Cruise Control
Continuous Integration using Cruise ControlContinuous Integration using Cruise Control
Continuous Integration using Cruise Control
 
Idiomatic gradle plugin writing
Idiomatic gradle plugin writingIdiomatic gradle plugin writing
Idiomatic gradle plugin writing
 
Gradle in 45min - JBCN2-16 version
Gradle in 45min - JBCN2-16 versionGradle in 45min - JBCN2-16 version
Gradle in 45min - JBCN2-16 version
 
Workshop React.js
Workshop React.jsWorkshop React.js
Workshop React.js
 
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle build tool that rocks with DSL JavaOne India 4th May 2012Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
 
Dsc Charusat Learning React Part 1
Dsc Charusat Learning React Part 1 Dsc Charusat Learning React Part 1
Dsc Charusat Learning React Part 1
 
Introducing Playwright's New Test Runner
Introducing Playwright's New Test RunnerIntroducing Playwright's New Test Runner
Introducing Playwright's New Test Runner
 

Similaire à Why Gradle?

Why your build matters
Why your build mattersWhy your build matters
Why your build mattersPeter Ledbrook
 
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13Fred Sauer
 
Gr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx Plugin
Gr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx PluginGr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx Plugin
Gr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx PluginYasuharu Nakano
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldRoberto Pérez Alcolea
 
Faster Java EE Builds with Gradle
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with GradleRyan Cuprak
 
Faster Java EE Builds with Gradle
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with GradleRyan Cuprak
 
OpenDaylight Developer Experience 2.0
 OpenDaylight Developer Experience 2.0 OpenDaylight Developer Experience 2.0
OpenDaylight Developer Experience 2.0Michael Vorburger
 
Moving from Jenkins 1 to 2 declarative pipeline adventures
Moving from Jenkins 1 to 2 declarative pipeline adventuresMoving from Jenkins 1 to 2 declarative pipeline adventures
Moving from Jenkins 1 to 2 declarative pipeline adventuresFrits Van Der Holst
 
Life of a Chromium Developer
Life of a Chromium DeveloperLife of a Chromium Developer
Life of a Chromium Developermpaproductions
 
Eclipse Buildship JUG Hamburg
Eclipse Buildship JUG HamburgEclipse Buildship JUG Hamburg
Eclipse Buildship JUG Hamburgsimonscholz
 
Gitlab and Lingvokot
Gitlab and LingvokotGitlab and Lingvokot
Gitlab and LingvokotLingvokot
 
Adventures in docker compose
Adventures in docker composeAdventures in docker compose
Adventures in docker composeLinkMe Srl
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestSeb Rose
 
Grails beginners workshop
Grails beginners workshopGrails beginners workshop
Grails beginners workshopJacobAae
 
Faster java ee builds with gradle [con4921]
Faster java ee builds with gradle [con4921]Faster java ee builds with gradle [con4921]
Faster java ee builds with gradle [con4921]Ryan Cuprak
 
Flutter vs Java Graphical User Interface Frameworks - text
Flutter vs Java Graphical User Interface Frameworks - textFlutter vs Java Graphical User Interface Frameworks - text
Flutter vs Java Graphical User Interface Frameworks - textToma Velev
 
AOT and Native with Spring Boot 3.0
AOT and Native with Spring Boot 3.0AOT and Native with Spring Boot 3.0
AOT and Native with Spring Boot 3.0MoritzHalbritter
 

Similaire à Why Gradle? (20)

Why your build matters
Why your build mattersWhy your build matters
Why your build matters
 
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
 
Gr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx Plugin
Gr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx PluginGr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx Plugin
Gr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx Plugin
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
Enter the gradle
Enter the gradleEnter the gradle
Enter the gradle
 
Faster Java EE Builds with Gradle
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with Gradle
 
Faster Java EE Builds with Gradle
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with Gradle
 
OpenDaylight Developer Experience 2.0
 OpenDaylight Developer Experience 2.0 OpenDaylight Developer Experience 2.0
OpenDaylight Developer Experience 2.0
 
Moving from Jenkins 1 to 2 declarative pipeline adventures
Moving from Jenkins 1 to 2 declarative pipeline adventuresMoving from Jenkins 1 to 2 declarative pipeline adventures
Moving from Jenkins 1 to 2 declarative pipeline adventures
 
7 maven vsgradle
7 maven vsgradle7 maven vsgradle
7 maven vsgradle
 
Life of a Chromium Developer
Life of a Chromium DeveloperLife of a Chromium Developer
Life of a Chromium Developer
 
Eclipse Buildship JUG Hamburg
Eclipse Buildship JUG HamburgEclipse Buildship JUG Hamburg
Eclipse Buildship JUG Hamburg
 
Gitlab and Lingvokot
Gitlab and LingvokotGitlab and Lingvokot
Gitlab and Lingvokot
 
Adventures in docker compose
Adventures in docker composeAdventures in docker compose
Adventures in docker compose
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under Test
 
Grails beginners workshop
Grails beginners workshopGrails beginners workshop
Grails beginners workshop
 
Faster java ee builds with gradle [con4921]
Faster java ee builds with gradle [con4921]Faster java ee builds with gradle [con4921]
Faster java ee builds with gradle [con4921]
 
Hands on the Gradle
Hands on the GradleHands on the Gradle
Hands on the Gradle
 
Flutter vs Java Graphical User Interface Frameworks - text
Flutter vs Java Graphical User Interface Frameworks - textFlutter vs Java Graphical User Interface Frameworks - text
Flutter vs Java Graphical User Interface Frameworks - text
 
AOT and Native with Spring Boot 3.0
AOT and Native with Spring Boot 3.0AOT and Native with Spring Boot 3.0
AOT and Native with Spring Boot 3.0
 

Plus de Peter Ledbrook

Groovy for Java Developers
Groovy for Java DevelopersGroovy for Java Developers
Groovy for Java DevelopersPeter Ledbrook
 
Application Architectures in Grails
Application Architectures in GrailsApplication Architectures in Grails
Application Architectures in GrailsPeter Ledbrook
 
Open source-and-you-gr8conf-us-2013
Open source-and-you-gr8conf-us-2013Open source-and-you-gr8conf-us-2013
Open source-and-you-gr8conf-us-2013Peter Ledbrook
 
Groovy & Grails for Spring/Java developers
Groovy & Grails for Spring/Java developersGroovy & Grails for Spring/Java developers
Groovy & Grails for Spring/Java developersPeter Ledbrook
 
Grails & the World of Tomorrow
Grails & the World of TomorrowGrails & the World of Tomorrow
Grails & the World of TomorrowPeter Ledbrook
 
Migrating to Cloud Foundry
Migrating to Cloud FoundryMigrating to Cloud Foundry
Migrating to Cloud FoundryPeter Ledbrook
 
Grails and the World of Tomorrow
Grails and the World of TomorrowGrails and the World of Tomorrow
Grails and the World of TomorrowPeter Ledbrook
 
Cloud Foundry for Java devs
Cloud Foundry for Java devsCloud Foundry for Java devs
Cloud Foundry for Java devsPeter Ledbrook
 

Plus de Peter Ledbrook (9)

Groovy for Java Developers
Groovy for Java DevelopersGroovy for Java Developers
Groovy for Java Developers
 
Application Architectures in Grails
Application Architectures in GrailsApplication Architectures in Grails
Application Architectures in Grails
 
Open source-and-you-gr8conf-us-2013
Open source-and-you-gr8conf-us-2013Open source-and-you-gr8conf-us-2013
Open source-and-you-gr8conf-us-2013
 
Groovy & Grails for Spring/Java developers
Groovy & Grails for Spring/Java developersGroovy & Grails for Spring/Java developers
Groovy & Grails for Spring/Java developers
 
Grails & the World of Tomorrow
Grails & the World of TomorrowGrails & the World of Tomorrow
Grails & the World of Tomorrow
 
Migrating to Cloud Foundry
Migrating to Cloud FoundryMigrating to Cloud Foundry
Migrating to Cloud Foundry
 
Grails 2.0 Update
Grails 2.0 UpdateGrails 2.0 Update
Grails 2.0 Update
 
Grails and the World of Tomorrow
Grails and the World of TomorrowGrails and the World of Tomorrow
Grails and the World of Tomorrow
 
Cloud Foundry for Java devs
Cloud Foundry for Java devsCloud Foundry for Java devs
Cloud Foundry for Java devs
 

Dernier

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 

Dernier (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 

Why Gradle?

  • 1. Why Gradle? Peter Ledbrook e: peter@cacoethes.co.uk w: http://www.cacoethes.co.uk t: @pledbrook
  • 2. When did it all begin? • Programmable machines have a long history • Mechanised instruments • Looms Late 18th/early 19th centuries
  • 3. Punched cards First used for looms in 18th Century France - Jacquard Loom 1801 IBM introduced punched card format 1928 - 80 columns! Text mode column width for DOS, Unix etc. Imagine creating by hand Keypunch machines (a little like typewriters) for creating them Errors mean throwing away the card and doing it again Fortran and Cobol started with punched cards
  • 4. Fixing card decks What if your cards are dropped on the floor? This is an IBM 082 Sorter Automation of a very error-prone manual process
  • 5. Magnetism saves the day! Finally, R/W data and code. The dawn of text editors.
  • 7. Make *.c: *.o cc … myapp: app.o mylib.o … ld … + manual custom dependencies Focus mainly on compilation and linking Make has powerful model based on file dependencies Maintenance was a lot of work
  • 8. Make *.c: *.o cc … myapp: app.o mylib.o … ld … What’s this? + manual custom dependencies Tabs were the bane of Make file writers
  • 9. Java • Compiler handles .java to .class dependencies • JAR as ‘module’ unit • Several standard deployment types - Applet - WAR - Standalone app Publish == prod server, installer, JAR, zip package, etc.
  • 10. A standard build Compile Test Package Publish? A simplification from the days of C Interesting point: does the packaging actually require the tests to run?
  • 11. What will builds look like in 5 years time?
  • 12. Our builds last a long time You want a tool that can grow and adapt One that handles all sorts of build processes Even Java builds are evolving
  • 13. Model as a graph Step Step Step Step Step All build processes can be modeled as a Directed Acyclic Graph (DAG) of steps This is the Gradle model (a task == a step)
  • 14. But we don’t want to set up all those steps!
  • 15. Gradle Conventions apply plugin: "java" group = "org.example" version = "0.7.1" sourceCompatibility = "1.7" targetCompatibility = "1.7" Java build conventions provided by plugin
  • 16. Gradle Conventions • compileJava (src/main/java) • compileTestJava (src/test/java) • test (added as dependency of check) - test reports in build/reports/test • jar (added as dependency of assemble) - created in build/libs • javadoc
  • 17. Not all builds are the same
  • 18. Java build evolved Compile Test Package Publish? Dev setup Run QA SCM Tags Deployment Docs Generators JS + CSS Builds are incorporating more and more steps Android is an example of a quite different Java build
  • 19. Custom build publishPdf publishGuide apiDocs fetchGrailsSource grails-doc project expensive, so optional build A build to generate the Grails user guide Automation of all steps No standard tasks Task graph is a suitable model
  • 20. Mixed build C/C++ DLL/SO Java Debian packages Executable Build barrier Build barrier I’ve worked with or know of several projects that have native + Java parts
  • 21. Each transfer between different build systems is like a baton handover - with the potential for the baton to be dropped.
  • 22. The build tool should not dictate the build process
  • 23. Goals of a build What do we want out of our build processes?
  • 24. Automation People are fallible Muscle memory can help e.g. tying shoe laces Not usually applicable in software development
  • 25. Automation • Humans are fallible • Every manual step adds to the fragility of the build • Muscle memory can help, but rarely applicable People are fallible Muscle memory can help e.g. tying shoe laces Not usually applicable in software development
  • 26. Mistakes == Lost time (and possibly money) Errors made deploying to beta.grails.org and grails.org Long path between updating source code and starting the server with changes Stress and downtime
  • 27. Does your build have manual steps? If so, why? For example, copying files around, entering parameter values, running external scripts, etc.
  • 28. Custom tasks in Gradle task publishGuide << { // Generate HTML from .gdoc } build.dependsOn publishGuide buildSrc/src/groovy/pkg/PublishGuideTask.groovy pkg.PublishGuideTask in a JAR
  • 29. Don’t reinvent the wheel http://plugins.gradle.org/ Gradle Plugin Portal This is searchable Contains many (but not all) publicly available plugins You can publish your own too
  • 31. Same inputs should result in same outputs In other words, repeatable builds Environment should not be a factor Does the build behave differently on different platforms? Consider “works for me” with local Maven cache
  • 32. Depends on tasks • Are tasks environment-dependent? • Do system properties or environment variables have an effect? • What about number of cores? • Order of tests? Gradle can’t help much with this - except for task ordering
  • 33. Task ordering • mustRunAfter/shouldRunAfter • No task dependencies task integTest { ... } task packageReports { mustRunAfter integTest ... } `packageReports` does not depend on `integTest` But if both are executed, `packageReports` must come after `integTest` shouldRunAfter is less strict - mostly to optimise feedback
  • 34. Task ordering • finalizedBy • Ensures execution of the finalizer task task integTest { finalizedBy packageReports ... } task packageReports { ... } `packageReports` does not depend on `integTest` If `integTest` runs, then `packageReports` will run too, always after `integTest`
  • 35. Gradle cache • Origin checks • Artifact checksums • Concurrency safe • Avoid mavenLocal()! Dependency cache can be a big impediment to repeatability
  • 36. Resolution strategy configurations.all { resolutionStrategy { failOnVersionConflict() force 'asm:asm-all:3.3.1', 'commons-io:commons-io:1.4' } Override version to use for specific dependencies Fail the build if any version conflicts Defaults to ‘newest’ strategy Fine-grained control over dependency versions Automatic conflict resolution error-prone
  • 37. Resolution strategy configurations.all { eachDependency { details -> if (details.requested.name == 'groovy-all') { details.useTarget( group: details.requested.group, name: 'groovy', version: details.requested.version) } } } Control modules with different names, same classes A painful problem to debug
  • 38. Efficiency Some tasks take significant amounts of time to execute Why run them each time? Think Ant/Maven incremental compilation
  • 39. Incremental build :lazybones-app:compileJava :lazybones-app:compileGroovy UP-TO-DATE :lazybones-app:processResources UP-TO-DATE :lazybones-app:classes UP-TO-DATE :lazybones-app:jar UP-TO-DATE :lazybones-app:startScripts UP-TO-DATE :lazybones-app:installApp UP-TO-DATE BUILD SUCCESSFUL Total time: 2.178 secs UP-TO-DATE Don’t execute tasks you don’t have to
  • 40. Task inputs & outputs class BintrayGenericUpload extends DefaultTask { @InputFile File artifactFile @Input String artifactUrlPath @Optional @Input String repositoryUrl …⋯ } Use of annotations makes task support incremental build Inputs and outputs can be values, files, directories
  • 41. A build should be… Automated Repeatable Efficient
  • 42. On top of this, Gradle gives you • a rich API for modelling your build process • full dependency management • Java ecosystem integration - IDEs, CI, static analysis tools, etc. • Flexible publishing (Maven, Ivy,AWS S3) • Many useful plugins to save you work
  • 43. Summary • End-to-end process is the build • 80-20 rule (80% standard 20% custom) • Automate everything == save time • Invest in build as if it’s part of your code base • Building software requires a rich model
  • 44. Thank you! e: peter@cacoethes.co.uk w: http://www.cacoethes.co.uk t: @pledbrook