ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cathal Mc Ginley <t...@vccomputers.ie>
Subject Re: [beginner] how to build a jar file with ant?
Date Fri, 23 Feb 2001 19:16:44 GMT
Hi Bala,
The location of the jar file is specified by the jarfile attribute of
the jar task. This location is relative to the project basedir. So if
the opening project tag is:

   <project name="app" default="compile" basedir="/home/time/java">

and your jar task looks like:

   <jar jarfile="build/app.jar" basedir="build/classes" />

your jar will end up as /home/time/java/build/app.jar and will contain
the files under /home/time/build/classes/

By the way, Francesco, I cut and pasted the example build.xml I gave you
and replicated the directory structure and it worked first time with Ant
1.2
Perhaps if you put the project basedir to the absolute location of the
base directory e.g. basedir="/home/time/java" or basedir="c:\java"
rather than basedir="." that might help. If not, could you give me the
messages Ant gives you when the task fails.

Bala Subramanian wrote:
> 
> Hi cathal
>    Let me have one more doubt ,I want to know the
>    Where the app.jar is placed .After jar file is created ,
>    where the jar file is exactly available .EXpecting reply from u
> 
> Regards
> bala
> 
> 
> -----Original Message-----
> From: time [mailto:time]On Behalf Of Cathal Mc Ginley
> Sent: Friday, February 23, 2001 2:38 AM
> To: ant-user@jakarta.apache.org
> Subject: Re: [beginner] how to build a jar file with ant?
> 
> I think your build.xml file is rather invalid. You cannot explicitly
> nest targets. What you probably want to try is something like:
> 
> <project name="myproject" default="compile" basedir=".">
> 
> <target name="compile">
>    <javac srcdir="bean" destdir="classes"
>       debug="on" optimize="off" deprecation="off" />
> </target>
> 
> <target name="dist" depends="compile">
>    <jar jarfile="app.jar" basedir="classes" />
> </target>
> 
> </project>
> 
> Use dependencies to execute several tasks in a row, nesting seems
> intuitive but it's *not* how ant works.
> 
> So the command "ant" or "ant compile" will compile your files, and the
> command "ant dist" will run the compile task and jar your classes
> 
> good luck
>         Cathal.
> 
> "fmarchioni@libero.it" wrote:
> >
> > Hi all,
> > I'm trying to build a jar file but it seems that
> > ant ignores my request!
> >
> > This is my directory structure
> >          build.xml
> > [bean]          [classes]
> > sources         compiled classes
> >
> > I'd like to jar all files under the "classes" dir
> >
> > -This is my very little build.xml file-
> >
> > <project name="myproject" default="compile" basedir=".">
> >
> > <target name="dist" >
> >
> >   <target name="compile" >
> >     <javac srcdir="bean" destdir="classes"
> >      debug="on" optimize="off" deprecation="off"/>
> >   </target>
> >
> > <jar jarfile="app.jar" basedir="classes" />
> >
> > </target>
> > </project>
> >
> > Why the jar file doesn't get built?
> > Thank you very much in advance
> > Francesco

Mime
View raw message