Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 454
Johan Avatar asked Apr 04 '14 11:04

Johan


People also ask

Can gradle be used with spring boot?

The Spring Boot Gradle Plugin provides Spring Boot support in Gradle. It allows you to package executable jar or war archives, run Spring Boot applications, and use the dependency management provided by spring-boot-dependencies . Spring Boot's Gradle plugin requires Gradle 6.8, 6.9, or 7.

What is distribution in gradle?

The Distribution Plugin facilitates building archives that serve as distributions of the project. Distribution archives typically contain the executable application and other supporting files, such as documentation.

What is bootJar in gradle?

bootJar on the other hand is a specific task added by Spring Boot Gradle plugin that, when the java plugin is present, attaches itself to the assemble lifecycle task. The assemble task is automatically configured to depend upon the bootJar task so running assemble (or build ) will also run the bootJar task.


1 Answers

Something like this?

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

build.dependsOn(zip)
like image 57
Dave Syer Avatar answered Oct 05 '22 06:10

Dave Syer