..O Deniz's personal pages
/home /about

Spring Boot multi module with Gradle

August 13, 2014

Gradle is a build tool in the java world that will one day hopefully deprecate maven. I hate editing XML (like most other humans) and Gradle uses it’s own DSL (looks like groovy) to define you build file. Spring boot has a great plugin for Gradle which make setting up the build easier. To create a multi module project for Spring boot with Gradle here are the steps you need to follow:

Root configuration

in the root directory of your project create a file called settings.gradle and add this content

include "my-sub-module1"
include "my-sub-module2"

add all the sub modules with an include directive. Now create a file build.gradle in the root directory and add the following

buildscript {
    repositories {
    dependencies {

Sub-module configuration

Now for each sub-module that you have you will create a build.gradle file in the sub-module directory with the content

apply plugin: "java"
apply plugin: "idea"
apply plugin: "eclipse"
apply plugin: "spring-boot"
apply plugin: "war"
repositories {
    maven { url "http://mvn.dendiz.com/repository/internal" }

dependencies {
    testCompile "junit:junit:4.11"

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    // tag::jetty[]
    compile("org.springframework.boot:spring-boot-starter-web") {
        exclude group:"org.springframework.boot", module: "spring-boot-starter-jetty"

adjust your plugins and dependencies as needed, these are just some example dependencies.

Tags: #programming