How to extract a WAR without applying the Ziptree on binary files?


(Anirban Roy) #1

Hi Experts,

I am using gradle 3.0 (with apply plugin: ‘war’) in my project to build my web java application war. There is a exploded war task which explodes the war and places the contents in a directory for tomcat to serve. My project uses a SQLite DB file for a feature and this file is to be shipped with WAR. However, when the exploded war task runs it tries to unzip the DB file as well and in the process corrupts it thereby stopping the functionality. Original file size 116MB, exploded file size 128MB. Below is my explodedwar task:

task explodedWar(type: Copy, dependsOn: war) {
  def warFileName = tasks['war'].archiveName
  def zipFile = file('build/libs/' + warFileName)
  def outputDir = file("build/exploded")

  from zipTree(zipFile)
  into outputDir
}

I have tried changing the DB file extension to .db from .dat (default for my library) and it did not work either. I want the DB file to be shipped with the war and as such need gradle to not try to decompress the binary file. Please help!!

Thanks,
Roy


(Lance Java) #2

What’s the path to the db file inside the war? How does it get there? Perhaps a filter is corrupting the binary during copy operation?


(Anirban Roy) #3

@Lance_Java The file is placed under /src/main/resources and it gets copied to /bin directory during building step.