3

It very much looks like spring boots gradle plugin is not packaging the contents of src/dist like application plugin does. How can I add the contents of src/dist add to my spring boot distribution zip and tar?

plugins {
    id 'java'
    id 'application'
    id 'org.springframework.boot' version '2.0.2.RELEASE'
    id "io.spring.dependency-management" version "1.0.5.RELEASE"
}

version '1.0-SNAPSHOT'

repositories {
    jcenter()
    mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8
mainClassName = "kic.data.server.Server"

dependencies {
    compile 'org.springframework.boot:spring-boot-starter'
    compile 'org.springframework.boot:spring-boot-starter-web'
    compile 'org.apache.commons:commons-lang3:3.7'

    testCompile group: 'junit', name: 'junit', version: '4.12'
    testCompile "org.springframework.boot:spring-boot-starter-test"

    testCompile 'org.spockframework:spock-core:1.1-groovy-2.4'
    testCompile 'org.hamcrest:hamcrest-core:1.3'
    testCompile "com.github.tomakehurst:wiremock-standalone:2.16.0"

}
KIC
  • 5,887
  • 7
  • 58
  • 98

2 Answers2

5

I could solve it. To add back the src/dist/ folder I just needed to add this to my build.gradle. A pity that spring boot supports lookup of files in a config folder but the distribution plugin just ignores it.

bootDistZip {
    into("${project.name}-boot-${project.version}") {
        from './src/dist/'
    }
}

bootDistTar {
    into("${project.name}-boot-${project.version}") {
        from './src/dist/'
    }
}
KIC
  • 5,887
  • 7
  • 58
  • 98
0

I encountered the same issue and wasn't able to solve it using the accepted response.

Here is what worked for me (using Gradle Kotlin DSL)

distributions.getByName("boot", Distribution::class) {
    val distCopySpec = project.copySpec().from("src/dist")
    this.contents.with(distCopySpec)
}

Looking at the source code from Spring Boot Gradle Plugin (version 2.7), I saw that it creates a distribution named "boot". The code above retrieve this distribution and add a new CopySpec into it to copy the content of ths src/dist folder

nicopico
  • 3,606
  • 1
  • 28
  • 30