tags:

views:

92

answers:

1

I am currently doing this:

    <jar update="yes"
      jarfile="${pwd}/dist/${release}_installer.jar">
      <zipfileset src="${pwd}/dist/app.jar" includes="com/izforge/izpack/panels/**"/>
      <zipfileset src="${pwd}/dist/app.jar" includes="com/xyz/img/logo.png"/>
    </jar>

My existing installer JAR gets updated to include the files as needed, extracted from the app JAR.

So far, so good.

However, I want to modify the behaviour such that the path of the image file is different than what is being copied from:

Currently:

com/izforge/izpack/panels/MyIzPanel.class
com/xyz/img/logo.png

What I want:

com/izforge/izpack/panels/MyIzPanel.class
blah/img/logo.png

So I need to copy the files, but use <zipfileset> and <jar> in such a way that I can modify the directory structure.

Is there a way to do this, apart from unzipping the entire contents copying file and then zipping it back up again?


EDIT:

Link to earlier related question: http://stackoverflow.com/questions/2521231/ant-task-to-remove-files-from-a-jar

A: 

You can use the fullpath attribute:

<zipfileset src="${pwd}/dist/app.jar"
    includes="com/xyz/img/logo.png" fullpath="blah/img/logo.img"/>

If you need to copy several files you may want to have a look at the prefix attribute, e.g.:

<zipfileset src="${pwd}/dist/app.jar"
    includes="**/*.png" prefix="blah/img"/>
Grodriguez
@Grodriguez I did trry prefix, h/w I get `blah/img/com/xyz/img/logo.png` instead of `blah/img/logo.png`, which is what I want.
bguiz
I have updated my answer, try `fullpath` instead.
Grodriguez
@Grodriguez Yup, `fullpath` does work for a single file, however I have got multiple `.png` files which I want to map... I have been looking at the `mapper` ( http://ant.apache.org/manual/Types/mapper.html ) ant types, but haven't managed to get them working...
bguiz
For more than one file, if `prefix` does not suit your needs, then yes, you will need to use mappers.
Grodriguez