Gradle build plugin for the Quantum Leap project, so the project's build scripts can be smaller and cleaner. Probably its not useful for anything else except for Quantum Leap, but you can check it out and get some inspiration from it.
Quantum Leap is a project template for building Java multi-module web applications backed by Spring Boot, jOOQ, Thymeleaf and PostgreSQL. The plugin expects following project structure.
root project <-- Here's applied the plugin
|
+--- core module <-- Module that contains main class annotated by @SpringBootProject annotation. Name of the module has to be "core".
|
\--- some other modules
- Applies Spring Boot Gradle plugin to a root project and provides alternative facility for finding project's main class which can be located outside of the root project.
- New
generateJooqDomainObjects
task, generates jOOQ domain objects tosrc/generated/java
directories.- Schemata for a particular module are detected by parsing
CREATE SCHEMA
statement from scripts insrc/resources/db/scripts
and domain objects are generated into the module. - Generator configuration is read from
db/jooq-generator-configuration.xml
file located in resources of modules. - Database configuration is read from
config/application-default.properties
properties file, also located in resources. Following properties are recognized:- spring.datasource.url
- spring.datasource.username
- spring.datasource.password
- Schemata for a particular module are detected by parsing
- New
discoverProjectDependencies
task. It discovers dependencies between project's modules and serializes this structure intoprojectDependencies.ser
files and puts those into resources directory of every module. Structure is used in Quantum Leap project to sort resources loaded from various modules, etc. - Upgrades Thymeleaf to version 3.x.
- Adds Maven Central Repository and JitPack Repository to all projects in the multi-project build.
The plugin uses new Gradle plugins DSL to avoid some problems connected to a Kotlin build scripts, and an old way of apply plugins.
-
Add the plugin repository to your project's
settings.gradle.kts
file.pluginManagement { repositories { mavenCentral() maven(url = "https://jitpack.io") } }
-
Apply the plugin to your root module
build.gradle.kts
.plugins { id("com.github.vkuzel.Quantum-Leap-Gradle-Plugin") version "2.5.6-1" }
-
Optionally specify location of a main class in a module that contains it.
ext { // Parameter mainClass allows you to set Spring Boot's main class // explicitly and to suppress *MainClassName tasks. Usually should be set // in the module where @SpringBootApplication is located. mainClass = "your.class.Name" }
-
In the root project run the
generateModuleDependencies
task to generate and store module dependencies to resources files.gradle generateModuleDependencies
-
Run the
generateJooqDomainObjects
task to generate domain objects from the database schema. Generated classes will be stored insrc/generated/java
directory.gradle generateJooqDomainObjects
-
Start the application.
gradle bootRun
-
Build the plugin into your local Maven repository.
./gradlew publishToMavenLocal
-
Configure your project to use the plugin located in the local Maven repository.
// settings.gradle.kts pluginManagement { repositories { mavenLocal() } }
// build.gradle.kts plugins { id("com.github.vkuzel.Quantum-Leap-Gradle-Plugin") version "correct version" }
- Spring Boot 2.5.6
- ProjectDependencies 3.0.0