I would like to include file to zipfileset
but rename it as well
e.g.
<zipfileset dir="${basedir}/test/target" prefix="webapps">
<include name="test*.war"/>
</zipfileset>
but want to change name from test.war
to sample.war
how to achieve this ? thank you.
You can probably do what you want using a mappedresources
resource collection.
This 'worked for me' in a basic test (one input war called test1.war
):
<mappedresources id="mapped.zfs">
<zipfileset dir="${basedir}/test/target">
<include name="test*.war"/>
</zipfileset>
<globmapper from="test*" to="webapps/sample*" />
</mappedresources>
<zip destfile="eg.zip">
<resources refid="mapped.zfs" />
</zip>
% unzip -l eg.zip
Archive: eg.zip
Length Date Time Name
--------- ---------- ----- ----
0 11-27-2012 00:19 webapps/
1423 11-27-2012 00:16 webapps/sample1.war
--------- -------
1423 2 files
I don't think this is possible, I'd go for 2 steps approach.
Either rename and add:
<move file="${basedir}/test/target/test.war" tofile="${basedir}/test/target/sample.war"/>
<zipfileset dir="${basedir}/test/target" prefix="webapps">
<include name="sample*.war"/>
</zipfileset>
or copy and add (if you need both):
<copy file="${basedir}/test/target/test.war" tofile="${basedir}/test/target/sample.war"/>
<zipfileset dir="${basedir}/test/target" prefix="webapps">
<include name="sample*.war"/>
</zipfileset>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With