Spring Boot Starter Workbench Project utilizing Gradle as Build Tool
This workbench project demonstrates how to setup a Spring Boot Starter and Auto Configuration as a project using Gradle, Java and Kotlin.
It includes the following sub-projects:
greet-library: A sample library that is configured by the Starter and is mandatory for all consumer applications. It is therefore automatically included as a transitive dependency.
greet-opt-library: A sample library that is configured by the Starter and is optional for consumer applications. It has to be explicitly declared as a dependency by the consumer.
gradle-workbench-spring-boot-autoconfigure: The autoconfiguration implementation. It shows how to handle classes that may not be present on the classpath when the consumer is running.
gradle-workbench-spring-boot-autoconfigure-kt: The autoconfiguration implemented in Kotlin.
gradle-workbench-spring-boot-starter: The Spring Boot Starter that is declared as a dependency by the consumer and references all mandatory transitive dependencies.
gradle-workbench-spring-boot-starter-kt: The Spring Boot Starter referencing the Kotlin implementation of the autoconfiguration.
sample-application-simple: A cli Spring Boot application demonstrating the usage of the Starter without using the optional library.
sample-application-optional: A cli Spring Boot application demonstrating the usage of the Starter including the optional library.
integration-test: A module demonstrating how to write integration tests that utilize the auto-configuration implementation.
How to build
The libraries, starter and autoconfiguration are build as Gradle multi-project. The sample applications are separate Gradle projects.
The starter project has to be build and published to the local maven repository once before building the sample applications.
Build the Starter and Libraries
To build the starter, auto-configuration and library projects and publish them to the local maven repository use
./gradlew clean build publishToMavenLocal.
Build and run the Sample Applications
In either the
sample-application-optional folder use
./gradlew clean bootRun to start the application.
Execute the Integration Tests
By default the integration-tests will be disabled. To run them use the
integrationTest gradle task.
Where to get more Information
A great video outlining some of these concepts is YouTube: Spring Tips: Organizational Consistency in your Spring Boot Applications