Spring Boot Multi Gradle Module Assembly - Multiple Fatty Cans

our spring-boot project is as follows

project
|__ build.gradle
|__ settings.gradle
   |__ module_a
   |__ module_b
   |__ ...
|__ module_a
|__ module_b

module_a contains only the SpringApplication class and application.properties file

Starting. / Gradlew build works fine, but the problem is that for each module (about 10) gradle a fat jar is created, including all the dependencies.

We want to have only one distant can (in module a)

buildscript {
    ext {
        springBootVersion = '1.2.0.RELEASE'
        springLoadedVersion = '1.2.0.RELEASE'
    }
    repositories {
        // NOTE: You should declare only repositories that you need here
        mavenCentral()
        maven { url "http://repo.spring.io/release" }
        maven { url "http://repo.spring.io/milestone" }
        maven { url "http://repo.spring.io/snapshot" }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        classpath("org.springframework:springloaded:${springLoadedVersion}")
    }
}


allprojects {

    group = "example.group"
    version = "0.0.1"

    repositories() {
        mavenCentral()
    }

}


subprojects {

    apply plugin: "groovy"
    apply plugin: "eclipse"

    eclipse {
        classpath {
            containers.remove("org.eclipse.jdt.launching.JRE_CONTAINER")
            containers "org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"
        }
    }

    apply plugin: "idea"
    apply plugin: "java"
    apply plugin: "spring-boot"

    mainClassName = "MainClassName"

    sourceCompatibility = 1.8
    targetCompatibility = 1.8

    dependencies {
    }
}

task wrapper(type: Wrapper) { gradleVersion = '2.2' }

We tried to add the parameters jar.enabled = false bootRepackage.enabled = false

in the subprojects section, but after that the project will no longer compile.

+4
source share
1 answer

, Spring Boot , module_a:

project(':module_a') {
    apply plugin: 'org.springframework.boot'
}
+5

All Articles