ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Harkness, David" <>
Subject RE: Newbie using Ant with Eclipse
Date Fri, 11 Jul 2003 22:57:03 GMT
'lo again,

While that does work, I would recommend changing your <jar> task to use
nested filesets. Hopefully other seasoned Ant users on the list can
chime in if this doesn't make sense, but here's my take.

As much as possible, I try to limit duplication and spreading of files
during the build process. When I started on this current project the
<package> target did essentially the following:

  1. delete "dist" directory.
  2. create "dist" directory.
  3. copy "classes" to "dist"
  4. copy several JARs from "../lib" to "dist"
  5. copy "MANIFEST.MF" from "src" to "dist/META-INF"
  6. copy deployment descriptors from "generated" to "dist/META-INF"
  7. jar up "dist" to "dist/packaged.jar"

This worked, but it was a lot of busy work. When you're tweaking a
single file over and over to get something to work, you want the
build-package-deploy loop to be as short as possible. As disks get
fragmented, copying a bunch of files can take a minute.

So I changed the <jar> task to simply pull all the files from their
appropriate directories. The time to package decreased by far more than
half as only one big file was being created rather than a whole lot of
little files. Well, I thought I had some other reason for doing this --
something more fundamental regarding akin to not putting generated files
into source control, but I was thinking of something else. Sheesh, it's
been a long week.

Anyway, I would still use the following in your case:

  <jar jarfile="bin/alpha.jar" basedir=".">
    <fileset dir="classes"/>
    <fileset file="../beta/bin/beta.jar"/>
    <fileset file="../gamma/bin/gamma.jar"/>

It would also allow you to isolate what the problem with ".." was: is it
the includes attribute or something else? As always, YMMV. :)

David Harkness
Sony Pictures Digital Networks
(310) 482-4756

-----Original Message-----
From: Bob Barnes [] 
Sent: Friday, July 11, 2003 11:45 AM
To: Ant Users List
Subject: Re: Newbie using Ant with Eclipse


    Thanks, I appreciate the effort to help. I've gotten this to work by

putting a "copy" step into the creation of the beta and gamma jar 
files. to copy them to the alpha/bin directory.

<copy file="bin/beta.jar" tofile="../alpha/bin/beta.jar"/>

and then referencing them in the include as

<jar jarfile="bin/alpha.jar" includes="bin/beta.jar, bin/gamma.jar, 
**/*.class" basedir="."/>

   I can only surmise that either 'includes" doesn't support ../ style 
navigation or that there's a bug. I get similar behavior on Mac OS X 
and Win XP so at least it's consistent.

   Again, thanks for the help.


On Friday, July 11, 2003, at 11:06 AM, Harkness, David wrote:

> Hiya Bob,
> I am definitely using ../ liberally in my build files to include JARs 
> from other projects into EARs. A few things:
> 1. I have `` basedir="." '' in my <project> tag.
> 2. All of my shared JARs are in a lib folder at the same level as my 
> projects.
>    Thus, I use "../lib/*.jar" to get to them.
> 3. If it helps, here's my JAR task:
>         <jar jarfile="${dist.dir}/${identity.service.jar.file}"
>              manifest="${meta.dir}/MANIFEST.MF"
>              whenempty="fail"
>             <!-- Compiled classes -->
>             <fileset dir="${class.dir}"/>
>             <!-- EJB deployment descriptors -->
>             <zipfileset dir="${gen.meta.dir}" prefix="META-INF"/>
>             <!-- Optonal log4j properties (blank excludes) -->
>             <fileset file="${}"/>
>         </jar>
> Now that I look, all of the included files are in the project
> directory.
> However, here's my EAR task:
>         <ear destfile="${dist.dir}/${identity.service.ear.file}"
>              appxml="${meta.dir}/application.xml"
>              whenempty="fail"
>             <!-- Include WebLogic-specific application deployment file
> -->
>             <metainf file="${meta.dir}/weblogic-application.xml"/>
>             <!-- Identity Service JAR -->
>             <fileset file="${dist.dir}/${identity.service.jar.file}"/>
>             <!-- CDP project dependencies -->
>             <fileset file="${serviceAPI.jar}"/>
>             <fileset file="${utilities.jar}"/>
>             <!-- 3rd-Party utility dependencies -->
>             <fileset file="${log4j.jar.file}"/>
>             <fileset file="${lib.dir}/${beanutils.jar.file}"/>
>             <fileset file="${lib.dir}/${collections.jar.file}"/>
>             <fileset file="${lib.dir}/${digester.jar.file}"/>
>             <fileset file="${lib.dir}/${logging.jar.file}"/>
>             <fileset file="${lib.dir}/${validator.jar.file}"/>
>         </ear>
> ${lib.dir} == "../lib" and the two "CDP project dependencies" JARs are

> located in "../lib/cdp1.5".
> Have you tried running Ant outside of Eclipse to isolate the problem? 
> That would be my next step.
> Oh, this may have been a typo, but your Alpha JAR task seems 
> incorrect.
>> alpha Ant file
>> <jar jarfile="bin/alpha.jar" includes="../beta/bin/**/*.class, 
>> ../gamma/bin/**/*.properties, **/*.class" basedir="."/>
>                                 ^^^^^^^^^^
> Shouldn't that be "bin/**/*.class"? Of course, if you only have class 
> files in "bin" it will have the same effect but take a little longer. 
> I've been using nested filesets rather than includes, but that's just 
> cuz the template I started with did the same thing. That would be my 
> next step after determining that it isn't an Eclipse issue, just to be

> sure.
> Keep plugging away at it -- you'll get it! :)
> David Harkness
> Sony Pictures Digital Networks
> (310) 482-4756
> -----Original Message-----
> From: Bob Barnes []
> Sent: Friday, July 11, 2003 9:13 AM
> To: Ant Users List
> Subject: Re: Newbie using Ant with Eclipse
> David,
>     Thanks for the quick reply. As soon as I hit the send button I 
> realized the answer to the compression question... happens every time.

> Are you sure about the path semantics accepting ../ style navigation? 
> I had already tried that with no luck and I haven't been able to 
> locate any reference to that in the online Ant manual. At any rate I 
> can't seem to make it work. You understood perfectly my directory 
> structure, but just to restate.
> I have:
> top
> top/alpha
> top/alpha/bin
> top/beta
> top/beta/bin
> top/gamma
> top/gamma/bin
> The alpha, beta and gamma directories each contain the Ant build file 
> for that project. The Eclipse compile places class files in the bin 
> directory. I'm able to access the class files and create the jar for 
> each project using something like:
> beta Ant file
> <jar jarfile="bin/beta.jar" includes="bin/**/*.class" basedir="."/>
> but using 'up' navigation like so:
> alpha Ant file
> <jar jarfile="bin/alpha.jar" includes="../beta/bin/**/*.class, 
> ../gamma/bin/**/*.properties, **/*.class" basedir="."/>
> The beta Ant file correctly builds the beta.jar and the alpha Ant 
> build file correctly picks up the class files from the alpha 
> directory, but not the beta or gamma directories. I've tried ../, 
> ../../ and even ../../../ just to make sure I wasn't missing a level. 
> Either I'm doing something really stupid (wouldn't be the first time) 
> or there's more to it. Just as a side note, what I'd prefer to do is 
> include the jar files from beta and gamma into alpha, but I can't get 
> that to work either. Any addiional suggestions?
> TIA,
> Bob
> On Thursday, July 10, 2003, at 07:56 PM, Harkness, David wrote:
>> If you know that a, b, and c are at the same level (which you stated,

>> but just to make sure), you can access one from the other using 
>> normal
>> path semantics (".." goes "up" one directory level):
>>   In a:     ../b/bin
>>   In a/bin: ../../b/bin
>> As for JAR compression:
>>   compress: Not only store data but also compress them, defaults to 
>> true
>> Just use <jar ... Compress="no" ...> to disable it.
>> David Harkness
>> Sony Pictures Digital Networks
>> (310) 482-4756
>> -----Original Message-----
>> From: Bob Barnes []
>> Sent: Thursday, July 10, 2003 7:24 PM
>> To:
>> Subject: Newbie using Ant with Eclipse
>> Hi,
>>     I'm new to Eclipse and a total neophyte with Ant. I'm trying to 
>> use Ant build files to generate jar files as part of my Eclipse 
>> project build. I've succeeded in getting most things to build and 
>> create proper jar files, but I'm having two problems. First of all I 
>> have a directory structure something like:
>> a/bin
>> b/bin
>> c/bin
>>    Each bin directory contains an Ant created jar file. The jar file 
>> in a/bin needs to include the jar files built in b/bin and c/bin, but

>> I can't seem to figure out how to reference those directories from a.

>> Is there a way to reference files from one directory to another when 
>> the base directories are at the same level?
>>    Second question is that the jar files are being compressed. As far

>> as
>> I can tell I'm not explicitly requesting compression. Is there a way 
>> to create a jar file that uncompressed?
>> TIA,
>> Bob
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:
>> For additional commands, e-mail:
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:
>> For additional commands, e-mail:
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

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

View raw message