Java – ant: jar and zipfileset – copy files from one jar to another
•
Java
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 has been updated to include files extracted from the application jar as needed
So far, it's very good
However, I want to modify the behavior so that the path of the image file is different from the path copied from it:
Currently:
com/izforge/izpack/panels/MyIzPanel.class com/xyz/img/logo.png
What I want is:
com/izforge/izpack/panels/MyIzPanel.class blah/img/logo.png
So I need to copy the files, but use < zipfileset > and < jar > in a way that I can modify the directory structure
Is there a way to do this, except to unzip the entire content, copy the file, and then pull it back again?
Edit:
Link to the previous related question: ant task to remove files from a jar
Solution
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 multiple files, you may need to view prefix properties, for example:
<zipfileset src="${pwd}/dist/app.jar" includes="**/*.png" prefix="blah/img"/>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码