ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kenneth McKnight" <kmckni...@vitria.com>
Subject RE: Need Help With <jar> Task
Date Wed, 13 Sep 2006 17:24:58 GMT
You need to use the fileset nested <include> element to do this:

<jar destfile="${classes.dir}/mia_gui.jar" index="true">
    <fileset dir="${classes.dir}">
        <include name="mia/gui/**"/>
    </fileset>
 </jar>
<jar destfile="${classes.dir}/mia_middleware.jar" index="true">
    <fileset dir="${classes.dir}">
        <include name="mia/middleware/**"/>
    </fileset>
 </jar>

Here's what you get (I used some dummy files so you can see that it
works on subdirs as well):
$ jar tvf mia_gui.jar
     0 Wed Sep 13 10:22:10 PST 2006 META-INF/
   106 Wed Sep 13 10:22:08 PST 2006 META-INF/MANIFEST.MF
     0 Wed Sep 13 10:19:48 PST 2006 mia/
     0 Wed Sep 13 10:20:06 PST 2006 mia/gui/
     0 Wed Sep 13 10:20:06 PST 2006 mia/gui/bar1.class
     0 Wed Sep 13 10:20:04 PST 2006 mia/gui/foo1.class
    54 Wed Sep 13 10:22:08 PST 2006 META-INF/INDEX.LIST

$ jar tvf mia_middleware.jar
     0 Wed Sep 13 10:22:58 PST 2006 META-INF/
   106 Wed Sep 13 10:22:56 PST 2006 META-INF/MANIFEST.MF
     0 Wed Sep 13 10:19:48 PST 2006 mia/
     0 Wed Sep 13 10:20:24 PST 2006 mia/middleware/
     0 Wed Sep 13 10:20:32 PST 2006 mia/middleware/icons/
     0 Wed Sep 13 10:20:18 PST 2006 mia/middleware/bar2.class
     0 Wed Sep 13 10:20:14 PST 2006 mia/middleware/foo2.class
     0 Wed Sep 13 10:20:32 PST 2006 mia/middleware/icons/me.ico
    90 Wed Sep 13 10:22:56 PST 2006 META-INF/INDEX.LIST

ken :)

~~~~~~~~~~~~~~~~~~~~~~~
Kenneth J. Mc Knight
Sr. Staff Release Engineer
Release Engineering
Vitria Technology, Inc.
945 Stewart Dr.
Sunnyvale, CA  94085-3913
+1.408.212.2346

mailto:kmcknight@vitria.com
http://www.vitria.com
~~~~~~~~~~~~~~~~~~~~~~~
-----Original Message-----
From: Robert Pepersack [mailto:RPepersack@mdinsurance.state.md.us] 
Sent: Wednesday, September 13, 2006 9:57 AM
To: user@ant.apache.org
Subject: Need Help With <jar> Task

Hi all,

I'm a to Ant.  I have some Java classes in a single directory tree that
has two child directories (i.e. mia/gui and mia/middleware).  I need to
create two .jar files, one that contains the classes in the mia.gui
package and the other that contains the classes in mia.middleware.  When
I use the <jar> task to archive mia/gui, the directories in the .jar
file start with mia's children, not mia.  I need the root directory in
the .jar file to be mia.

I've tried this a number of ways in my build file with different
elements and attributes.  Here's the simplest:

    <target name="archive" depends="compile" description="Create the
Java archive files">
        <jar destfile="${classes.dir}/mia_gui.jar"
             index="true">
            <fileset dir="${classes.dir}/mia/gui" />
        </jar>
    </target>

Here are the equivalent commands from the batch file (which I don't
want to use any more) that archives my classes:

"%JAVA_HOME%\bin\jar" cf mia_gui.jar mia\gui

"%JAVA_HOME%\bin\jar" cf mia_middleware.jar mia\middleware

Thanks,

Robert Pepersack
Senior Lead Developer
Maryland Insurance Administration
410-468-2054

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


Mime
View raw message