I'm scripting some deployment steps for sending static resources to my SF org. What are valid zip commands for static resources? If I'm running the build on a build server with a bash shell is there a recommended zip tool and arguments for creating a zipped static resource?

When I've done this in OSX I've used:

ditto -ck --rsrc --sequesterRsrc $sourceFolder $targetResource

That seems to work if I upload the resource directly via the Setup -> Static Resources in my org but I'm looking for something that will reliably work with the Force.com migration tool.


2 Answers 2


I've done something similar to Keith C's answer, so thought I'd include it here as well.

I've set up an 'unzippedStaticResources' directory within my project where I store the unzipped version of my static resource. When I do an ant deploy, an ant task automatically zips up the contents and copies it to the staticresource directory before the deployment happens.

Zip macrodef

<macrodef name="zip-static-resource">
    <attribute name="zipName"/>
        <echo message="Zipping: @{zipName}"/>
        <zip destfile="${srcDir}/staticresources/@{zipName}.resource" basedir="${unzippedDir}/@{zipName}" update="true" whenempty="fail"/>

To deploy

<target name="deploy">
        <zip-static-resource zipName="myZipFile1"/>
        <zip-static-resource zipName="myZipFile2"/>
        <sf:deploy ..... />

Then when I want to retrieve metadata from Salesforce, I automate the unzipping of the static resource and copy it to the unZipped directory.

Unzip macrodef

<macrodef name="unzip-static-resource">
    <attribute name="zipName"/>
        <echo message="Unzipping: @{zipName}"/>
        <delete dir="${unzippedDir}/@{zipName}"/>
        <unzip src="${srcDir}/staticresources/@{zipName}.resource" dest="${unzippedDir}/@{zipName}" failOnEmptyArchive="true"/>

To retrieve

<target name="retrieve">
        <sf:retrieve ..... />
        <unzip-static-resource zipName="myZipFile1"/>
        <unzip-static-resource zipName="myZipFile2"/>

In this code I have a few properties set up:

<property name="srcDir" value="src" />
<property name="unzippedDir" value="unzippedStaticResources" />

I'm pretty new to Ant, so let me know if there's a better way to do things.

Ideally, I'd like the Ant script to automatically unzip all *.resource files (that are zip files) in the staticresource directory, and automatically zip up all directories in my 'unzippedStaticResources' directory.


The Force.com Migration Tools are Ant based so it makes sense to use the Ant zip features such as zip and zipfileset to create the zip file. These have worked fine for me.

Here is a random example from a project:

<target name="create zip">
    <zip destfile="phoneGapExternalContent.zip">
        <zipfileset dir="." includes="indexExternalContent.html" fullpath="index.html"/>
        <fileset dir="." includes="config.xml"/>
        <zipfileset dir="data" includes="Cv-Eep-120x120.png" fullpath="icon.png"/>
        <zipfileset dir="data" includes="Cv-Eep-640x960.png"/>
        <zipfileset dir="data" includes="Cv-Eep-640x1136.png"/>

You can make the output file a .resource file in the src/staticresources folder that following Force.com Migration Tool Ant targets can push into an org.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .