SlideShare a Scribd company logo
1 of 10
Download to read offline
Netflix = freedom and responsibility
(The assignment operator is intentional)
What can Gradle Lint do?
4 Remove cruft
4 Bar practices that are universally bad
4 Sanitize dependencies
4 Keep Gradle version up-to-date
4 Auto-fix violations!
Gradle Lint in action
Apply it:
allprojects {
apply plugin: 'nebula.lint'
gradleLint.rules = ['dependency-parentheses', 'dependency-tuple', ...]
}
Run it:
./gradlew lintGradle
./gradlew build <-- also causes lintGradle to run
./gradlew fixGradleLint <-- fixes all problems for you
Unused dependencies
4 Remove unused first-order dependencies
4 Add transitive dependencies with compile time
references as first-order dependencies
4 Align fixed first-order dependency versions with
transitives when conflict resolved
4 Shuffle first-order dependencies to the correct
configurations (e.g. junit to testCompile)
Creating a simple lint rule
"All wars should be published to our binary
repository"
1: Apply immediately after the war plugin
class AllWarsShouldBePublishedRule extends GradleLintRule {
@Override void visitApplyPlugin(MethodCallExpression call, String plugin) {
if(plugin == 'war') {
addLintViolation('WARs must be published')
.insertAfter(call, "apply plugin: 'netflix.war-publish'")
}
}
}
2: Apply only if it isn't already applied
class AllWarsShouldBePublishedRule extends GradleLintRule {
@Override void visitApplyPlugin(MethodCallExpression call, String plugin) {
if(plugin == 'war') bookmark('applyWar', call)
else if(plugin == 'netflix.war-publish') bookmark('applyWarPublish', call)
}
@Override protected void visitClassComplete(ClassNode node) {
if(bookmark('applyWar') && !bookmark('applyWarPublish')) {
addLintViolation('WARs must be published')
.insertAfter(bookmark('applyWar'), "apply plugin: 'netflix.war-publish'")
}
}
3: Replace the war plugin entirely
class AllWarsShouldBePublishedRule extends GradleLintRule {
@Override void visitApplyPlugin(MethodCallExpression call, String plugin) {
if(plugin == 'war') bookmark('applyWar', call)
else if(plugin == 'netflix.war-publish') bookmark('applyWarPublish', call)
}
@Override protected void visitClassComplete(ClassNode node) {
if(bookmark('applyWar') && !bookmark('applyWarPublish')) {
addLintViolation('WARs must be published')
.replaceWith(bookmark('applyWar'), "apply plugin: 'netflix.war-publish'")
}
}
4: Become Gradle model aware
class AllWarsShouldBePublishedRule extends GradleLintRule implements GradleModelAware {
@Override void visitApplyPlugin(MethodCallExpression call, String plugin) {
bookmark('lastApplyPlugin', call)
}
@Override protected void visitClassComplete(ClassNode node) {
if(project.plugins.hasPlugin(WarPlugin) && !project.plugins.hasPlugin('netflix.war-publish')) {
addLintViolation('WARs must be published')
.insertAfter(bookmark('lastApplyPlugin'), "apply plugin: 'netflix.war-publish'")
}
}
}
Resources
"How We Build Code at Netflix" -- Netflix techblog
github.com/nebula-plugins/gradle-lint-plugin

More Related Content

What's hot

Android build process (1)
Android build process (1)Android build process (1)
Android build process (1)Shubham Goyal
 
GitLab for CI/CD process
GitLab for CI/CD processGitLab for CI/CD process
GitLab for CI/CD processHYS Enterprise
 
Continuous Deployment of Architectural Change
Continuous Deployment of Architectural ChangeContinuous Deployment of Architectural Change
Continuous Deployment of Architectural ChangeMatt Graham
 
Continuous Integration/Deployment with Gitlab CI
Continuous Integration/Deployment with Gitlab CIContinuous Integration/Deployment with Gitlab CI
Continuous Integration/Deployment with Gitlab CIDavid Hahn
 
PUG Romagna - Pipeline + Deployer PHP
PUG Romagna - Pipeline + Deployer PHPPUG Romagna - Pipeline + Deployer PHP
PUG Romagna - Pipeline + Deployer PHPGiuseppe Morelli
 
Jenkins vs GitLab CI
Jenkins vs GitLab CIJenkins vs GitLab CI
Jenkins vs GitLab CICEE-SEC(R)
 
OpenStack and DevOps - DevOps Meetup
OpenStack and DevOps - DevOps MeetupOpenStack and DevOps - DevOps Meetup
OpenStack and DevOps - DevOps MeetupOpsta
 
Docker New York City: From GitOps to a scalable CI/CD Pattern for Kubernetes
Docker New York City: From GitOps to a scalable CI/CD Pattern for KubernetesDocker New York City: From GitOps to a scalable CI/CD Pattern for Kubernetes
Docker New York City: From GitOps to a scalable CI/CD Pattern for KubernetesAndrew Phillips
 
Parser Breakout Session
Parser Breakout SessionParser Breakout Session
Parser Breakout SessionZhipeng Huang
 
Terraform GitOps on Codefresh
Terraform GitOps on CodefreshTerraform GitOps on Codefresh
Terraform GitOps on CodefreshCodefresh
 
Writing Commits for You, Your Friends, and Your Future Self
Writing Commits for You, Your Friends, and Your Future SelfWriting Commits for You, Your Friends, and Your Future Self
Writing Commits for You, Your Friends, and Your Future SelfAll Things Open
 
An Introduction to Travis-CI
An Introduction to Travis-CIAn Introduction to Travis-CI
An Introduction to Travis-CIGengo
 
Git branching strategies
Git branching strategiesGit branching strategies
Git branching strategiesjstack
 
QA methodology by Quality Tech
QA methodology  by Quality TechQA methodology  by Quality Tech
QA methodology by Quality TechIvet Prokopova
 
CodeWay 2019 - Gandalf: Bad code shall not pass
CodeWay 2019 - Gandalf: Bad code shall not passCodeWay 2019 - Gandalf: Bad code shall not pass
CodeWay 2019 - Gandalf: Bad code shall not passIlya Ghirici
 
What's New for GitLab CI/CD February 2020
What's New for GitLab CI/CD February 2020What's New for GitLab CI/CD February 2020
What's New for GitLab CI/CD February 2020Noa Harel
 
Fine Tuning Your GitHub Flow
Fine Tuning Your GitHub FlowFine Tuning Your GitHub Flow
Fine Tuning Your GitHub FlowStefan Stölzle
 
Uop ntc 324 entire course new
Uop ntc 324 entire course newUop ntc 324 entire course new
Uop ntc 324 entire course newmailemail
 

What's hot (20)

Android build process (1)
Android build process (1)Android build process (1)
Android build process (1)
 
GitLab for CI/CD process
GitLab for CI/CD processGitLab for CI/CD process
GitLab for CI/CD process
 
Continuous Deployment of Architectural Change
Continuous Deployment of Architectural ChangeContinuous Deployment of Architectural Change
Continuous Deployment of Architectural Change
 
Continuous Integration/Deployment with Gitlab CI
Continuous Integration/Deployment with Gitlab CIContinuous Integration/Deployment with Gitlab CI
Continuous Integration/Deployment with Gitlab CI
 
PUG Romagna - Pipeline + Deployer PHP
PUG Romagna - Pipeline + Deployer PHPPUG Romagna - Pipeline + Deployer PHP
PUG Romagna - Pipeline + Deployer PHP
 
Jenkins vs GitLab CI
Jenkins vs GitLab CIJenkins vs GitLab CI
Jenkins vs GitLab CI
 
OpenStack and DevOps - DevOps Meetup
OpenStack and DevOps - DevOps MeetupOpenStack and DevOps - DevOps Meetup
OpenStack and DevOps - DevOps Meetup
 
Docker New York City: From GitOps to a scalable CI/CD Pattern for Kubernetes
Docker New York City: From GitOps to a scalable CI/CD Pattern for KubernetesDocker New York City: From GitOps to a scalable CI/CD Pattern for Kubernetes
Docker New York City: From GitOps to a scalable CI/CD Pattern for Kubernetes
 
Parser Breakout Session
Parser Breakout SessionParser Breakout Session
Parser Breakout Session
 
Terraform GitOps on Codefresh
Terraform GitOps on CodefreshTerraform GitOps on Codefresh
Terraform GitOps on Codefresh
 
Writing Commits for You, Your Friends, and Your Future Self
Writing Commits for You, Your Friends, and Your Future SelfWriting Commits for You, Your Friends, and Your Future Self
Writing Commits for You, Your Friends, and Your Future Self
 
Gitlab CI/CD
Gitlab CI/CDGitlab CI/CD
Gitlab CI/CD
 
An Introduction to Travis-CI
An Introduction to Travis-CIAn Introduction to Travis-CI
An Introduction to Travis-CI
 
Git branching strategies
Git branching strategiesGit branching strategies
Git branching strategies
 
QA methodology by Quality Tech
QA methodology  by Quality TechQA methodology  by Quality Tech
QA methodology by Quality Tech
 
CodeWay 2019 - Gandalf: Bad code shall not pass
CodeWay 2019 - Gandalf: Bad code shall not passCodeWay 2019 - Gandalf: Bad code shall not pass
CodeWay 2019 - Gandalf: Bad code shall not pass
 
What's New for GitLab CI/CD February 2020
What's New for GitLab CI/CD February 2020What's New for GitLab CI/CD February 2020
What's New for GitLab CI/CD February 2020
 
Fine Tuning Your GitHub Flow
Fine Tuning Your GitHub FlowFine Tuning Your GitHub Flow
Fine Tuning Your GitHub Flow
 
3 workflow
3 workflow3 workflow
3 workflow
 
Uop ntc 324 entire course new
Uop ntc 324 entire course newUop ntc 324 entire course new
Uop ntc 324 entire course new
 

Viewers also liked

Future State Asia - company presentation
Future State Asia - company presentationFuture State Asia - company presentation
Future State Asia - company presentationfuturestateasia
 
Informatica certification
Informatica certificationInformatica certification
Informatica certificationbnjkukunuri
 
Review game
Review gameReview game
Review gamebren-ies
 
โครงการนักธุรกิจน้อย
โครงการนักธุรกิจน้อยโครงการนักธุรกิจน้อย
โครงการนักธุรกิจน้อยratchadaphun
 
Questions Used For Interviews
Questions Used For InterviewsQuestions Used For Interviews
Questions Used For Interviewsmediarosanna
 

Viewers also liked (7)

Future State Asia - company presentation
Future State Asia - company presentationFuture State Asia - company presentation
Future State Asia - company presentation
 
Informatica certification
Informatica certificationInformatica certification
Informatica certification
 
PLR
PLRPLR
PLR
 
Review game
Review gameReview game
Review game
 
โครงการนักธุรกิจน้อย
โครงการนักธุรกิจน้อยโครงการนักธุรกิจน้อย
โครงการนักธุรกิจน้อย
 
Les bases du java
Les bases du javaLes bases du java
Les bases du java
 
Questions Used For Interviews
Questions Used For InterviewsQuestions Used For Interviews
Questions Used For Interviews
 

Similar to SF JUG - Gradle Lint

Gradle - the Enterprise Automation Tool
Gradle  - the Enterprise Automation ToolGradle  - the Enterprise Automation Tool
Gradle - the Enterprise Automation ToolIzzet Mustafaiev
 
Git for work groups ironhack talk
Git for work groups ironhack talkGit for work groups ironhack talk
Git for work groups ironhack talkTiago Ameller
 
Hands-on GitOps Patterns for Helm Users
Hands-on GitOps Patterns for Helm UsersHands-on GitOps Patterns for Helm Users
Hands-on GitOps Patterns for Helm UsersWeaveworks
 
Managing dependencies with gradle
Managing dependencies with gradleManaging dependencies with gradle
Managing dependencies with gradleLiviu Tudor
 
There's more to Ratpack than non-blocking
There's more to Ratpack than non-blockingThere's more to Ratpack than non-blocking
There's more to Ratpack than non-blockingMarcin Erdmann
 
GitOps for Helm Users by Scott Rigby
GitOps for Helm Users by Scott RigbyGitOps for Helm Users by Scott Rigby
GitOps for Helm Users by Scott RigbyWeaveworks
 
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
 
GitOps (& Flux) for Helm Users with Scott Rigby
GitOps (& Flux) for Helm Users with Scott RigbyGitOps (& Flux) for Helm Users with Scott Rigby
GitOps (& Flux) for Helm Users with Scott RigbyWeaveworks
 
Node Summit 2016: Building your DevOps for Node.js
Node Summit 2016: Building your DevOps for Node.jsNode Summit 2016: Building your DevOps for Node.js
Node Summit 2016: Building your DevOps for Node.jsChetan Desai
 
FOSDEM 2017: GitLab CI
FOSDEM 2017:  GitLab CIFOSDEM 2017:  GitLab CI
FOSDEM 2017: GitLab CIOlinData
 
Lightweight continuous delivery for small schools
Lightweight continuous delivery for small schoolsLightweight continuous delivery for small schools
Lightweight continuous delivery for small schoolsCharles Fulton
 
Pluggable Infrastructure with CI/CD and Docker
Pluggable Infrastructure with CI/CD and DockerPluggable Infrastructure with CI/CD and Docker
Pluggable Infrastructure with CI/CD and DockerBob Killen
 
Skaffold - faster development on K8S
Skaffold - faster development on K8SSkaffold - faster development on K8S
Skaffold - faster development on K8SHuynh Thai Bao
 
Understanding GitFlow by Ian Vizarra
Understanding GitFlow by Ian VizarraUnderstanding GitFlow by Ian Vizarra
Understanding GitFlow by Ian Vizarravzrx23
 

Similar to SF JUG - Gradle Lint (20)

Gradle - the Enterprise Automation Tool
Gradle  - the Enterprise Automation ToolGradle  - the Enterprise Automation Tool
Gradle - the Enterprise Automation Tool
 
Git for work groups ironhack talk
Git for work groups ironhack talkGit for work groups ironhack talk
Git for work groups ironhack talk
 
Desiging for Modularity with Java 9
Desiging for Modularity with Java 9Desiging for Modularity with Java 9
Desiging for Modularity with Java 9
 
Hands-on GitOps Patterns for Helm Users
Hands-on GitOps Patterns for Helm UsersHands-on GitOps Patterns for Helm Users
Hands-on GitOps Patterns for Helm Users
 
Managing dependencies with gradle
Managing dependencies with gradleManaging dependencies with gradle
Managing dependencies with gradle
 
There's more to Ratpack than non-blocking
There's more to Ratpack than non-blockingThere's more to Ratpack than non-blocking
There's more to Ratpack than non-blocking
 
Introduction to Git (part 3)
Introduction to Git (part 3)Introduction to Git (part 3)
Introduction to Git (part 3)
 
GitOps for Helm Users by Scott Rigby
GitOps for Helm Users by Scott RigbyGitOps for Helm Users by Scott Rigby
GitOps for Helm Users by Scott Rigby
 
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
 
GitOps (& Flux) for Helm Users with Scott Rigby
GitOps (& Flux) for Helm Users with Scott RigbyGitOps (& Flux) for Helm Users with Scott Rigby
GitOps (& Flux) for Helm Users with Scott Rigby
 
OpenCms Days 2012 - Developing OpenCms with Gradle
OpenCms Days 2012 - Developing OpenCms with GradleOpenCms Days 2012 - Developing OpenCms with Gradle
OpenCms Days 2012 - Developing OpenCms with Gradle
 
Node Summit 2016: Building your DevOps for Node.js
Node Summit 2016: Building your DevOps for Node.jsNode Summit 2016: Building your DevOps for Node.js
Node Summit 2016: Building your DevOps for Node.js
 
FOSDEM 2017: GitLab CI
FOSDEM 2017:  GitLab CIFOSDEM 2017:  GitLab CI
FOSDEM 2017: GitLab CI
 
Lightweight continuous delivery for small schools
Lightweight continuous delivery for small schoolsLightweight continuous delivery for small schools
Lightweight continuous delivery for small schools
 
Why gradle
Why gradle Why gradle
Why gradle
 
Gitops Hands On
Gitops Hands OnGitops Hands On
Gitops Hands On
 
Pluggable Infrastructure with CI/CD and Docker
Pluggable Infrastructure with CI/CD and DockerPluggable Infrastructure with CI/CD and Docker
Pluggable Infrastructure with CI/CD and Docker
 
Skaffold - faster development on K8S
Skaffold - faster development on K8SSkaffold - faster development on K8S
Skaffold - faster development on K8S
 
Understanding GitFlow by Ian Vizarra
Understanding GitFlow by Ian VizarraUnderstanding GitFlow by Ian Vizarra
Understanding GitFlow by Ian Vizarra
 

Recently uploaded

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
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
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
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
 
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
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024SynarionITSolutions
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
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
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 

Recently uploaded (20)

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
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...
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
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
 
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
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
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
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 

SF JUG - Gradle Lint

  • 1. Netflix = freedom and responsibility (The assignment operator is intentional)
  • 2. What can Gradle Lint do? 4 Remove cruft 4 Bar practices that are universally bad 4 Sanitize dependencies 4 Keep Gradle version up-to-date 4 Auto-fix violations!
  • 3. Gradle Lint in action Apply it: allprojects { apply plugin: 'nebula.lint' gradleLint.rules = ['dependency-parentheses', 'dependency-tuple', ...] } Run it: ./gradlew lintGradle ./gradlew build <-- also causes lintGradle to run ./gradlew fixGradleLint <-- fixes all problems for you
  • 4. Unused dependencies 4 Remove unused first-order dependencies 4 Add transitive dependencies with compile time references as first-order dependencies 4 Align fixed first-order dependency versions with transitives when conflict resolved 4 Shuffle first-order dependencies to the correct configurations (e.g. junit to testCompile)
  • 5. Creating a simple lint rule "All wars should be published to our binary repository"
  • 6. 1: Apply immediately after the war plugin class AllWarsShouldBePublishedRule extends GradleLintRule { @Override void visitApplyPlugin(MethodCallExpression call, String plugin) { if(plugin == 'war') { addLintViolation('WARs must be published') .insertAfter(call, "apply plugin: 'netflix.war-publish'") } } }
  • 7. 2: Apply only if it isn't already applied class AllWarsShouldBePublishedRule extends GradleLintRule { @Override void visitApplyPlugin(MethodCallExpression call, String plugin) { if(plugin == 'war') bookmark('applyWar', call) else if(plugin == 'netflix.war-publish') bookmark('applyWarPublish', call) } @Override protected void visitClassComplete(ClassNode node) { if(bookmark('applyWar') && !bookmark('applyWarPublish')) { addLintViolation('WARs must be published') .insertAfter(bookmark('applyWar'), "apply plugin: 'netflix.war-publish'") } }
  • 8. 3: Replace the war plugin entirely class AllWarsShouldBePublishedRule extends GradleLintRule { @Override void visitApplyPlugin(MethodCallExpression call, String plugin) { if(plugin == 'war') bookmark('applyWar', call) else if(plugin == 'netflix.war-publish') bookmark('applyWarPublish', call) } @Override protected void visitClassComplete(ClassNode node) { if(bookmark('applyWar') && !bookmark('applyWarPublish')) { addLintViolation('WARs must be published') .replaceWith(bookmark('applyWar'), "apply plugin: 'netflix.war-publish'") } }
  • 9. 4: Become Gradle model aware class AllWarsShouldBePublishedRule extends GradleLintRule implements GradleModelAware { @Override void visitApplyPlugin(MethodCallExpression call, String plugin) { bookmark('lastApplyPlugin', call) } @Override protected void visitClassComplete(ClassNode node) { if(project.plugins.hasPlugin(WarPlugin) && !project.plugins.hasPlugin('netflix.war-publish')) { addLintViolation('WARs must be published') .insertAfter(bookmark('lastApplyPlugin'), "apply plugin: 'netflix.war-publish'") } } }
  • 10. Resources "How We Build Code at Netflix" -- Netflix techblog github.com/nebula-plugins/gradle-lint-plugin