Creating a distribution zip file using Spring Boot and Gradle

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

  • Spring boot box created at launch of "gradle build" (located in build / libs / x.jar file)
  • Configuration folder with some files located in src / dist / config

It is preferable that this zip file be created when you run "gradle build" (but another task is fine if this is difficult to achieve). Is there a good way to achieve this?

+6
source share
2 answers

Something like that?

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

I did something similar to what Dave Sir 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 suggestions for improvement are welcome.

+1
source

All Articles