Johan
Johan

Reputation: 40530

Creating a distribution zip file with Spring Boot and Gradle

I'm using Spring Boot (1.0.0.RELASE) and I want to create a distribution zip file containing the following:

  1. The spring boot one-jar created when running "gradle build" (located in build/libs/x.jar)
  2. A config folder with some files that are located in src/dist/config

Preferable I would like this zip file to be created when running "gradle build" (but another task is fine if this is hard to achieve). Is there nice way to achieve this?

Upvotes: 8

Views: 5828

Answers (2)

Johan
Johan

Reputation: 40530

I did something similar to what Dave Syer suggested:

task zip(type: Zip, dependsOn: bootRepackage) {
  def fileName = "${jar.baseName}-${jar.version}"
  from projectDir
  include "script.sh"
  from file("$buildDir/libs")
  include "${fileName}.jar"
  from file('src/dist')
  include "config/application.yml"
  archiveName "${fileName}.zip"
}

build.dependsOn(zip)

Any improvement suggestions are welcome.

Upvotes: 3

Dave Syer
Dave Syer

Reputation: 58094

Something like this?

task zip(type: Zip, dependsOn: bootRepackage) {
    from('build/libs') {
        include '*.jar'
    }
    from 'conf'
}

build.dependsOn(zip)

Upvotes: 11

Related Questions