SlideShare a Scribd company logo
1 of 39
Download to read offline
ANDRES ALMIRAY
@AALMIRAY
MAKING THE MOST OF
YOUR GRADLE BUILD
DON’T FORGET TO VOTE!
1
HOW TO GET GRADLE
INSTALLED ON YOUR
SYSTEM
$ curl -s get.sdkman.io | bash
$ sdk install gradle
2
INITIALIZING A GRADLE
PROJECT
GRADLE INIT
THIS COMMAND WILL GENERATE A BASIC STRUCTURE
AND A MINIMUM SET OF FILES TO GET STARTED.
YOU CAN INVOKE THIS COMMAND ON A MAVEN PROJECT
TO TURN IT INTO A GRADLE PROJECT. MUST MIGRATE
PLUGINS MANUALLY.
$ sdk install lazybones
$ lazybones create gradle-quickstart
sample
3
FIX GRADLE VERSION TO A
PARTICULAR RELEASE
GRADLE WRAPPER
INITIALIZE THE WRAPPER WITH A GIVEN VERSION.
CHANGE FROM –BIN.ZIP TO –ALL.ZIP TO HAVE ACCESS TO
GRADLE API SOURCES.
4
INVOKING GRADLE
ANYWHERE ON YOUR
PROJECT
GDUB
https://github.com/dougborg/gdub
A SCRIPT THAT CAN INVOKE A GRADLE BUILD ANYWHERE
INSIDE THE PROJECT STRUCTURE.
WILL ATTEMPT RESOLVING WRAPPER FIRST, THEN LOCAL
GRADLE.
FAILS IF NEITHER IS FOUND.
5
MULTI-PROJECT SETUP
CHANGE BUILD FILE NAMES
CHANGE BULD FILE NAME FROM BUILD.GRADLE TO
${PROJECT.NAME}.GRADLE
USE GROOVY EXPRESSIONS TO FACTORIZE PROJECT
INCLUSIONS IN SETTINGS.GRADLE
SETTINGS.GRADLE (1/2)
['common',	
  'full',	
  'light'].each	
  {	
  name	
  -­‐>	
  
	
  	
  	
  	
  File	
  subdir	
  =	
  new	
  File(rootDir,	
  name)	
  
	
  	
  	
  	
  subdir.eachDir	
  {	
  dir	
  -­‐>	
  
	
  	
  	
  	
  	
  	
  	
  	
  File	
  buildFile	
  =	
  new	
  File(dir,	
  "${dir.name}.gradle")	
  
	
  	
  	
  	
  	
  	
  	
  	
  if	
  (buildFile.exists())	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  include	
  "${name}/${dir.name}"	
  
	
  	
  	
  	
  	
  	
  	
  	
  }	
  
	
  	
  	
  	
  }	
  
}	
  
SETTINGS.GRADLE (2/2)
rootProject.name	
  =	
  'my-­‐project'	
  
rootProject.children.each	
  {	
  project	
  -­‐>	
  
	
  	
  	
  	
  int	
  slash	
  =	
  project.name.indexOf('/')	
  
	
  	
  	
  	
  String	
  fileBaseName	
  =	
  project.name[(slash	
  +	
  1)..-­‐1]	
  
	
  	
  	
  	
  String	
  projectDirName	
  =	
  project.name	
  
	
  	
  	
  	
  project.name	
  =	
  fileBaseName	
  
	
  	
  	
  	
  project.projectDir	
  =	
  new	
  File(settingsDir,	
  projectDirName)	
  
	
  	
  	
  	
  project.buildFileName	
  =	
  "${fileBaseName}.gradle"	
  
	
  	
  	
  	
  assert	
  project.projectDir.isDirectory()	
  
	
  	
  	
  	
  assert	
  project.buildFile.isFile()	
  
}	
  
6
BUILD FILE ETIQUETTE
WHAT BUILD.GRADLE IS NOT
KEEP IT DRY
EMBRACE THE POWER OF CONVENTIONS.
BUILD FILE SHOULD DEFINE HOW THE PROJECT DEVIATES
FROM THE PRE-ESTABLISHED CONVENTIONS.
RELY ON SECONDARY SCRIPTS, SEGGREGATED BY
RESPONSIBILITIES.
TASK DEFINITIONS
PUT THEM IN SEPARATE FILES.
1.  INSIDE SECONDARY SCRIPTS
1.  REGULAR TASK DEFINITIONS
2.  PLUGIN DEFINITIONS
2.  AS PART OF buildSrc SOURCES
3.  AS A PLUGIN PROJECT
APPLY PLUGINS
USE THE PLUGINS BLOCK DSL IF IN A SINGLE PROJECT.
PLUGINS BLOCK DOES NOT WORK IN SECONDARY
SCRIPTS.
USE THE OLD-SCHOOL SYNTAX IF IN A MULTI-PROJECT
AND NOT ALL SUBPROJECTS REQUIRE THE SAME
PLUGINS.
7
DON’T REINVENT THE
WHEEL, APPLY PLUGINS
INSTEAD
USEFUL PLUGINS
Versions
id 'com.github.ben-manes.versions' version '0.13.0’
License
id 'com.github.hierynomus.license' version '0.11.0’
Versioning
id 'net.nemerosa.versioning' version '2.4.0'
8
SUPPLY MORE INFORMATION
TO DEVELOPERS
MANIFEST ENTRIES
ENRICH JAR MANIFESTS WITH ADDITIONAL ENTRIES SUCH AS
'Built-By': System.properties['user.name'],
'Created-By': "${System.properties['java.version']} (${System.properties['java.vendor']}
${System.properties['java.vm.version']})".toString(),
'Build-Date': buildDate,
'Build-Time': buildTime,
'Build-Revision': versioning.info.commit,
'Specification-Title': project.name,
'Specification-Version': project.version,
'Specification-Vendor': project.vendor,
'Implementation-Title': project.name,
'Implementation-Version': project.version,
'Implementation-Vendor': project.vendor
9
INCREMENTAL BUILDS
INCREMENTAL BUILD
ACTIVATED BY ADDING –T TO THE COMMAND LINE.
EXECUTES A GIVEN COMMAND WHENEVER ITS
RESOURCES (INPUTS) CHANGE.
AVOID INVOKING THE CLEAN TASK AS MUCH AS YOU CAN.
10
AGGREGATE CODE
COVERAGE REPORTS
JACOCO OR BUST
STEP 1: DEFINE A LIST OF PROJECTS TO INCLUDE
ext	
  {	
  
	
  	
  	
  	
  projectsWithCoverage	
  =	
  []	
  
	
  	
  	
  	
  baseJaCocoDir	
  =	
  "${buildDir}/reports/jacoco/test/"	
  
	
  	
  	
  	
  jacocoMergeExecFile	
  =	
  "${baseJaCocoDir	
  }jacocoTestReport.exec"	
  
	
  	
  	
  	
  jacocoMergeReportHTMLFile	
  =	
  "${baseJaCocoDir	
  }/html/"	
  
	
  	
  	
  	
  jacocoMergeReportXMLFile	
  =	
  "${baseJaCocoDir}/jacocoTestReport.xml"	
  
}	
  
JACOCO OR BUST
STEP 2: ADD PROJECT TO COVERAGE LIST
jacocoTestReport	
  {	
  
	
  	
  	
  	
  group	
  =	
  'Reporting'	
  
	
  	
  	
  	
  description	
  =	
  'Generate	
  Jacoco	
  coverage	
  reports	
  after	
  running	
  tests.'	
  
	
  	
  	
  	
  additionalSourceDirs	
  =	
  project.files(sourceSets.main.allSource.srcDirs)	
  
	
  	
  	
  	
  sourceDirectories	
  =	
  project.files(sourceSets.main.allSource.srcDirs)	
  
	
  	
  	
  	
  classDirectories	
  =	
  project.files(sourceSets.main.output)	
  
	
  	
  	
  	
  reports	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  xml.enabled	
  =	
  true	
  
	
  	
  	
  	
  	
  	
  	
  	
  csv.enabled	
  =	
  false	
  
	
  	
  	
  	
  	
  	
  	
  	
  html.enabled	
  =	
  true	
  
	
  	
  	
  	
  }	
  
}	
  
projectsWithCoverage	
  <<	
  project	
  
JACOCO OR BUST
STEP 3: DEFINE AGGREGATE TASKS IN ROOT PROJECT
evaluationDependsOnChildren()	
  //	
  VERY	
  IMPORTANT!!	
  
	
  
task	
  jacocoRootMerge(type:	
  org.gradle.testing.jacoco.tasks.JacocoMerge)	
  {	
  
	
  	
  	
  	
  dependsOn	
  =	
  projectsWithCoverage.test	
  +	
  
projectsWithCoverage.jacocoTestReport	
  	
  
	
  	
  	
  	
  executionData	
  =	
  projectsWithCoverage.jacocoTestReport.executionData	
  
	
  	
  	
  	
  destinationFile	
  =	
  file(jacocoMergeExecFile)	
  
}	
  
JACOCO OR BUST
STEP 3: DEFINE AGGREGATE TASKS IN ROOT PROJECT
task	
  jacocoRootMergeReport(dependsOn:	
  jacocoRootMerge,	
  type:	
  JacocoReport)	
  {	
  
	
  	
  	
  	
  executionData	
  projectsWithCoverage.jacocoTestReport.executionData	
  
	
  	
  	
  	
  sourceDirectories	
  =	
  projectsWithCoverage.sourceSets.main.allSource.srcDirs	
  
	
  	
  	
  	
  classDirectories	
  =	
  projectsWithCoverage.sourceSets.main.output	
  
	
  
	
  	
  	
  	
  reports	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  html.enabled	
  =	
  true	
  
	
  	
  	
  	
  	
  	
  	
  	
  xml.enabled	
  =	
  true	
  
	
  	
  	
  	
  	
  	
  	
  	
  html.destination	
  =	
  file(jacocoMergeReportHTMLFile)	
  
	
  	
  	
  	
  	
  	
  	
  	
  xml.destination	
  =	
  file(jacocoMergeReportXMLFile)	
  
	
  	
  	
  	
  }	
  
}	
  
11
PLUGINS! PLUGINS!
PLUGINS!
license
versions
stats
bintray
shadow
izpack
java2html
git
coveralls
asciidoctor
jbake
markdown
livereload
gretty
nexus
watch
wuff
spawn
versioning
pitest
build-time-tracker
semantic-release
clirr
japicmp
compass
flyway
jmh
macappbundle
osspackage
jnlp
spotless
dependency-
management
sshoogr
THANK YOU!
ANDRES ALMIRAY
@AALMIRAY

More Related Content

What's hot

Revolution or Evolution in Page Object
Revolution or Evolution in Page ObjectRevolution or Evolution in Page Object
Revolution or Evolution in Page ObjectArtem Sokovets
 
Java(ee) mongo db applications in the cloud
Java(ee) mongo db applications in the cloud Java(ee) mongo db applications in the cloud
Java(ee) mongo db applications in the cloud Shekhar Gulati
 
Retrofit
RetrofitRetrofit
Retrofitbresiu
 
Contract-driven development with OpenAPI 3 and Vert.x | DevNation Tech Talk
Contract-driven development with OpenAPI 3 and Vert.x | DevNation Tech TalkContract-driven development with OpenAPI 3 and Vert.x | DevNation Tech Talk
Contract-driven development with OpenAPI 3 and Vert.x | DevNation Tech TalkRed Hat Developers
 
Building domain-specific testing tools : lessons learned from the Apache Slin...
Building domain-specific testing tools : lessons learned from the Apache Slin...Building domain-specific testing tools : lessons learned from the Apache Slin...
Building domain-specific testing tools : lessons learned from the Apache Slin...Robert Munteanu
 
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?Srijan Technologies
 
SymfonyCon Berlin 2016 Jenkins Deployment Pipelines
SymfonyCon Berlin 2016 Jenkins Deployment PipelinesSymfonyCon Berlin 2016 Jenkins Deployment Pipelines
SymfonyCon Berlin 2016 Jenkins Deployment Pipelinescpsitgmbh
 
Java EE 6 CDI Integrates with Spring & JSF
Java EE 6 CDI Integrates with Spring & JSFJava EE 6 CDI Integrates with Spring & JSF
Java EE 6 CDI Integrates with Spring & JSFJiayun Zhou
 
The world of gradle - an introduction for developers
The world of gradle  - an introduction for developersThe world of gradle  - an introduction for developers
The world of gradle - an introduction for developersTricode (part of Dept)
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API07.pallav
 
Arquillian Constellation
Arquillian ConstellationArquillian Constellation
Arquillian ConstellationAlex Soto
 
Spring boot Introduction
Spring boot IntroductionSpring boot Introduction
Spring boot IntroductionJeevesh Pandey
 
Java Play Restful JPA
Java Play Restful JPAJava Play Restful JPA
Java Play Restful JPAFaren faren
 
Java Play RESTful ebean
Java Play RESTful ebeanJava Play RESTful ebean
Java Play RESTful ebeanFaren faren
 
Retrofit library for android
Retrofit library for androidRetrofit library for android
Retrofit library for androidInnovationM
 
An introduction to maven gradle and sbt
An introduction to maven gradle and sbtAn introduction to maven gradle and sbt
An introduction to maven gradle and sbtFabio Fumarola
 

What's hot (20)

Revolution or Evolution in Page Object
Revolution or Evolution in Page ObjectRevolution or Evolution in Page Object
Revolution or Evolution in Page Object
 
Java(ee) mongo db applications in the cloud
Java(ee) mongo db applications in the cloud Java(ee) mongo db applications in the cloud
Java(ee) mongo db applications in the cloud
 
Retrofit
RetrofitRetrofit
Retrofit
 
Contract-driven development with OpenAPI 3 and Vert.x | DevNation Tech Talk
Contract-driven development with OpenAPI 3 and Vert.x | DevNation Tech TalkContract-driven development with OpenAPI 3 and Vert.x | DevNation Tech Talk
Contract-driven development with OpenAPI 3 and Vert.x | DevNation Tech Talk
 
Building domain-specific testing tools : lessons learned from the Apache Slin...
Building domain-specific testing tools : lessons learned from the Apache Slin...Building domain-specific testing tools : lessons learned from the Apache Slin...
Building domain-specific testing tools : lessons learned from the Apache Slin...
 
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
[Srijan Wednesday Webinar] Rails 5: What's in It for Me?
 
Retrofit
RetrofitRetrofit
Retrofit
 
SymfonyCon Berlin 2016 Jenkins Deployment Pipelines
SymfonyCon Berlin 2016 Jenkins Deployment PipelinesSymfonyCon Berlin 2016 Jenkins Deployment Pipelines
SymfonyCon Berlin 2016 Jenkins Deployment Pipelines
 
Springを用いた社内ライブラリ開発
Springを用いた社内ライブラリ開発Springを用いた社内ライブラリ開発
Springを用いた社内ライブラリ開発
 
Java EE 6 CDI Integrates with Spring & JSF
Java EE 6 CDI Integrates with Spring & JSFJava EE 6 CDI Integrates with Spring & JSF
Java EE 6 CDI Integrates with Spring & JSF
 
The JavaFX Ecosystem
The JavaFX EcosystemThe JavaFX Ecosystem
The JavaFX Ecosystem
 
The world of gradle - an introduction for developers
The world of gradle  - an introduction for developersThe world of gradle  - an introduction for developers
The world of gradle - an introduction for developers
 
Gradle Introduction
Gradle IntroductionGradle Introduction
Gradle Introduction
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API
 
Arquillian Constellation
Arquillian ConstellationArquillian Constellation
Arquillian Constellation
 
Spring boot Introduction
Spring boot IntroductionSpring boot Introduction
Spring boot Introduction
 
Java Play Restful JPA
Java Play Restful JPAJava Play Restful JPA
Java Play Restful JPA
 
Java Play RESTful ebean
Java Play RESTful ebeanJava Play RESTful ebean
Java Play RESTful ebean
 
Retrofit library for android
Retrofit library for androidRetrofit library for android
Retrofit library for android
 
An introduction to maven gradle and sbt
An introduction to maven gradle and sbtAn introduction to maven gradle and sbt
An introduction to maven gradle and sbt
 

Viewers also liked

Gr8conf - The Groovy Ecosystem Revisited
Gr8conf - The Groovy Ecosystem RevisitedGr8conf - The Groovy Ecosystem Revisited
Gr8conf - The Groovy Ecosystem RevisitedAndres Almiray
 
Greach - The Groovy Ecosystem
Greach - The Groovy EcosystemGreach - The Groovy Ecosystem
Greach - The Groovy EcosystemAndres Almiray
 
Griffon: what's new and what's coming
Griffon: what's new and what's comingGriffon: what's new and what's coming
Griffon: what's new and what's comingAndres Almiray
 
Gradle Glam: Plugis Galore
Gradle Glam: Plugis GaloreGradle Glam: Plugis Galore
Gradle Glam: Plugis GaloreAndres Almiray
 
Gradle Glam: Plugis Strike Back
Gradle Glam: Plugis Strike BackGradle Glam: Plugis Strike Back
Gradle Glam: Plugis Strike BackAndres Almiray
 
Asciidoctor, because documentation does not have to suck
Asciidoctor, because documentation does not have to suckAsciidoctor, because documentation does not have to suck
Asciidoctor, because documentation does not have to suckAndres Almiray
 
Machine Learning for Developers
Machine Learning for DevelopersMachine Learning for Developers
Machine Learning for DevelopersDanilo Poccia
 
awesome groovy
awesome groovyawesome groovy
awesome groovyPaul King
 
Get Value from Your Data
Get Value from Your DataGet Value from Your Data
Get Value from Your DataDanilo Poccia
 
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Mario Fusco
 
vJUG - The JavaFX Ecosystem
vJUG - The JavaFX EcosystemvJUG - The JavaFX Ecosystem
vJUG - The JavaFX EcosystemAndres Almiray
 
Real World Event Sourcing and CQRS
Real World Event Sourcing and CQRSReal World Event Sourcing and CQRS
Real World Event Sourcing and CQRSMatthew Hawkins
 
Gradle: Harder, Stronger, Better, Faster
Gradle: Harder, Stronger, Better, FasterGradle: Harder, Stronger, Better, Faster
Gradle: Harder, Stronger, Better, FasterAndres Almiray
 
Developing microservices with aggregates (devnexus2017)
Developing microservices with aggregates (devnexus2017)Developing microservices with aggregates (devnexus2017)
Developing microservices with aggregates (devnexus2017)Chris Richardson
 
There is no such thing as a microservice! (oracle code nyc)
There is no such thing as a microservice! (oracle code nyc)There is no such thing as a microservice! (oracle code nyc)
There is no such thing as a microservice! (oracle code nyc)Chris Richardson
 
Developing event-driven microservices with event sourcing and CQRS (svcc, sv...
Developing event-driven microservices with event sourcing and CQRS  (svcc, sv...Developing event-driven microservices with event sourcing and CQRS  (svcc, sv...
Developing event-driven microservices with event sourcing and CQRS (svcc, sv...Chris Richardson
 

Viewers also liked (16)

Gr8conf - The Groovy Ecosystem Revisited
Gr8conf - The Groovy Ecosystem RevisitedGr8conf - The Groovy Ecosystem Revisited
Gr8conf - The Groovy Ecosystem Revisited
 
Greach - The Groovy Ecosystem
Greach - The Groovy EcosystemGreach - The Groovy Ecosystem
Greach - The Groovy Ecosystem
 
Griffon: what's new and what's coming
Griffon: what's new and what's comingGriffon: what's new and what's coming
Griffon: what's new and what's coming
 
Gradle Glam: Plugis Galore
Gradle Glam: Plugis GaloreGradle Glam: Plugis Galore
Gradle Glam: Plugis Galore
 
Gradle Glam: Plugis Strike Back
Gradle Glam: Plugis Strike BackGradle Glam: Plugis Strike Back
Gradle Glam: Plugis Strike Back
 
Asciidoctor, because documentation does not have to suck
Asciidoctor, because documentation does not have to suckAsciidoctor, because documentation does not have to suck
Asciidoctor, because documentation does not have to suck
 
Machine Learning for Developers
Machine Learning for DevelopersMachine Learning for Developers
Machine Learning for Developers
 
awesome groovy
awesome groovyawesome groovy
awesome groovy
 
Get Value from Your Data
Get Value from Your DataGet Value from Your Data
Get Value from Your Data
 
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...
 
vJUG - The JavaFX Ecosystem
vJUG - The JavaFX EcosystemvJUG - The JavaFX Ecosystem
vJUG - The JavaFX Ecosystem
 
Real World Event Sourcing and CQRS
Real World Event Sourcing and CQRSReal World Event Sourcing and CQRS
Real World Event Sourcing and CQRS
 
Gradle: Harder, Stronger, Better, Faster
Gradle: Harder, Stronger, Better, FasterGradle: Harder, Stronger, Better, Faster
Gradle: Harder, Stronger, Better, Faster
 
Developing microservices with aggregates (devnexus2017)
Developing microservices with aggregates (devnexus2017)Developing microservices with aggregates (devnexus2017)
Developing microservices with aggregates (devnexus2017)
 
There is no such thing as a microservice! (oracle code nyc)
There is no such thing as a microservice! (oracle code nyc)There is no such thing as a microservice! (oracle code nyc)
There is no such thing as a microservice! (oracle code nyc)
 
Developing event-driven microservices with event sourcing and CQRS (svcc, sv...
Developing event-driven microservices with event sourcing and CQRS  (svcc, sv...Developing event-driven microservices with event sourcing and CQRS  (svcc, sv...
Developing event-driven microservices with event sourcing and CQRS (svcc, sv...
 

Similar to Making the Most of Your Gradle Build

Making the most of your gradle build - Gr8Conf 2017
Making the most of your gradle build - Gr8Conf 2017Making the most of your gradle build - Gr8Conf 2017
Making the most of your gradle build - Gr8Conf 2017Andres Almiray
 
Making the most of your gradle build - Greach 2017
Making the most of your gradle build - Greach 2017Making the most of your gradle build - Greach 2017
Making the most of your gradle build - Greach 2017Andres Almiray
 
Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingSchalk Cronjé
 
Andres Almiray - Gradle Ex Machina - Codemotion Rome 2019
Andres Almiray - Gradle Ex Machina - Codemotion Rome 2019Andres Almiray - Gradle Ex Machina - Codemotion Rome 2019
Andres Almiray - Gradle Ex Machina - Codemotion Rome 2019Codemotion
 
Idiomatic gradle plugin writing
Idiomatic gradle plugin writingIdiomatic gradle plugin writing
Idiomatic gradle plugin writingSchalk Cronjé
 
Making the most of your gradle build - vJUG24 2017
Making the most of your gradle build - vJUG24 2017Making the most of your gradle build - vJUG24 2017
Making the most of your gradle build - vJUG24 2017Andres Almiray
 
Making the most of your gradle build - BaselOne 2017
Making the most of your gradle build - BaselOne 2017Making the most of your gradle build - BaselOne 2017
Making the most of your gradle build - BaselOne 2017Andres Almiray
 
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
 
Basic Gradle Plugin Writing
Basic Gradle Plugin WritingBasic Gradle Plugin Writing
Basic Gradle Plugin WritingSchalk Cronjé
 
Gradleintroduction 111010130329-phpapp01
Gradleintroduction 111010130329-phpapp01Gradleintroduction 111010130329-phpapp01
Gradleintroduction 111010130329-phpapp01Tino Isnich
 
Gradle: The Build system you have been waiting for
Gradle: The Build system you have been waiting forGradle: The Build system you have been waiting for
Gradle: The Build system you have been waiting forCorneil du Plessis
 
Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingSchalk Cronjé
 
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
 
Mastering Grails 3 Plugins - G3 Summit 2016
Mastering Grails 3 Plugins - G3 Summit 2016Mastering Grails 3 Plugins - G3 Summit 2016
Mastering Grails 3 Plugins - G3 Summit 2016Alvaro Sanchez-Mariscal
 
Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingSchalk Cronjé
 
10 Cool Facts about Gradle
10 Cool Facts about Gradle10 Cool Facts about Gradle
10 Cool Facts about GradleEvgeny Goldin
 

Similar to Making the Most of Your Gradle Build (20)

Making the most of your gradle build - Gr8Conf 2017
Making the most of your gradle build - Gr8Conf 2017Making the most of your gradle build - Gr8Conf 2017
Making the most of your gradle build - Gr8Conf 2017
 
Making the most of your gradle build - Greach 2017
Making the most of your gradle build - Greach 2017Making the most of your gradle build - Greach 2017
Making the most of your gradle build - Greach 2017
 
Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin Writing
 
GradleFX
GradleFXGradleFX
GradleFX
 
Andres Almiray - Gradle Ex Machina - Codemotion Rome 2019
Andres Almiray - Gradle Ex Machina - Codemotion Rome 2019Andres Almiray - Gradle Ex Machina - Codemotion Rome 2019
Andres Almiray - Gradle Ex Machina - Codemotion Rome 2019
 
Gradle ex-machina
Gradle ex-machinaGradle ex-machina
Gradle ex-machina
 
Idiomatic gradle plugin writing
Idiomatic gradle plugin writingIdiomatic gradle plugin writing
Idiomatic gradle plugin writing
 
Making the most of your gradle build - vJUG24 2017
Making the most of your gradle build - vJUG24 2017Making the most of your gradle build - vJUG24 2017
Making the most of your gradle build - vJUG24 2017
 
Making the most of your gradle build - BaselOne 2017
Making the most of your gradle build - BaselOne 2017Making the most of your gradle build - BaselOne 2017
Making the most of your gradle build - BaselOne 2017
 
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
 
Basic Gradle Plugin Writing
Basic Gradle Plugin WritingBasic Gradle Plugin Writing
Basic Gradle Plugin Writing
 
Gradle how to's
Gradle how to'sGradle how to's
Gradle how to's
 
Gradleintroduction 111010130329-phpapp01
Gradleintroduction 111010130329-phpapp01Gradleintroduction 111010130329-phpapp01
Gradleintroduction 111010130329-phpapp01
 
Gradle: The Build system you have been waiting for
Gradle: The Build system you have been waiting forGradle: The Build system you have been waiting for
Gradle: The Build system you have been waiting for
 
Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin Writing
 
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]
 
Mastering Grails 3 Plugins - G3 Summit 2016
Mastering Grails 3 Plugins - G3 Summit 2016Mastering Grails 3 Plugins - G3 Summit 2016
Mastering Grails 3 Plugins - G3 Summit 2016
 
Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin Writing
 
10 Cool Facts about Gradle
10 Cool Facts about Gradle10 Cool Facts about Gradle
10 Cool Facts about Gradle
 

More from Andres Almiray

Creando, creciendo, y manteniendo una comunidad de codigo abierto
Creando, creciendo, y manteniendo una comunidad de codigo abiertoCreando, creciendo, y manteniendo una comunidad de codigo abierto
Creando, creciendo, y manteniendo una comunidad de codigo abiertoAndres Almiray
 
Liberando a produccion con confianza
Liberando a produccion con confianzaLiberando a produccion con confianza
Liberando a produccion con confianzaAndres Almiray
 
Liberando a produccion con confidencia
Liberando a produccion con confidenciaLiberando a produccion con confidencia
Liberando a produccion con confidenciaAndres Almiray
 
OracleDB Ecosystem for Java Developers
OracleDB Ecosystem for Java DevelopersOracleDB Ecosystem for Java Developers
OracleDB Ecosystem for Java DevelopersAndres Almiray
 
Softcon.ph - Maven Puzzlers
Softcon.ph - Maven PuzzlersSoftcon.ph - Maven Puzzlers
Softcon.ph - Maven PuzzlersAndres Almiray
 
Oracle Database Ecosystem for Java Developers
Oracle Database Ecosystem for Java DevelopersOracle Database Ecosystem for Java Developers
Oracle Database Ecosystem for Java DevelopersAndres Almiray
 
JReleaser - Releasing at the speed of light
JReleaser - Releasing at the speed of lightJReleaser - Releasing at the speed of light
JReleaser - Releasing at the speed of lightAndres Almiray
 
Building modular applications with the Java Platform Module System and Layrry
Building modular applications with the Java Platform Module System and LayrryBuilding modular applications with the Java Platform Module System and Layrry
Building modular applications with the Java Platform Module System and LayrryAndres Almiray
 
Going Reactive with g rpc
Going Reactive with g rpcGoing Reactive with g rpc
Going Reactive with g rpcAndres Almiray
 
Building modular applications with JPMS and Layrry
Building modular applications with JPMS and LayrryBuilding modular applications with JPMS and Layrry
Building modular applications with JPMS and LayrryAndres Almiray
 
Taking Micronaut out for a spin
Taking Micronaut out for a spinTaking Micronaut out for a spin
Taking Micronaut out for a spinAndres Almiray
 
Apache Groovy's Metaprogramming Options and You
Apache Groovy's Metaprogramming Options and YouApache Groovy's Metaprogramming Options and You
Apache Groovy's Metaprogramming Options and YouAndres Almiray
 
What I wish I knew about Maven years ago
What I wish I knew about Maven years agoWhat I wish I knew about Maven years ago
What I wish I knew about Maven years agoAndres Almiray
 
What I wish I knew about maven years ago
What I wish I knew about maven years agoWhat I wish I knew about maven years ago
What I wish I knew about maven years agoAndres Almiray
 
The impact of sci fi in tech
The impact of sci fi in techThe impact of sci fi in tech
The impact of sci fi in techAndres Almiray
 
Gradle Ex Machina - Devoxx 2019
Gradle Ex Machina - Devoxx 2019Gradle Ex Machina - Devoxx 2019
Gradle Ex Machina - Devoxx 2019Andres Almiray
 
Creating Better Builds with Gradle
Creating Better Builds with GradleCreating Better Builds with Gradle
Creating Better Builds with GradleAndres Almiray
 
Interacting with the Oracle Cloud Java SDK with Gradle
Interacting with the Oracle Cloud Java SDK with GradleInteracting with the Oracle Cloud Java SDK with Gradle
Interacting with the Oracle Cloud Java SDK with GradleAndres Almiray
 

More from Andres Almiray (20)

Creando, creciendo, y manteniendo una comunidad de codigo abierto
Creando, creciendo, y manteniendo una comunidad de codigo abiertoCreando, creciendo, y manteniendo una comunidad de codigo abierto
Creando, creciendo, y manteniendo una comunidad de codigo abierto
 
Liberando a produccion con confianza
Liberando a produccion con confianzaLiberando a produccion con confianza
Liberando a produccion con confianza
 
Liberando a produccion con confidencia
Liberando a produccion con confidenciaLiberando a produccion con confidencia
Liberando a produccion con confidencia
 
OracleDB Ecosystem for Java Developers
OracleDB Ecosystem for Java DevelopersOracleDB Ecosystem for Java Developers
OracleDB Ecosystem for Java Developers
 
Softcon.ph - Maven Puzzlers
Softcon.ph - Maven PuzzlersSoftcon.ph - Maven Puzzlers
Softcon.ph - Maven Puzzlers
 
Maven Puzzlers
Maven PuzzlersMaven Puzzlers
Maven Puzzlers
 
Oracle Database Ecosystem for Java Developers
Oracle Database Ecosystem for Java DevelopersOracle Database Ecosystem for Java Developers
Oracle Database Ecosystem for Java Developers
 
JReleaser - Releasing at the speed of light
JReleaser - Releasing at the speed of lightJReleaser - Releasing at the speed of light
JReleaser - Releasing at the speed of light
 
Building modular applications with the Java Platform Module System and Layrry
Building modular applications with the Java Platform Module System and LayrryBuilding modular applications with the Java Platform Module System and Layrry
Building modular applications with the Java Platform Module System and Layrry
 
Going Reactive with g rpc
Going Reactive with g rpcGoing Reactive with g rpc
Going Reactive with g rpc
 
Building modular applications with JPMS and Layrry
Building modular applications with JPMS and LayrryBuilding modular applications with JPMS and Layrry
Building modular applications with JPMS and Layrry
 
Taking Micronaut out for a spin
Taking Micronaut out for a spinTaking Micronaut out for a spin
Taking Micronaut out for a spin
 
Apache Groovy's Metaprogramming Options and You
Apache Groovy's Metaprogramming Options and YouApache Groovy's Metaprogramming Options and You
Apache Groovy's Metaprogramming Options and You
 
What I wish I knew about Maven years ago
What I wish I knew about Maven years agoWhat I wish I knew about Maven years ago
What I wish I knew about Maven years ago
 
What I wish I knew about maven years ago
What I wish I knew about maven years agoWhat I wish I knew about maven years ago
What I wish I knew about maven years ago
 
The impact of sci fi in tech
The impact of sci fi in techThe impact of sci fi in tech
The impact of sci fi in tech
 
Gradle Ex Machina - Devoxx 2019
Gradle Ex Machina - Devoxx 2019Gradle Ex Machina - Devoxx 2019
Gradle Ex Machina - Devoxx 2019
 
Creating Better Builds with Gradle
Creating Better Builds with GradleCreating Better Builds with Gradle
Creating Better Builds with Gradle
 
Interacting with the Oracle Cloud Java SDK with Gradle
Interacting with the Oracle Cloud Java SDK with GradleInteracting with the Oracle Cloud Java SDK with Gradle
Interacting with the Oracle Cloud Java SDK with Gradle
 
Go Java, Go!
Go Java, Go!Go Java, Go!
Go Java, Go!
 

Recently uploaded

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
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
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
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
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

Making the Most of Your Gradle Build

  • 1. ANDRES ALMIRAY @AALMIRAY MAKING THE MOST OF YOUR GRADLE BUILD
  • 2.
  • 3.
  • 5. 1 HOW TO GET GRADLE INSTALLED ON YOUR SYSTEM
  • 6. $ curl -s get.sdkman.io | bash $ sdk install gradle
  • 8. GRADLE INIT THIS COMMAND WILL GENERATE A BASIC STRUCTURE AND A MINIMUM SET OF FILES TO GET STARTED. YOU CAN INVOKE THIS COMMAND ON A MAVEN PROJECT TO TURN IT INTO A GRADLE PROJECT. MUST MIGRATE PLUGINS MANUALLY.
  • 9. $ sdk install lazybones $ lazybones create gradle-quickstart sample
  • 10. 3 FIX GRADLE VERSION TO A PARTICULAR RELEASE
  • 11. GRADLE WRAPPER INITIALIZE THE WRAPPER WITH A GIVEN VERSION. CHANGE FROM –BIN.ZIP TO –ALL.ZIP TO HAVE ACCESS TO GRADLE API SOURCES.
  • 13. GDUB https://github.com/dougborg/gdub A SCRIPT THAT CAN INVOKE A GRADLE BUILD ANYWHERE INSIDE THE PROJECT STRUCTURE. WILL ATTEMPT RESOLVING WRAPPER FIRST, THEN LOCAL GRADLE. FAILS IF NEITHER IS FOUND.
  • 15. CHANGE BUILD FILE NAMES CHANGE BULD FILE NAME FROM BUILD.GRADLE TO ${PROJECT.NAME}.GRADLE USE GROOVY EXPRESSIONS TO FACTORIZE PROJECT INCLUSIONS IN SETTINGS.GRADLE
  • 16. SETTINGS.GRADLE (1/2) ['common',  'full',  'light'].each  {  name  -­‐>          File  subdir  =  new  File(rootDir,  name)          subdir.eachDir  {  dir  -­‐>                  File  buildFile  =  new  File(dir,  "${dir.name}.gradle")                  if  (buildFile.exists())  {                          include  "${name}/${dir.name}"                  }          }   }  
  • 17. SETTINGS.GRADLE (2/2) rootProject.name  =  'my-­‐project'   rootProject.children.each  {  project  -­‐>          int  slash  =  project.name.indexOf('/')          String  fileBaseName  =  project.name[(slash  +  1)..-­‐1]          String  projectDirName  =  project.name          project.name  =  fileBaseName          project.projectDir  =  new  File(settingsDir,  projectDirName)          project.buildFileName  =  "${fileBaseName}.gradle"          assert  project.projectDir.isDirectory()          assert  project.buildFile.isFile()   }  
  • 20. KEEP IT DRY EMBRACE THE POWER OF CONVENTIONS. BUILD FILE SHOULD DEFINE HOW THE PROJECT DEVIATES FROM THE PRE-ESTABLISHED CONVENTIONS. RELY ON SECONDARY SCRIPTS, SEGGREGATED BY RESPONSIBILITIES.
  • 21. TASK DEFINITIONS PUT THEM IN SEPARATE FILES. 1.  INSIDE SECONDARY SCRIPTS 1.  REGULAR TASK DEFINITIONS 2.  PLUGIN DEFINITIONS 2.  AS PART OF buildSrc SOURCES 3.  AS A PLUGIN PROJECT
  • 22. APPLY PLUGINS USE THE PLUGINS BLOCK DSL IF IN A SINGLE PROJECT. PLUGINS BLOCK DOES NOT WORK IN SECONDARY SCRIPTS. USE THE OLD-SCHOOL SYNTAX IF IN A MULTI-PROJECT AND NOT ALL SUBPROJECTS REQUIRE THE SAME PLUGINS.
  • 23. 7 DON’T REINVENT THE WHEEL, APPLY PLUGINS INSTEAD
  • 24. USEFUL PLUGINS Versions id 'com.github.ben-manes.versions' version '0.13.0’ License id 'com.github.hierynomus.license' version '0.11.0’ Versioning id 'net.nemerosa.versioning' version '2.4.0'
  • 25.
  • 27. MANIFEST ENTRIES ENRICH JAR MANIFESTS WITH ADDITIONAL ENTRIES SUCH AS 'Built-By': System.properties['user.name'], 'Created-By': "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})".toString(), 'Build-Date': buildDate, 'Build-Time': buildTime, 'Build-Revision': versioning.info.commit, 'Specification-Title': project.name, 'Specification-Version': project.version, 'Specification-Vendor': project.vendor, 'Implementation-Title': project.name, 'Implementation-Version': project.version, 'Implementation-Vendor': project.vendor
  • 29. INCREMENTAL BUILD ACTIVATED BY ADDING –T TO THE COMMAND LINE. EXECUTES A GIVEN COMMAND WHENEVER ITS RESOURCES (INPUTS) CHANGE. AVOID INVOKING THE CLEAN TASK AS MUCH AS YOU CAN.
  • 31. JACOCO OR BUST STEP 1: DEFINE A LIST OF PROJECTS TO INCLUDE ext  {          projectsWithCoverage  =  []          baseJaCocoDir  =  "${buildDir}/reports/jacoco/test/"          jacocoMergeExecFile  =  "${baseJaCocoDir  }jacocoTestReport.exec"          jacocoMergeReportHTMLFile  =  "${baseJaCocoDir  }/html/"          jacocoMergeReportXMLFile  =  "${baseJaCocoDir}/jacocoTestReport.xml"   }  
  • 32. JACOCO OR BUST STEP 2: ADD PROJECT TO COVERAGE LIST jacocoTestReport  {          group  =  'Reporting'          description  =  'Generate  Jacoco  coverage  reports  after  running  tests.'          additionalSourceDirs  =  project.files(sourceSets.main.allSource.srcDirs)          sourceDirectories  =  project.files(sourceSets.main.allSource.srcDirs)          classDirectories  =  project.files(sourceSets.main.output)          reports  {                  xml.enabled  =  true                  csv.enabled  =  false                  html.enabled  =  true          }   }   projectsWithCoverage  <<  project  
  • 33. JACOCO OR BUST STEP 3: DEFINE AGGREGATE TASKS IN ROOT PROJECT evaluationDependsOnChildren()  //  VERY  IMPORTANT!!     task  jacocoRootMerge(type:  org.gradle.testing.jacoco.tasks.JacocoMerge)  {          dependsOn  =  projectsWithCoverage.test  +   projectsWithCoverage.jacocoTestReport            executionData  =  projectsWithCoverage.jacocoTestReport.executionData          destinationFile  =  file(jacocoMergeExecFile)   }  
  • 34. JACOCO OR BUST STEP 3: DEFINE AGGREGATE TASKS IN ROOT PROJECT task  jacocoRootMergeReport(dependsOn:  jacocoRootMerge,  type:  JacocoReport)  {          executionData  projectsWithCoverage.jacocoTestReport.executionData          sourceDirectories  =  projectsWithCoverage.sourceSets.main.allSource.srcDirs          classDirectories  =  projectsWithCoverage.sourceSets.main.output            reports  {                  html.enabled  =  true                  xml.enabled  =  true                  html.destination  =  file(jacocoMergeReportHTMLFile)                  xml.destination  =  file(jacocoMergeReportXMLFile)          }   }  
  • 38.