Gradle Zip All Feature

Had a need to zip an entire website, all the bits and pieces, images, you name it. Had tried to write a gradle script that would do it from a folder like this:

folder layout of my web app
folder layout of my web app

and you would have thought it’d be easy-peasy. Well not so on my aging windows XP system. Any script using a gradle (type:Zip) task would bomb with ‘portion of file in use by another task’ – drat !

So dumped whole web app to a USB key and took it to my Apple Macbook 10.6.8. Using the same gradlew command this worked a charm:

 task zipAll(type: Zip) {
 from projectDir
 exclude 'build/**'
 }

Basically, it says from the root of the directory folder of my web app, thats the ‘projectDir‘ declaration, zip it all but don’t include the sub-folder build/ or it’s contents either. Giving me:

Screen shot 2014-03-17 at 7.13.48 AM

Well now, that’s more like it ! And since i did not say where to store the zip file, gradle puts it into the build/distributions/ folder :

Screen shot 2014-03-17 at 7.15.52 AM

but also demonstrates why i excluded the build/ folder from the zip task as it would create a circular reference issue, i.e. zip into the build folder that gets included in the zip archive, which gets … 😛

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s