Saturday, July 27, 2019

Part-1: Spring & Gradle - Multi Module Project

Overview:
In this article, we’ll implement a spring boot multi module application. We’ll use gradle build system. The goal is here to create a microservices application which will be covered in the upcoming articles.
Layout:
Here we are going to use flat layout to keep the application directories as siblings of the root project directory (Pic-1). The advantage of flat layout is we can have the distinct git repository for every application. In your root project’s settings.gradle file, we need to use the includeFlat with the subproject.
Pic-1. Directory Structure
Project: root
This project having only the project configuration files such as build.gradle and settings.gradle.

settings.gradle:
rootProject.name = 'root'
includeFlat 'utilities', 'exception-handler’, 'discovery-server' 
includeFlat 'enquiry', 'api-gateway', 'registration' 
build.gradle:
buildscript {
ext {
springBootVersion = '2.1.6.RELEASE' 
}
repositories {
mavenCentral() 
}
dependencies
classpath("org.springframework.boot:spring-boot-gradle- plugin:${springBootVersion}"
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'


group = 'com.apandiyan' 
version = '0.0.1'
sourceCompatibility = '1.8' 
repositories
mavenCentral() 
}
ext {
set('springCloudVersion', "Greenwich.SR1"
}
dependencies
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud- dependencies:${springCloudVersion}"
}
}

}


Source: https://github.com/pandiyan90/microservice-blog/tree/master/root

No comments:

Post a Comment