How to build only exploded war with gradle?


(Gennady Shumakher) #1

For our project the creation of war file takes too long, so coming from maven we used to execute only

mvn war:exploded

What is the best way to achieve that with gradle?

Thanks.


(James Justinic) #2

This will create a task that takes all the files that would be in the war file, but copies them into a folder instead of creating the war:

task explodedWar(type: Sync) {
    into "${buildDir}/exploded"
    with war
} 

However, I’m not sure that you will see any performance improvement by doing this. Either way, the implementation of these tasks is still copying data from one place to another on disk, so the difference between the two is the performance of the zip algorithm vs. overhead for writing many small files. Personally, I’ve seen the zip algorithm normally win that race with large Java applications on modern hardware. If your application has a few very large files, I could see you being on the opposite side of the tipping point though.


(Gennady Shumakher) #3

Thanks a lot! It is very useful.