How to add full folder to jar file using ant

I would like to create as a "live" jar with ant, where I have not only the usual classes, manifest files, etc., but also my "libs" folder.

I tried:

<jar destfile="myjar.jar" update="yes" basedir="${libs.dir}"/>

but this adds the files in the "libs" to the root of the jar file, where I would like to have the libs folder in the bank (with all that it contains, of course)

Is it possible to create the lib folder directly in the bank and add files to this specific place in the bank?

+3
source share
4 answers

If you specify how to use the directory as the root for your set of files, you can simply map it to the directory and save the structure.

<jar destfile="myjar.jar" >
  <fileset dir=".">
    <include name="**/${libs.dir}/**"/>
  </fileset>
</jar>
+9
source
+1

You need to do something like the following. In particular, the zipfileset team . You basically say that you want to build $ {build.name} .jar (you can hardcode the path to "myjar.jar" or something like that) and then add various files to the JAR.

Hope this helps!

<jar destfile="${dist}/${build.name}.jar">

    <!-- Generate the MANIFEST.MF file. -->
    <manifest>
        <attribute name="Built-By" value="${user.name}" />
        <attribute name="Release-Version" value="${version}" />
        <attribute name="Main-Class" value="my.lib.Main" />
            <attribute name="SplashScreen-Image" value="TitleScreen.png" />
        <attribute name="Class-Path" value="${classpath}" />
    </manifest>

    <zipfileset dir="${build.dir}" />
    <zipfileset dir="${resources}" />

    <fileset file="${resources}/icons/misc_icons/TitleScreen.png" />
</jar>
+1
source

http://www.vertigrated.com/blog/2009/11/how-to-bundle-command-line-programs-into-a-single-executable-jar-file/

                                                                                                     

+1
source

Source: https://habr.com/ru/post/1728931/


All Articles