Our great sponsors
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
-
monorepo.tools
Your defacto guide on monorepos, and in depth feature comparisons of tooling solutions.
plugins { id 'java-gradle-plugin' id 'com.gradle.plugin-publish' version '1.1.0' } group = 'io.github.simonharmonicminor.code.style' sourceCompatibility = '8' repositories { mavenCentral() } ext { set('lombokVersion', '1.18.24') } dependencies { compileOnly "org.projectlombok:lombok:${lombokVersion}" annotationProcessor "org.projectlombok:lombok:${lombokVersion}" testImplementation 'org.junit.jupiter:junit-jupiter:5.7.2' } gradlePlugin { website = 'https://github.com/SimonHarmonicMinor/gradle-code-style-plugin-example' vcsUrl = 'https://github.com/SimonHarmonicMinor/gradle-code-style-plugin-example' plugins { gradleCodeStylePluginExample { id = 'io.github.simonharmonicminor.code.style' displayName = 'Gradle Plugin Code Style Example' description = 'Predefined Checkstyle and PMD rules' implementationClass = 'io.github.simonharmonicminor.code.style.CodingRulesGradlePluginPlugin' tags.set(['codestyle', 'checkstyle', 'pmd']) } } } tasks.named('test') { useJUnitPlatform() }
PMD and Checkstyle are static analysis tools that check your code on each project build. Gradle allows to apply them easily.
If your entire project (or even company) is the monorepository, then this setup is absolutely fine. You just need to put these configurations in the root build.gradle file to apply those plugins for every existing module. But what if your choice is polyrepository? What if you want to share the same code style within all the projects in the company that developers are working on (and all the ones the programmers will create in the future)? Well, you can tell them to simply copy and paste the plugins’ configuration. Anyway, that’s an error-prone approach. There is always a probability that somebody does some misconfiguration.