Skip to content

vkuzel/Quantum-Leap-Gradle-Plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quantum Leap Gradle Plugin

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

Features

  • 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 to src/generated/java directories.
    • Schemata for a particular module are detected by parsing CREATE SCHEMA statement from scripts in src/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
  • New discoverProjectDependencies task. It discovers dependencies between project's modules and serializes this structure into projectDependencies.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.

Getting Started

Configuration

The plugin uses new Gradle plugins DSL to avoid some problems connected to a Kotlin build scripts, and an old way of apply plugins.

  1. Add the plugin repository to your project's settings.gradle.kts file.

    pluginManagement {
        repositories {
            mavenCentral()
            maven(url = "https://jitpack.io")
        }
    }
  2. Apply the plugin to your root module build.gradle.kts.

    plugins {
        id("com.github.vkuzel.Quantum-Leap-Gradle-Plugin") version "2.5.6-1"
    }
  3. 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"
    }

Run

  1. In the root project run the generateModuleDependencies task to generate and store module dependencies to resources files.

    gradle generateModuleDependencies
  2. Run the generateJooqDomainObjects task to generate domain objects from the database schema. Generated classes will be stored in src/generated/java directory.

    gradle generateJooqDomainObjects
  3. Start the application.

    gradle bootRun

Development

  1. Build the plugin into your local Maven repository.

    ./gradlew publishToMavenLocal
  2. 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"
    }

Library versions