Java jar ant include folder

My question is: how can I put files into subdirectories into my jar through ants? Now my code is:

<jar destfile="${dist.dir}\wo42.jar" basedir="bin">
<manifest>
    <attribute name="Main-Class" value="org.alternativedev.wo42.App" />
    <attribute name="Class-Path" value="lib" />
</manifest>
<zipgroupfileset dir="lib/." excludes="natives/*" />
<fileset dir="data/." includes="." />

It creates a structure

ROOT-Jar
-org
--bla
-filefromdata1
-filefromdata2

But it should be

ROOT-Jar
-org
--bla
-data
--filefromdata1
--filefromdata2

Are you with me?

Greetings, bigteddy

Solution

Change the last line to

<fileset dir="." includes="data/**" />

There is no need to copy files

An alternative (useful if you want directories in the archive to have different names)

<zipfileset dir="data" includes="." prefix="folder-name-in-jar"/>
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
分享
二维码
< <上一篇
下一篇>>