GRADLE
EX
MACHINA
ANDRES ALMIRAY
@AALMIRAY
@aalmiray
@aalmiray
@aalmiray
POM.XML
• POM stands for Project Object Model.
• A POM file defines both how a project should be built and how
consumers may interact with the published artifacts.
• Maven delivers lots of features out of the box thanks to the
hierarchical nature of the POM.
• The Maven Super POM provides default configuration for
common plugins such as compiler, resources, surefire, etc.
• The strict nature of the structure found in the POM allows
anyone to understand the configuration.
@aalmiray
@aalmiray
BUILD.GRADLE
• Gradle build files only specify how projects should be built.
• The definition for consumers is delivered through a generated
POM file.
• Gradle builds are highly customizable, resulting in a wider
range of build patterns.
CAN WE HAVE A
MAVEN-LIKE
STRUCTURE ON TOP
OF GRADLE?
HTTP://GITHUB.COM/AALMIRAY/KORDAMP-GRADLE-PLUGINS
HTTPS://AALMIRAY.GITHUB.IO/KORDAMP-GRADLE-PLUGINS
FILE
STRUCTURE
@aalmiray
STANDARD (MAVEN)
.
├── pom.xml
├── guide
│ └── pom.xml
├── project1
│ └── pom.xml
└── project2
└── pom.xml
@aalmiray
STANDARD (MAVEN)
<project>
<groupId>com.acme</groupId>
<artifactId>parent</artifactId>
<version>0.0.0</version>
<modules>
<module>guide</module>
<module>project1</module>
<module>project2</module>
</modules>
</project>
<project>
<parent>
<groupId>com.acme</groupId>
<artifactId>parent</artifactId>
<version>0.0.0</version>
</parent>
</project>
@aalmiray
TWO-LEVEL (MAVEN)
.
├── pom.xml
├── docs
│ └── guide
│ └── pom.xml
└── subprojects
├── project1
│ └── pom.xml
└── project2
└── pom.xml
@aalmiray
TWO-LEVEL (MAVEN)
<project>
<groupId>com.acme</groupId>
<artifactId>parent</artifactId>
<version>0.0.0</version>
<modules>
<module>docs/guide</module>
<module>subprojects/project2</module>
<module>subprojects/project3</module>
</modules>
</project>
<project>
<parent>
<groupId>com.acme</groupId>
<artifactId>parent</artifactId>
<version>0.0.0</version>
<path>../../pom.xml</path>
</parent>
</project>
@aalmiray
MULTI-LEVEL (MAVEN)
.
├── pom.xml
├── guide
│ └── pom.xml
└── subprojects
├── project1
│ └── pom.xml
└── project2
└── pom.xml
@aalmiray
MULTI-LEVEL (MAVEN)
<project>
<groupId>com.acme</groupId>
<artifactId>parent</artifactId>
<version>0.0.0</version>
<modules>
<module>project1</module>
<module>subprojects/project2</module>
<module>subprojects/project3</module>
</modules>
</project>
<project>
<parent>
<groupId>com.acme</groupId>
<artifactId>parent</artifactId>
<version>0.0.0</version>
</parent>
</project>
<project>
<parent>
<groupId>com.acme</groupId>
<artifactId>parent</artifactId>
<version>0.0.0</version>
<path>../../pom.xml</path>
</parent>
</project>
@aalmiray
STANDARD (GRADLE)
.
├── build.gradle
├── guide
│ └── build.gradle
├── project1
│ └── build.gradle
├── project2
│ └── build.gradle
└── settings.gradle
.
├── build.gradle
├── guide
│ └── guide.gradle
├── project1
│ └── project1.gradle
├── project2
│ └── project2.gradle
└── settings.gradle
@aalmiray
STANDARD (GRADLE)
$ cat settings.gradle
include 'guide'
include 'project1'
include 'project2'
$ cat settings.gradle
include 'guide'
include 'project1'
include 'project2’
project(':guide').buildFileName =
'guide.gradle'
project(':project1').buildFileName =
'project1.gradle'
project(':project2').buildFileName =
'project2.gradle'
@aalmiray
STANDARD (GRADLE)
$ cat settings.gradle
buildscript {
repositories {
gradlePluginPortal()
}
dependencies {
classpath 'org.kordamp.gradle:settings-gradle-plugin:0.15.0
}
}
apply plugin: 'org.kordamp.gradle.settings'
projects {
layout = 'standard'
}
@aalmiray
TWO-LEVEL (GRADLE)
.
├── build.gradle
├── docs
│ └── guide
│ └── build.gradle
└── subprojects
├── project1
│ └── build.gradle
└── project2
└── build.gradle
.
├── build.gradle
├── docs
│ └── guide
│ └── guide.gradle
└── subprojects
├── project1
│ └── project1.gradle
└── project2
└── project2.gradle
@aalmiray
TWO-LEVEL (GRADLE)
$ cat settings.gradle
include 'guide'
include 'project1'
include 'project2'
project(':guide').projectDir =
new File(“$settingsDir/docs/guide”)
project(':project1').projectDir =
new File(“$settingsDir/subprojects/project1”)
project(':project2').projectDir =
new File(“$settingsDir/subprojects/project2”)
@aalmiray
TWO-LEVEL (GRADLE)
$ cat settings.gradle
buildscript {
repositories {
gradlePluginPortal()
}
dependencies {
classpath 'org.kordamp.gradle:settings-gradle-plugin:0.15.0
}
}
apply plugin: 'org.kordamp.gradle.settings'
projects {
layout = 'two-level'
directories = ['docs', 'subprojects']
}
@aalmiray
MULTI-LEVEL (GRADLE)
.
├── build.gradle
├── guide
│ └── build.gradle
└── subprojects
├── project1
│ └── build.gradle
└── project2
└── build.gradle
.
├── build.gradle
├── guide
│ └── guide.gradle
└── subprojects
├── project1
│ └── project1.gradle
└── project2
└── project2.gradle
@aalmiray
MULTI-LEVEL (GRADLE)
$ cat settings.gradle
buildscript {
repositories {
gradlePluginPortal()
}
dependencies {
classpath 'org.kordamp.gradle:settings-gradle-plugin:0.15.0
}
}
apply plugin: 'org.kordamp.gradle.settings'
projects {
layout = 'multi-level'
directories = [
'guide',
'subprojects/project1',
'subprojects/project2'
]
}
PROJECT
DSL
@aalmiray
THE PROJECT PLUGIN
plugins {
id 'org.kordamp.gradle.project' version ‘0.15.0’
}
config {
release = (rootProject.findProperty('release') ?: false).toBoolean()
info {
name = 'Sample'
vendor = 'Acme'
description = 'Sample project'
links {
website = 'https://github.com/joecool/sample'
issueTracker = 'https://github.com/joecool/sample/issues'
scm = 'https://github.com/joecool/sample.git'
}
people {
person {
id = 'joecool'
name = 'Joe Cool'
roles = ['developer']
}
}
}
…
}
@aalmiray
PROVIDED BEHAVIOR
• The project plugin applies the following plugins
• org.kordamp.gradle.base
• org.kordamp.gradle.build-info
• org.kordamp.gradle.minpom
• org.kordamp.gradle.jar
• org.kordamp.gradle.source-jar
• org.kordamp.gradle.javadoc
• org.kordamp.gradle.license
• org.kordamp.gradle.jacoco
• org.kordamp.gradle.publishing
• org.kordamp.gradle.testing
• org.kordamp.gradle.apidoc
• org.kordamp.gradle.source-stats
• org.kordamp.gradle.source-html
• org.kordamp.gradle.bintray
ORG.KORDAMP.GRADLE.BASE
@aalmiray
DEFAULT TASKS
• Gradle provides the following tasks
• projects
• dependencies
• properties
• tasks
@aalmiray
ADDITIONAL TASKS
• The base plugin provides the following tasks
• extensions
• plugins
• repositories
• projectProperties
• effectiveSettings
@aalmiray
@aalmiray
@aalmiray
ORG.KORDAMP.GRADLE.BUILD-INFO
@aalmiray
BUILD-INFO
• The build-info plugin calculates build data such as
• Build date
• Build time
• Build creator
• SCM revision (git commit hash)
• Build JDK
• This information is used to enrich JAR manifests
@aalmiray
JAR MANIFEST EXAMPLE
Manifest-Version: 1.0
Created-By: Gradle 5.2
Build-By: aalmiray
Build-Jdk: 11 (Oracle Corporation 11+28)
Build-Date: 2019-03-22
Build-Time: 06:59:24.924+0100
Build-Revision: 6604da6d0d79f75c72c812f5017cb8d9bb383fb3
ORG.KORDAMP.GRADLE.MINPOM
@aalmiray
MINPOM
• Generates additional metafiles for Maven compatibility
• META-INF/maven/${project.group}/pom.properties
• META-INF/maven/${project.group}/pom.xml
ORG.KORDAMP.GRADLE.JAR
@aalmiray
JAR
• Includes files generated by minpom plugin
• Enriches JAR manifest with data from build-info
ORG.KORDAMP.GRADLE.SOURCE-JAR
@aalmiray
SOURCE-JAR
• Generates a JAR file with project sources.
• Adds the following tasks
• sourceJar
• artifact is automatically added for publication
• aggregateSourceJar
ORG.KORDAMP.GRADLE.JAVADOC
@aalmiray
JAVADOC
• Configures Javadoc generation with sensible defaults.
• Adds the following tasks
• javadoc
• javadocJar
• artifact is automatically added for publication
ORG.KORDAMP.GRADLE.GROOVYDOC
@aalmiray
GROOVYDOC
• Configures Groovydoc generation with sensible defaults.
• Adds the following tasks
• groovydoc
• groovydocJar
• artifact is automatically added for publication
ORG.KORDAMP.GRADLE.APIDOC
@aalmiray
APIDOC
• Configures aggregate doc tasks at root level.
• Adds the following tasks
• aggregateJavadocs
• aggregateJavadocsJar
• aggregateGroovydocs
• aggregateGroovyDocsJar
• aggregateApidocs
ORG.KORDAMP.GRADLE.LICENSE
@aalmiray
LICENSE
• Configures license reports and file header formatting with
com.github.hierynomus.license
• Adds the following tasks
• aggregateLicenseReport
ORG.KORDAMP.GRADLE.JACOCO
@aalmiray
JACOCO
• Configures JaCoCo on all Test tasks.
• Adds the following tasks
• jacoco<Test>Report
• jacocoRootMerge
• jacocoRootReport
ORG.KORDAMP.GRADLE.SOURCE-HTML
@aalmiray
SOURCE-HTML
• Configures pretty printed API documentation using Java2Html.
• Adds the following tasks
• convertCodeToHtml
• generateSourceHtmlOverview
• sourceHtml
• aggregateConvertCodeToHtml
• aggregateGenerateSourceHtmlOverview
• aggregateSourceHtml
ORG.KORDAMP.GRADLE.SOURCE-STATS
@aalmiray
SOURCE-STATS
• Generates source statistics based on file types and LOC.
• Adds the following tasks
• sourceStats
• aggregateSourceStats
@aalmiray
SOURCE-STATS
> Task :base-gradle-plugin:sourceStats
+------------------------+--------+--------+
| Name | Files | LOC |
+------------------------+--------+--------+
| Groovy Sources | 55 | 5462 |
| Groovy Test Sources | 1 | 102 |
| Java Sources | 4 | 43 |
+------------------------+--------+--------+
| Totals | 60 | 5607 |
+------------------------+--------+--------+
ORG.KORDAMP.GRADLE.TESTING
@aalmiray
TESTING
• Configures quick feedback test reports.
• Adds the following tasks
• aggregateTestReports
• aggregateIntegrationTestReports
• aggregateFunctionalTestReports
• aggregateAllTestReports
@aalmiray
ORG.KORDAMP.GRADLE.PUBLISHING
@aalmiray
PUBLISHING
• Configures publication of main artifact, including source,
javadoc, groovydoc, kotlindoc, scaladoc.
• Configures POM based on data from base & license plugins
• Artifacts may be optionally signed.
• Publication can be deployed to Maven compatible repositories.
ORG.KORDAMP.GRADLE.BINTRAY
@aalmiray
BINTRAY
• Configures publication to Bintray based on data provided by
base, license, and bintray DSL blocks.
• Can push automatically to Maven Central.
• Publishes all artifacts registered by publishing plugin.
@aalmiray
ADDITIONAL PLUGINS
• The following plugins can be applied explicitly
• org.kordamp.gradle.kotlindoc
• org.kordamp.gradle.scaladoc
• org.kordamp.gradle.source-xref
• org.kordamp.gradle.bom
• org.kordamp.gradle.clirr
• org.kordamp.gradle.guide
• org.kordamp.gradle.integration-test
• org.kordamp.gradle.functional-test
SUPER POM
@aalmiray
THE MAVEN SUPER POM
• POMs are hierarchical.
• The chain resolves all the way to the top where you find the
Maven Super POM.
• Super POM configures lots of default & useful behavior.
@aalmiray
THE GRADLE SUPER POM
• Gradle does not offer this behavior out of the box.
• But it can be “faked” using a custom plugin.
• The plugin applies the default behavior that consuming
projects require.
GRADLE
SUPER POM
DEMO
BUILD-SCANS
@aalmiray
X-RAY YOUR BUILDS
• Capture build data on the go.
• Analyze problems on the spot.
• Deep linking enables better sharing.
• Works for both Maven and Gradle.
@aalmiray
https://scans.gradle.com/s/nde2zxpa4xb5w
@aalmiray
https://gradle.com/s/sr5y2ufwamkb2
@aalmiray
@aalmiray
HTTP://ANDRESALMIRAY.COM/NEWSLETTER
HTTP://ANDRESALMIRAY.COM/EDITORIAL
@aalmiray
THANK YOU!
ANDRES ALMIRAY
@AALMIRAY

More Related Content

PDF
Android gradle-build-system-overview
PDF
My "Perfect" Toolchain Setup for Grails Projects
PPTX
Gradle build capabilities
PDF
Migrating from Grails 2 to Grails 3
PPTX
PPTX
ODP
Gradle - time for another build
PDF
Grails 3.0 Preview
Android gradle-build-system-overview
My "Perfect" Toolchain Setup for Grails Projects
Gradle build capabilities
Migrating from Grails 2 to Grails 3
Gradle - time for another build
Grails 3.0 Preview

What's hot (19)

PDF
Grails At Linked
PDF
Apache Airflow in the Cloud: Programmatically orchestrating workloads with Py...
PDF
Upcoming features in Airflow 2
PDF
Make Your Build Great Again (DroidConSF 2017)
PPTX
SBT Concepts, part 2
PPTX
Angular beans
PDF
Agile Database Modeling with Grails - Preview of GORM 1.4 - SF Grails Meetup ...
PDF
Upgrading to Apache Airflow 2 | Airflow Summit 2021
PDF
GraphQL And Relay Modern
PDF
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
PDF
Gradle plugin, take control of the build
PDF
Getting Started with Relay Modern
PPT
Comprehensive Browser Automation Solution using Groovy, WebDriver & Obect Model
PDF
Having Fun with Play
PDF
Lightweight Developer Provisioning with Gradle
PDF
Simple Build Tool
PDF
Gradle how to's
PDF
Idiomatic Gradle Plugin Writing
PDF
Graalvm with Groovy and Kotlin - Madrid GUG 2019
Grails At Linked
Apache Airflow in the Cloud: Programmatically orchestrating workloads with Py...
Upcoming features in Airflow 2
Make Your Build Great Again (DroidConSF 2017)
SBT Concepts, part 2
Angular beans
Agile Database Modeling with Grails - Preview of GORM 1.4 - SF Grails Meetup ...
Upgrading to Apache Airflow 2 | Airflow Summit 2021
GraphQL And Relay Modern
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle plugin, take control of the build
Getting Started with Relay Modern
Comprehensive Browser Automation Solution using Groovy, WebDriver & Obect Model
Having Fun with Play
Lightweight Developer Provisioning with Gradle
Simple Build Tool
Gradle how to's
Idiomatic Gradle Plugin Writing
Graalvm with Groovy and Kotlin - Madrid GUG 2019
Ad

Similar to Gradle ex-machina (20)

PDF
Creating Better Builds with Gradle
PPTX
Faster java ee builds with gradle [con4921]
PDF
Gradle Ex Machina - Devoxx 2019
PDF
Gradle - Build system evolved
PPTX
Faster Java EE Builds with Gradle
PPTX
Faster Java EE Builds with Gradle
PDF
Making the Most of Your Gradle Build
PDF
Making the Most of Your Gradle Build
PDF
ICONUK 2015 - Gradle Up!
PDF
Gradle - Build System
PPTX
Gradle 2.Write once, builde everywhere
PPT
An introduction to maven gradle and sbt
ODP
Gradle: The Build System you have been waiting for!
PDF
Basic Gradle Plugin Writing
PDF
Idiomatic Gradle Plugin Writing
PDF
Gradle
PPT
Intro to-ant
PPTX
Gradle,the new build system for android
PDF
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)
Creating Better Builds with Gradle
Faster java ee builds with gradle [con4921]
Gradle Ex Machina - Devoxx 2019
Gradle - Build system evolved
Faster Java EE Builds with Gradle
Faster Java EE Builds with Gradle
Making the Most of Your Gradle Build
Making the Most of Your Gradle Build
ICONUK 2015 - Gradle Up!
Gradle - Build System
Gradle 2.Write once, builde everywhere
An introduction to maven gradle and sbt
Gradle: The Build System you have been waiting for!
Basic Gradle Plugin Writing
Idiomatic Gradle Plugin Writing
Gradle
Intro to-ant
Gradle,the new build system for android
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)
Ad

More from Andres Almiray (20)

PDF
Dealing with JSON in the relational world
PDF
Deploying to production with confidence 🚀
PDF
Going beyond ORMs with JSON Relational Duality Views
PDF
Setting up data driven tests with Java tools
PDF
Creando, creciendo, y manteniendo una comunidad de codigo abierto
PDF
Liberando a produccion con confianza
PDF
Liberando a produccion con confidencia
PDF
OracleDB Ecosystem for Java Developers
PDF
Softcon.ph - Maven Puzzlers
PDF
Maven Puzzlers
PDF
Oracle Database Ecosystem for Java Developers
PDF
JReleaser - Releasing at the speed of light
PDF
Building modular applications with the Java Platform Module System and Layrry
PDF
Going Reactive with g rpc
PDF
Building modular applications with JPMS and Layrry
PDF
Taking Micronaut out for a spin
PDF
Apache Groovy's Metaprogramming Options and You
PDF
What I wish I knew about Maven years ago
PDF
What I wish I knew about maven years ago
PDF
The impact of sci fi in tech
Dealing with JSON in the relational world
Deploying to production with confidence 🚀
Going beyond ORMs with JSON Relational Duality Views
Setting up data driven tests with Java tools
Creando, creciendo, y manteniendo una comunidad de codigo abierto
Liberando a produccion con confianza
Liberando a produccion con confidencia
OracleDB Ecosystem for Java Developers
Softcon.ph - Maven Puzzlers
Maven Puzzlers
Oracle Database Ecosystem for Java Developers
JReleaser - Releasing at the speed of light
Building modular applications with the Java Platform Module System and Layrry
Going Reactive with g rpc
Building modular applications with JPMS and Layrry
Taking Micronaut out for a spin
Apache Groovy's Metaprogramming Options and You
What I wish I knew about Maven years ago
What I wish I knew about maven years ago
The impact of sci fi in tech

Recently uploaded (20)

PPTX
Web Crawler for Trend Tracking Gen Z Insights.pptx
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PDF
Unlock new opportunities with location data.pdf
PDF
Getting Started with Data Integration: FME Form 101
PDF
Hybrid model detection and classification of lung cancer
PPTX
observCloud-Native Containerability and monitoring.pptx
PPTX
Chapter 5: Probability Theory and Statistics
PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
PPTX
Tartificialntelligence_presentation.pptx
PPT
Module 1.ppt Iot fundamentals and Architecture
PPT
Geologic Time for studying geology for geologist
PPTX
The various Industrial Revolutions .pptx
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
August Patch Tuesday
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PDF
Enhancing emotion recognition model for a student engagement use case through...
PDF
Architecture types and enterprise applications.pdf
Web Crawler for Trend Tracking Gen Z Insights.pptx
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
sustainability-14-14877-v2.pddhzftheheeeee
Unlock new opportunities with location data.pdf
Getting Started with Data Integration: FME Form 101
Hybrid model detection and classification of lung cancer
observCloud-Native Containerability and monitoring.pptx
Chapter 5: Probability Theory and Statistics
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
Tartificialntelligence_presentation.pptx
Module 1.ppt Iot fundamentals and Architecture
Geologic Time for studying geology for geologist
The various Industrial Revolutions .pptx
Group 1 Presentation -Planning and Decision Making .pptx
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
August Patch Tuesday
Assigned Numbers - 2025 - Bluetooth® Document
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
Enhancing emotion recognition model for a student engagement use case through...
Architecture types and enterprise applications.pdf

Gradle ex-machina