Ruthless conventions for Gradle projects to keep them DRY. Inspired by buildSrc conventions
generated by Gradle init. Selfishly tailored for my taste, sorry.
If you are looking for a flexible way of sharing build logic between projects, without enforcing someone else's coding conventions and dependency versions, you might want to have a look at Blowdryer.
dev.lajoscseppento.ruthless- multi-use plugin, can apply to init, settings or project- 5 plugins, choose the best fit:
dev.lajoscseppento.ruthless.java-application- Java applicationdev.lajoscseppento.ruthless.java-gradle-plugin- Java Gradle Plugindev.lajoscseppento.ruthless.java-library- Java librarydev.lajoscseppento.ruthless.spring-boot-application- Spring Boot applicationdev.lajoscseppento.ruthless.spring-boot-library- Spring Boot library
- Multi-project support
- Lombok by default (it can be disabled via
ruthless.lombok) - Default dependency versions for Guava, Lombok, Jackson, JUnit 5, Mockito, AssertJ... and more!
dev.lajoscseppento.ruthless.logging- logging conventions are also available as a standalone plugin
For examples see ruthless-demo and ruthless-logging-demo. For details, see the source code.
First, create gradle.properties:
group=com.example
version=0.1.0-SNAPSHOT
org.gradle.caching=true
org.gradle.parallel=true
org.gradle.configureondemand=trueThen, settings.gradle.kts to apply defaults. This will apply a base Ruthless plugin to all
subprojects (multi-project is not enforced, you can go with single-project if you like that
setup more):
plugins {
id("dev.lajoscseppento.ruthless") version "0.8.0"
}
rootProject.name = "my-project"
include(
"my-project-app",
"my-project-lib"
)Then in build.gradle.kts for each project, you can specify the project type to apply basic
setup (not obligatory):
// For a Java library:
plugins {
id("dev.lajoscseppento.ruthless.java-library")
}
// For a Spring Boot application
plugins {
id("dev.lajoscseppento.ruthless.spring-boot-application")
}See ruthless-demo for a complete example.
Ruthless is a standard Gradle plugin project.
For manual local testing, it is recommended to publish the plugin to the local Maven repository.
./gradlew publishToMavenLocalThen use the local snapshot in the demo project:
# Full demo
cd ruthless-demo
../gradlew --init-script init-dev.gradle.kts ...
# Logging-only demo
cd ruthless-logging-demo
../gradlew --init-script init-dev.gradle.kts ...- Fix version, finalise change log
- Publish to Maven Central
- Run
./gradlew publishToSonatype closeSonatypeStagingRepository - Open https://oss.sonatype.org/#stagingRepositories
- Inspect contents
- Release
- Run
- Publish to Gradle Plugin Portal using
./gradlew publishPlugins - Bump version
- Upgrade to recently released version (
ruthless,ruthless-demoandruthless-logging-demo)