Hello Ant Developers:
I just chased down a nasty problem in Ant 1.2 running under JDK 1.3, and didn't
see a report of this on the mailing lists. I'm not subscribed to any-dev, but
feel free to mail me directly if you have any questions.
I had a build.xml file which first compiled some files and then did a jar-update
on jar-files which were also inputs to the compilation, something like this (see
below). If the "javac" and the "jarupdate" targets were invoked in the same Ant
session, the jar-update would fail with an error on the jarfile:
Updating petstoreEjb.jar
Myos = Windows 2000
jar -uf ../../output/lib/petstoreEjb.jar .
java.io.IOException: Error in writing existing jar file
at sun.tools.jar.Main.run(Main.java:179)
at sun.tools.jar.Main.main(Main.java:904)
Result: 1
This problem may well be Windows specific, since it seems that the javac
"modern" compiler is locking the .jar file during use, and hence the "jar -uf"
is failing. The simplest workaround is to specify <property
name="build.compiler" value="classic" /> to force the classic compiler to be
used, it seems not to have this problem.
<target name="prepareEjb" depends="init">
<javac srcdir="${enhydra.genic}" destdir="${ear.name}/${ejb.name}">
<classpath>
<pathelement location="${enhydra.liboutput}/build.jar" />
<pathelement location="${enhydra.liboutput}/SharedApiService.jar" />
<pathelement location="${enhydra.liboutput}/EjbService.jar" />
<fileset dir="${example.output}/lib" >
<include name="*.jar" />
</fileset>
</classpath>
</javac>
</target>
<target name="jarupdate">
<property name="jar.dir" value="${jar.name}" />
<echo>Updating ${jar.name}.${jar.type}</echo>
<exec executable="jar" dir="${ear.name}/${jar.dir}">
<arg line="-uf ../../output/lib/${jar.name}.${jar.type} ." />
</exec>
</target>
Regards,
Simon Tuffs.
--
Simon Tuffs
Staff Engineer, Lutris Technologies Inc
[EMAIL PROTECTED] (831) 460-7482 (http://www.lutris.com) (and musician
http://www.mp3.com/timedilation)