際際滷

際際滷Share a Scribd company logo
DISTRIBUTED
REFACTORING WITH
GRADLE LINT
Jon Schneider
Netflix Engineering Tools
@jon_k_schneider
GITHUB.COM/NETFLIXGRADLESUMMIT/LINT
GITHUB.COM/NETFLIXGRADLESUMMIT/LINT
NETFLIX IS KNOWN FOR
RAPID INNOVATION.
GITHUB.COM/NETFLIXGRADLESUMMIT/LINT
WE WANT TO MINIMIZE DRAG FROM LATE
ADOPTERS.
GITHUB.COM/NETFLIXGRADLESUMMIT/LINT
NETFLIX CULTURE IS
FREEDOM AND RESPONSIBILITY
GITHUB.COM/NETFLIXGRADLESUMMIT/LINT
GRADLE LINT
ALLOWS US TO
DISTRIBUTE
CHANGE.
GITHUB.COM/NETFLIXGRADLESUMMIT/LINT
THE UNUSED
DEPENDENCIES
RULE HELPS
MAINTAIN GOOD
DEPENDENCY
HYGIENE.
GITHUB.COM/NETFLIXGRADLESUMMIT/LINT
GRADLE LINT SUPPORTS
SHIPPING METRICS TO
nebula.metrics
GITHUB.COM/NETFLIXGRADLESUMMIT/LINT
CREATING A MORE COMPLEX RULE
"All wars should be published to our
binary repository"
GITHUB.COM/NETFLIXGRADLESUMMIT/LINT
1: APPLY IMMEDIATELY AFTER THE WAR
PLUGIN
class AllWarsShouldBePublishedRule extends GradleLintRule {
@Override void visitApplyPlugin(MethodCallExpression call, String plugin) {
if(plugin == 'war') {
addBuildLintViolation('WARs must be published', call)
.insertAfter(call, "apply plugin: 'netflix.war-publish'")
}
}
}
GITHUB.COM/NETFLIXGRADLESUMMIT/LINT
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')) {
addBuildLintViolation('WARs must be published', call)
.insertAfter(bookmark('applyWar'), "apply plugin: 'netflix.war-publish'")
}
}
}
GITHUB.COM/NETFLIXGRADLESUMMIT/LINT
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')) {
addBuildLintViolation('WARs must be published', call)
.replaceWith(bookmark('applyWar'), "apply plugin: 'netflix.war-publish'")
}
}
}
GITHUB.COM/NETFLIXGRADLESUMMIT/LINT
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')) {
addBuildLintViolation('WARs must be published', call)
.insertAfter(
bookmark('lastApplyPlugin'),
"apply plugin: 'netflix.war-publish'"
)
}
}
}
GITHUB.COM/NETFLIXGRADLESUMMIT/LINT
GRADLE LINT IS OUR FIRST
DISTRIBUTED REFACTORING
TOOL.
GITHUB.COM/NETFLIXGRADLESUMMIT/LINT
THE EXPERIMENTAL LOCK PLUGIN IS
ANOTHER EXAMPLE.
github.com/nebula-plugins/lock-
experimental
GITHUB.COM/NETFLIXGRADLESUMMIT/LINT
WE WANT AN
EVENTUALLY CONSISTENT
MONOREPO
THROUGH
DISTRIBUTED REFACTORING.
GITHUB.COM/NETFLIXGRADLESUMMIT/LINT
JAVA POWER ASSERT WAS THE
LEARNING GROUND.
github.com/jkschneider/java-power-assert
GITHUB.COM/NETFLIXGRADLESUMMIT/LINT
THANK YOU.
GITHUB.COM/NETFLIXGRADLESUMMIT/LINT

More Related Content

Similar to Distributed Refactoring with Gradle Lint (20)

Benoit Felten
Benoit FeltenBenoit Felten
Benoit Felten
Freedom to Connect
Open Source & DevOps Market trends - Open Core Summit
Open Source & DevOps Market trends - Open Core SummitOpen Source & DevOps Market trends - Open Core Summit
Open Source & DevOps Market trends - Open Core Summit
Ido Green
Thinxtra, Sigfox and Xamarin
Thinxtra, Sigfox and XamarinThinxtra, Sigfox and Xamarin
Thinxtra, Sigfox and Xamarin
Rod Hemphill
L19 Local
L19 LocalL19 Local
L19 Local
lafur Andri Ragnarsson
Smart Gigabit Applications
Smart Gigabit ApplicationsSmart Gigabit Applications
Smart Gigabit Applications
US-Ignite
Whitepaper DVB Native IP: The Gamechanger for Content Distribution
Whitepaper DVB Native IP: The Gamechanger for Content DistributionWhitepaper DVB Native IP: The Gamechanger for Content Distribution
Whitepaper DVB Native IP: The Gamechanger for Content Distribution
ST Engineering iDirect
L20 Personalised World
L20 Personalised WorldL20 Personalised World
L20 Personalised World
lafur Andri Ragnarsson
2019.02 Eclipse Foundation and Eclipse IoT presentation at Eclipse IoT Day Gr...
2019.02 Eclipse Foundation and Eclipse IoT presentation at Eclipse IoT Day Gr...2019.02 Eclipse Foundation and Eclipse IoT presentation at Eclipse IoT Day Gr...
2019.02 Eclipse Foundation and Eclipse IoT presentation at Eclipse IoT Day Gr...
Ga谷l Blondelle
Green house software
Green house softwareGreen house software
Green house software
Vinod Pol
Growing impact and future potential of blockchain for telcos: A Game Changer?
Growing impact and future potential of blockchain for telcos: A Game Changer?Growing impact and future potential of blockchain for telcos: A Game Changer?
Growing impact and future potential of blockchain for telcos: A Game Changer?
Jos辿 Luis N炭単ez D鱈az
DevSecCon London 2017: Their-problems-are-your-problems-devseccon by Tim Kadlec
DevSecCon London 2017: Their-problems-are-your-problems-devseccon by Tim KadlecDevSecCon London 2017: Their-problems-are-your-problems-devseccon by Tim Kadlec
DevSecCon London 2017: Their-problems-are-your-problems-devseccon by Tim Kadlec
DevSecCon
L Migrator Pres
L Migrator PresL Migrator Pres
L Migrator Pres
Brian Loomis
Ceph Day Beijing - Ceph Community Update
Ceph Day Beijing - Ceph Community UpdateCeph Day Beijing - Ceph Community Update
Ceph Day Beijing - Ceph Community Update
Ceph Community
Ceph Day Beijing- Ceph Community Update
Ceph Day Beijing- Ceph Community UpdateCeph Day Beijing- Ceph Community Update
Ceph Day Beijing- Ceph Community Update
Danielle Womboldt
Hyperledger Fabric in a Nutshell
Hyperledger Fabric in a NutshellHyperledger Fabric in a Nutshell
Hyperledger Fabric in a Nutshell
Daniel Chan
Perspectives of Telecommunications in CALA - ECI Telecom - 20/10/2016
Perspectives of Telecommunications in CALA - ECI Telecom - 20/10/2016Perspectives of Telecommunications in CALA - ECI Telecom - 20/10/2016
Perspectives of Telecommunications in CALA - ECI Telecom - 20/10/2016
Renato Cruz
BigchainDB and Beyond
BigchainDB and BeyondBigchainDB and Beyond
BigchainDB and Beyond
Dimitri De Jonghe
Supercharge Spark: Unleashing Big Data Potential with Milvus for RAG systems
Supercharge Spark: Unleashing Big Data Potential with Milvus for RAG systemsSupercharge Spark: Unleashing Big Data Potential with Milvus for RAG systems
Supercharge Spark: Unleashing Big Data Potential with Milvus for RAG systems
Zilliz
IoT, arquitectura de soluci坦n y c坦mo enriquecerlo con Confluent
IoT, arquitectura de soluci坦n y c坦mo enriquecerlo con ConfluentIoT, arquitectura de soluci坦n y c坦mo enriquecerlo con Confluent
IoT, arquitectura de soluci坦n y c坦mo enriquecerlo con Confluent
mimacom
Observability
ObservabilityObservability
Observability
Ebru Cucen 端巽en
Open Source & DevOps Market trends - Open Core Summit
Open Source & DevOps Market trends - Open Core SummitOpen Source & DevOps Market trends - Open Core Summit
Open Source & DevOps Market trends - Open Core Summit
Ido Green
Thinxtra, Sigfox and Xamarin
Thinxtra, Sigfox and XamarinThinxtra, Sigfox and Xamarin
Thinxtra, Sigfox and Xamarin
Rod Hemphill
Smart Gigabit Applications
Smart Gigabit ApplicationsSmart Gigabit Applications
Smart Gigabit Applications
US-Ignite
Whitepaper DVB Native IP: The Gamechanger for Content Distribution
Whitepaper DVB Native IP: The Gamechanger for Content DistributionWhitepaper DVB Native IP: The Gamechanger for Content Distribution
Whitepaper DVB Native IP: The Gamechanger for Content Distribution
ST Engineering iDirect
2019.02 Eclipse Foundation and Eclipse IoT presentation at Eclipse IoT Day Gr...
2019.02 Eclipse Foundation and Eclipse IoT presentation at Eclipse IoT Day Gr...2019.02 Eclipse Foundation and Eclipse IoT presentation at Eclipse IoT Day Gr...
2019.02 Eclipse Foundation and Eclipse IoT presentation at Eclipse IoT Day Gr...
Ga谷l Blondelle
Green house software
Green house softwareGreen house software
Green house software
Vinod Pol
Growing impact and future potential of blockchain for telcos: A Game Changer?
Growing impact and future potential of blockchain for telcos: A Game Changer?Growing impact and future potential of blockchain for telcos: A Game Changer?
Growing impact and future potential of blockchain for telcos: A Game Changer?
Jos辿 Luis N炭単ez D鱈az
DevSecCon London 2017: Their-problems-are-your-problems-devseccon by Tim Kadlec
DevSecCon London 2017: Their-problems-are-your-problems-devseccon by Tim KadlecDevSecCon London 2017: Their-problems-are-your-problems-devseccon by Tim Kadlec
DevSecCon London 2017: Their-problems-are-your-problems-devseccon by Tim Kadlec
DevSecCon
L Migrator Pres
L Migrator PresL Migrator Pres
L Migrator Pres
Brian Loomis
Ceph Day Beijing - Ceph Community Update
Ceph Day Beijing - Ceph Community UpdateCeph Day Beijing - Ceph Community Update
Ceph Day Beijing - Ceph Community Update
Ceph Community
Ceph Day Beijing- Ceph Community Update
Ceph Day Beijing- Ceph Community UpdateCeph Day Beijing- Ceph Community Update
Ceph Day Beijing- Ceph Community Update
Danielle Womboldt
Hyperledger Fabric in a Nutshell
Hyperledger Fabric in a NutshellHyperledger Fabric in a Nutshell
Hyperledger Fabric in a Nutshell
Daniel Chan
Perspectives of Telecommunications in CALA - ECI Telecom - 20/10/2016
Perspectives of Telecommunications in CALA - ECI Telecom - 20/10/2016Perspectives of Telecommunications in CALA - ECI Telecom - 20/10/2016
Perspectives of Telecommunications in CALA - ECI Telecom - 20/10/2016
Renato Cruz
Supercharge Spark: Unleashing Big Data Potential with Milvus for RAG systems
Supercharge Spark: Unleashing Big Data Potential with Milvus for RAG systemsSupercharge Spark: Unleashing Big Data Potential with Milvus for RAG systems
Supercharge Spark: Unleashing Big Data Potential with Milvus for RAG systems
Zilliz
IoT, arquitectura de soluci坦n y c坦mo enriquecerlo con Confluent
IoT, arquitectura de soluci坦n y c坦mo enriquecerlo con ConfluentIoT, arquitectura de soluci坦n y c坦mo enriquecerlo con Confluent
IoT, arquitectura de soluci坦n y c坦mo enriquecerlo con Confluent
mimacom

Recently uploaded (20)

Production Planning & Control and Inventory Management.pptx
Production Planning & Control and Inventory Management.pptxProduction Planning & Control and Inventory Management.pptx
Production Planning & Control and Inventory Management.pptx
VirajPasare
Why the Engineering Model is Key to Successful Projects
Why the Engineering Model is Key to Successful ProjectsWhy the Engineering Model is Key to Successful Projects
Why the Engineering Model is Key to Successful Projects
Maadhu Creatives-Model Making Company
Telehealth technology A new horizon in health care
Telehealth technology  A new horizon in health careTelehealth technology  A new horizon in health care
Telehealth technology A new horizon in health care
Dr INBAMALAR T M
Introduction to Forensic Research Digital Forensics
Introduction to Forensic Research Digital ForensicsIntroduction to Forensic Research Digital Forensics
Introduction to Forensic Research Digital Forensics
SaanviMisar
Artificial intelligence and Machine learning in remote sensing and GIS
Artificial intelligence  and Machine learning in remote sensing and GISArtificial intelligence  and Machine learning in remote sensing and GIS
Artificial intelligence and Machine learning in remote sensing and GIS
amirthamm2083
Unit-03 Cams and Followers in Mechanisms of Machines.pptx
Unit-03 Cams and Followers in Mechanisms of Machines.pptxUnit-03 Cams and Followers in Mechanisms of Machines.pptx
Unit-03 Cams and Followers in Mechanisms of Machines.pptx
Kirankumar Jagtap
Water Industry Process Automation & Control Monthly - April 2025
Water Industry Process Automation & Control Monthly - April 2025Water Industry Process Automation & Control Monthly - April 2025
Water Industry Process Automation & Control Monthly - April 2025
Water Industry Process Automation & Control
Virtual Power plants-Cleantech-Revolution
Virtual Power plants-Cleantech-RevolutionVirtual Power plants-Cleantech-Revolution
Virtual Power plants-Cleantech-Revolution
Ashoka Saket
Cloudera Partner Network Enablement Full.pdf
Cloudera Partner Network Enablement Full.pdfCloudera Partner Network Enablement Full.pdf
Cloudera Partner Network Enablement Full.pdf
Nguy畛n H畉i
Kamal 2, new features and practical examples
Kamal 2, new features and practical examplesKamal 2, new features and practical examples
Kamal 2, new features and practical examples
Igor Aleksandrov
SIMULATION OF FIR FILTER BASED ON CORDIC ALGORITHM
SIMULATION OF FIR FILTER BASED ON CORDIC ALGORITHMSIMULATION OF FIR FILTER BASED ON CORDIC ALGORITHM
SIMULATION OF FIR FILTER BASED ON CORDIC ALGORITHM
VLSICS Design
NBA Criteria TIER I and TIER II Comparison
NBA Criteria TIER I and TIER II ComparisonNBA Criteria TIER I and TIER II Comparison
NBA Criteria TIER I and TIER II Comparison
Dr INBAMALAR T M
DBMS Notes selection projection aggregate
DBMS Notes selection projection aggregateDBMS Notes selection projection aggregate
DBMS Notes selection projection aggregate
Sreedhar Chowdam
UHV UNIT-5 IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON ...
UHV UNIT-5    IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON ...UHV UNIT-5    IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON ...
UHV UNIT-5 IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON ...
ariomthermal2031
DBMS Nested & Sub Queries Set operations
DBMS Nested & Sub Queries Set operationsDBMS Nested & Sub Queries Set operations
DBMS Nested & Sub Queries Set operations
Sreedhar Chowdam
Floating Offshore Wind in the Celtic Sea
Floating Offshore Wind in the Celtic SeaFloating Offshore Wind in the Celtic Sea
Floating Offshore Wind in the Celtic Sea
permagoveu
Scalling Rails: The Journey to 200M Notifications
Scalling Rails: The Journey to 200M NotificationsScalling Rails: The Journey to 200M Notifications
Scalling Rails: The Journey to 200M Notifications
Gustavo Araujo
Distributed renewable energy in Colombia.OECD2023.pdf
Distributed renewable energy in Colombia.OECD2023.pdfDistributed renewable energy in Colombia.OECD2023.pdf
Distributed renewable energy in Colombia.OECD2023.pdf
SantiagoCardonaGallo
Intro of Airport Engg..pptx-Definition of airport engineering and airport pla...
Intro of Airport Engg..pptx-Definition of airport engineering and airport pla...Intro of Airport Engg..pptx-Definition of airport engineering and airport pla...
Intro of Airport Engg..pptx-Definition of airport engineering and airport pla...
Priyanka Dange
Mastering Secure Login Mechanisms for React Apps.pdf
Mastering Secure Login Mechanisms for React Apps.pdfMastering Secure Login Mechanisms for React Apps.pdf
Mastering Secure Login Mechanisms for React Apps.pdf
Brion Mario
Production Planning & Control and Inventory Management.pptx
Production Planning & Control and Inventory Management.pptxProduction Planning & Control and Inventory Management.pptx
Production Planning & Control and Inventory Management.pptx
VirajPasare
Telehealth technology A new horizon in health care
Telehealth technology  A new horizon in health careTelehealth technology  A new horizon in health care
Telehealth technology A new horizon in health care
Dr INBAMALAR T M
Introduction to Forensic Research Digital Forensics
Introduction to Forensic Research Digital ForensicsIntroduction to Forensic Research Digital Forensics
Introduction to Forensic Research Digital Forensics
SaanviMisar
Artificial intelligence and Machine learning in remote sensing and GIS
Artificial intelligence  and Machine learning in remote sensing and GISArtificial intelligence  and Machine learning in remote sensing and GIS
Artificial intelligence and Machine learning in remote sensing and GIS
amirthamm2083
Unit-03 Cams and Followers in Mechanisms of Machines.pptx
Unit-03 Cams and Followers in Mechanisms of Machines.pptxUnit-03 Cams and Followers in Mechanisms of Machines.pptx
Unit-03 Cams and Followers in Mechanisms of Machines.pptx
Kirankumar Jagtap
Virtual Power plants-Cleantech-Revolution
Virtual Power plants-Cleantech-RevolutionVirtual Power plants-Cleantech-Revolution
Virtual Power plants-Cleantech-Revolution
Ashoka Saket
Cloudera Partner Network Enablement Full.pdf
Cloudera Partner Network Enablement Full.pdfCloudera Partner Network Enablement Full.pdf
Cloudera Partner Network Enablement Full.pdf
Nguy畛n H畉i
Kamal 2, new features and practical examples
Kamal 2, new features and practical examplesKamal 2, new features and practical examples
Kamal 2, new features and practical examples
Igor Aleksandrov
SIMULATION OF FIR FILTER BASED ON CORDIC ALGORITHM
SIMULATION OF FIR FILTER BASED ON CORDIC ALGORITHMSIMULATION OF FIR FILTER BASED ON CORDIC ALGORITHM
SIMULATION OF FIR FILTER BASED ON CORDIC ALGORITHM
VLSICS Design
NBA Criteria TIER I and TIER II Comparison
NBA Criteria TIER I and TIER II ComparisonNBA Criteria TIER I and TIER II Comparison
NBA Criteria TIER I and TIER II Comparison
Dr INBAMALAR T M
DBMS Notes selection projection aggregate
DBMS Notes selection projection aggregateDBMS Notes selection projection aggregate
DBMS Notes selection projection aggregate
Sreedhar Chowdam
UHV UNIT-5 IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON ...
UHV UNIT-5    IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON ...UHV UNIT-5    IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON ...
UHV UNIT-5 IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON ...
ariomthermal2031
DBMS Nested & Sub Queries Set operations
DBMS Nested & Sub Queries Set operationsDBMS Nested & Sub Queries Set operations
DBMS Nested & Sub Queries Set operations
Sreedhar Chowdam
Floating Offshore Wind in the Celtic Sea
Floating Offshore Wind in the Celtic SeaFloating Offshore Wind in the Celtic Sea
Floating Offshore Wind in the Celtic Sea
permagoveu
Scalling Rails: The Journey to 200M Notifications
Scalling Rails: The Journey to 200M NotificationsScalling Rails: The Journey to 200M Notifications
Scalling Rails: The Journey to 200M Notifications
Gustavo Araujo
Distributed renewable energy in Colombia.OECD2023.pdf
Distributed renewable energy in Colombia.OECD2023.pdfDistributed renewable energy in Colombia.OECD2023.pdf
Distributed renewable energy in Colombia.OECD2023.pdf
SantiagoCardonaGallo
Intro of Airport Engg..pptx-Definition of airport engineering and airport pla...
Intro of Airport Engg..pptx-Definition of airport engineering and airport pla...Intro of Airport Engg..pptx-Definition of airport engineering and airport pla...
Intro of Airport Engg..pptx-Definition of airport engineering and airport pla...
Priyanka Dange
Mastering Secure Login Mechanisms for React Apps.pdf
Mastering Secure Login Mechanisms for React Apps.pdfMastering Secure Login Mechanisms for React Apps.pdf
Mastering Secure Login Mechanisms for React Apps.pdf
Brion Mario

Distributed Refactoring with Gradle Lint

  • 1. DISTRIBUTED REFACTORING WITH GRADLE LINT Jon Schneider Netflix Engineering Tools @jon_k_schneider GITHUB.COM/NETFLIXGRADLESUMMIT/LINT
  • 3. NETFLIX IS KNOWN FOR RAPID INNOVATION. GITHUB.COM/NETFLIXGRADLESUMMIT/LINT
  • 4. WE WANT TO MINIMIZE DRAG FROM LATE ADOPTERS. GITHUB.COM/NETFLIXGRADLESUMMIT/LINT
  • 5. NETFLIX CULTURE IS FREEDOM AND RESPONSIBILITY GITHUB.COM/NETFLIXGRADLESUMMIT/LINT
  • 6. GRADLE LINT ALLOWS US TO DISTRIBUTE CHANGE. GITHUB.COM/NETFLIXGRADLESUMMIT/LINT
  • 7. THE UNUSED DEPENDENCIES RULE HELPS MAINTAIN GOOD DEPENDENCY HYGIENE. GITHUB.COM/NETFLIXGRADLESUMMIT/LINT
  • 8. GRADLE LINT SUPPORTS SHIPPING METRICS TO nebula.metrics GITHUB.COM/NETFLIXGRADLESUMMIT/LINT
  • 9. CREATING A MORE COMPLEX RULE "All wars should be published to our binary repository" GITHUB.COM/NETFLIXGRADLESUMMIT/LINT
  • 10. 1: APPLY IMMEDIATELY AFTER THE WAR PLUGIN class AllWarsShouldBePublishedRule extends GradleLintRule { @Override void visitApplyPlugin(MethodCallExpression call, String plugin) { if(plugin == 'war') { addBuildLintViolation('WARs must be published', call) .insertAfter(call, "apply plugin: 'netflix.war-publish'") } } } GITHUB.COM/NETFLIXGRADLESUMMIT/LINT
  • 11. 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')) { addBuildLintViolation('WARs must be published', call) .insertAfter(bookmark('applyWar'), "apply plugin: 'netflix.war-publish'") } } } GITHUB.COM/NETFLIXGRADLESUMMIT/LINT
  • 12. 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')) { addBuildLintViolation('WARs must be published', call) .replaceWith(bookmark('applyWar'), "apply plugin: 'netflix.war-publish'") } } } GITHUB.COM/NETFLIXGRADLESUMMIT/LINT
  • 13. 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')) { addBuildLintViolation('WARs must be published', call) .insertAfter( bookmark('lastApplyPlugin'), "apply plugin: 'netflix.war-publish'" ) } } } GITHUB.COM/NETFLIXGRADLESUMMIT/LINT
  • 14. GRADLE LINT IS OUR FIRST DISTRIBUTED REFACTORING TOOL. GITHUB.COM/NETFLIXGRADLESUMMIT/LINT
  • 15. THE EXPERIMENTAL LOCK PLUGIN IS ANOTHER EXAMPLE. github.com/nebula-plugins/lock- experimental GITHUB.COM/NETFLIXGRADLESUMMIT/LINT
  • 16. WE WANT AN EVENTUALLY CONSISTENT MONOREPO THROUGH DISTRIBUTED REFACTORING. GITHUB.COM/NETFLIXGRADLESUMMIT/LINT
  • 17. JAVA POWER ASSERT WAS THE LEARNING GROUND. github.com/jkschneider/java-power-assert GITHUB.COM/NETFLIXGRADLESUMMIT/LINT