ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Simon Tuffs" <simon.tu...@lutris.com>
Subject Ant javac and jar update interaction.
Date Thu, 22 Mar 2001 23:57:30 GMT
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
simon.tuffs@lutris.com (831) 460-7482  (http://www.lutris.com) (and musician
http://www.mp3.com/timedilation)


Mime
View raw message