ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <DDevie...@lgc.com>
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}"
           destdir="${classes}"
           classpathref="classpath.default"
           deprecation="on"
           verbose="off"
           fork="yes"
           debug="${compile_debug}"
           memoryInitialSize="512m"
           memoryMaximumSize="1024m"
           source="${javac.sourceflag}">
    </javac>

  </target>

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

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

  </target>

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

    <!-- Jar classes and generated manifest -->
    <jar jarfile="lib/acme.jar"
         compress="false"
         basedir="${classes}"
         excludes="**/test/**" />

  </target>

-----Original Message-----
From: John C. Turnbull [mailto:ozemale@ozemail.com.au] 
Sent: Monday, October 21, 2002 4:54 PM
To: ant-user@jakarta.apache.org
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>
        <jar jarfile="${util}" update="yes" basedir="${src}">
            <include name="**/util/**" />
            <exclude name="**/*.java" />
        </jar>
    </target>

Any ideas?

Thanks,

-JT


--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message