I am trying to package a jar and in the attribute classpath of the manifest I want to add the paths where all my dependable jars are present. One way to do is to copy all the jars in the directory and provide the name in the classpath like below:
<path id="lib-classpath">
<fileset dir="${libApp.dir}">
<include name="**/*.jar"/>
</fileset>
</path>
<!-- convert classpath to a flat list/string -->
<pathconvert property="lib.classpath" pathsep=" ">
<path refid="lib-classpath" />
<flattenmapper />
</pathconvert>
<copy todir="${out.dir}" flatten="true">
<fileset dir="${libApp.dir}" />
</copy>
<echo message=" Generating JAR " />
<delete file="${out.dir}/${file-name}" />
<jar destfile = "${out.dir}/${file-name}" basedir = "${bin.dir}" includes = "**/*">
<fileset dir=".">
<include name="**/*.properties" />
</fileset>
<manifest >
<attribute name="Class-Path" value="${lib.classpath}" />
<attribute name="Main-Class" value="com.executive.ThreadPool"/>
</manifest>
</jar>
<echo message=" ...JAR Created for " />
But is there a way that I can actually specify the directories contating the jars, so that I don't have to copy all of the jars into the current directly? Like if my directory structure is: log4j/*.jar svn/*.jar Then I don't copy all of my jar to the out directory and can give the relative paths in the clasppath attruibute.