ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <>
Subject RE: JAR task not adding all files
Date Mon, 21 Oct 2002 22:14:17 GMT
I do things a little differently...

Instead of JARing the classes on disk (in classes dir), and then updating
that JAR with the resource files (stuff in your source dir not .java
usually), I copy the resources to the classes directory, and then JAR
everything from there in one pass. This has the added advantage that running
your application off the JAR or the classes dir is completely equivalent
(maybe except if you put stuff in Class-Path attribute in the Mannifest of
the JAR).

Does that help? --DD

  <target name="compile"
          depends="init, -classes, -resources "
          description="Compiles the java source files" />

  <!-- Compile the java code from ${src} into ${classes}
  <target name="-classes">

    <javac srcdir="${src}"


  <!-- Copy resources from ${src} into ${classes}
  <target name="-resources">

    <copy todir="${classes}">
      <fileset dir="src"
               includes="**/*.gif, **/*.properties" />


  <target name="jar"
          description="Creates the Java Archive (JAR)">

    <!-- Jar classes and generated manifest -->
    <jar jarfile="lib/acme.jar"
         excludes="**/test/**" />


-----Original Message-----
From: John C. Turnbull [] 
Sent: Monday, October 21, 2002 4:54 PM
Subject: JAR task not adding all files

This is my first Ant project.  I am using J2SE 1.4.0 on Windows 2000 SP3.

I have encountered a problem that appears to be with the JAR task though I
cannot be sure.  The symptom is that an XML file (amongst others) is not
being added to a JAR even though the .class files in the same directory are
being added correctly.  This is some of the output when running Ant
with -verbose:

[jar] adding entry com/acme/util/ClassA.class
[jar] com\acme\util\test.xml omitted as C:\dist\util.jar is up to date.

The relevant section of the build file looks like this:

   <target name="util" depends="libs">
        <jar jarfile="${util}" basedir="${build}">
            <include name="**/util/**" />
        <jar jarfile="${util}" update="yes" basedir="${src}">
            <include name="**/util/**" />
            <exclude name="**/*.java" />

Any ideas?



To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message