I generate a jar with
ant but it will not use the class-path specified in the manifest file. However, when I extract the jar and package it again manually it works ok. How do I fix my ant so it works directly?
ant file:
...
<path id='lib.path'>
<fileset dir='lib/'>
<include name='*.jar'/>
</fileset>
</path>
<pathconvert property='lib.path.manifest' pathsep=' '>
<path refid='lib.path'/>
<chainedmapper>
<flattenmapper/>
<globmapper from='*' to='lib/*'/>
</chainedmapper>
</pathconvert>
...
<target name='dist' depends='build' description='make distribution'>
<copy file='README' todir='build'/>
<copy file='LICENSE' todir='build'/>
<copy file='ChangeLog' todir='build'/>
<copy todir='build/lib'>
<fileset dir='lib'/>
</copy>
<mkdir dir='dist'/>
<jar jarfile='dist/${name}-${version}.jar' basedir='build'>
<manifest>
<attribute name='Built-By' value='Pander'/>
<attribute name='Class-Path' value='${lib.path.manifest}'/>
<attribute name='Main-Class' value='com.svg.${name}.${Name}'/>
</manifest>
</jar>
<checksum file='dist/${name}-${version}.jar' forceOverwrite='yes'/>
</target>
<target name='run'>
<
java jar='dist/${name}-${version}.jar' fork='true'/>
</target>
...
The resulting manifest in the generated jar is:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.5
Created-By: Blackdown-1.4.2-02 (Blackdown Java-Linux Team)
Built-By: Pander
Main-Class: com.svg.vault.Vault
Class-Path: lib/BrowserLauncher2.jar
but "ant run" or "java -jar bla.jar" will abort on being unable to find classes of lib/BrowserLauncher2.jar
but if I unjar the file and create a new jar with
jar mcf specifying the manifest and the contents of the just extracted jar, the new jar will work with "java -jar bla.jar"
How can I fix this so that the jar generated by ant works with java -jar ?