Ant - Zip Multiple Folders
<p>I'm trying to run an Ant job within Maven to look at a folder, and based on how many folders are in that folder, to create x number of zip files with the name of the folder. I have it working manually, but it would be nice if I didn't have to edit the pom each time I added a new folder to this structure.</p>

<pre><code>&lt;configuration&gt;
    &lt;target name="zip"&gt;
        &lt;zip destfile="root/sub1/sub1.jar"&gt; 
        &lt;zipfileset dir="root/sub1/unpacked/" includes="**" &gt;&lt;/zipfileset&gt;
        &lt;/zip&gt;
    &lt;/target&gt;
&lt;/configuration&gt;
</code></pre>

<p>If I were to add sub2 to the root dir, I would like it to be picked up automagically, and create a sub2.jar file (yes, I'm aware I'm using .jar, but the program that is taking these files expects .jar files, but they're not jar files in that they contain any Java code, they're just zip files with jar extensions)</p>

<p>I've tried this</p>

<p>Thanks I had a look at the first link, but perhaps I'm doing it wrong</p>

<pre><code>&lt;target name="checkDir"&gt;
    &lt;foreach target="zip" param="theFile"&gt;
        &lt;dirset dir="root" casesensitive="yes"&gt;
            &lt;include name="**"/&gt;
        &lt;/dirset&gt;
    &lt;/foreach&gt;
    &lt;/target&gt;
&lt;target name="zip"&gt;
&lt;!-- &lt;zip destfile="root/${theFile}/${theFile}.jar"&gt; 
                            &lt;zipfileset dir="root/${theFile}/unpacked/" includes="**" &gt;&lt;/zipfileset&gt;
&lt;/zip&gt; --&gt;
&lt;echo message="${theFile}"/&gt;
&lt;/target&gt;
</code></pre>

<p>I just get</p>

<p>[INFO] --- maven-antrun-plugin:1.7:run (process-javascript-plugin) @ war---
[INFO] Executing tasks</p>

<p>zip:
     [echo] ${theFile}
[INFO] Executed tasks</p>

<hr>

<p>Still doesn't seem to be working.</p>

<p>pom.xml</p>

<pre><code>&lt;plugin&gt;
                &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                &lt;artifactId&gt;maven-antrun-plugin&lt;/artifactId&gt;
                &lt;version&gt;1.7&lt;/version&gt;
                &lt;executions&gt;
                    &lt;execution&gt;
                        &lt;id&gt;process-cartridges&lt;/id&gt;
                        &lt;phase&gt;compile&lt;/phase&gt;
                        &lt;configuration&gt;
                        &lt;target&gt;
                           &lt;ant antfile="root/build-main.xml"/&gt;
                        &lt;/target&gt;
                        &lt;/configuration&gt;
                    &lt;/execution&gt;
                &lt;/executions&gt;
            &lt;/plugin&gt;
</code></pre>

<p>build-main.xml</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
&lt;project&gt;
    &lt;target name="checkDir"&gt;
        &lt;foreach target="zip" param="theFile"&gt;
            &lt;dirset dir="root" casesensitive="yes"&gt;
                &lt;include name="**"/&gt;
            &lt;/dirset&gt;
        &lt;/foreach&gt;
    &lt;/target&gt;
    &lt;target name="zip"&gt;
        &lt;zip destfile="root/${theFile}/${theFile}.jar"&gt; 
            &lt;zipfileset dir="root/${theFile}/unpacked/" includes="**" /&gt;
        &lt;/zip&gt;
        &lt;echo message="TESTZIP ${theFile}"/&gt;
    &lt;/target&gt;
&lt;/project&gt;
</code></pre>

<p>Doesn't seem to be working. Am I missing anything?</p>