Ant API - Examples where? Please help.  
Author Message
monty5k





PostPosted: 2004-2-21 2:48:00 Top

java-programmer, Ant API - Examples where? Please help. Hi all,

I need to develop a series of classes (zip, unzip, ftp, scp, rsh and
ssh) in java using the Ant API.

But I can't find anything on this, any tutorials, any example code.
I've searched the net, many books and I got almost nothing. Java
source code i only get the "How to develop an Ant Task" thing.

Does anyone know where can i get simple examples of using this in
java?

Thank you all.
 
Scott Ellsworth





PostPosted: 2004-2-21 3:21:00 Top

java-programmer >> Ant API - Examples where? Please help. In article <email***@***.com>,
email***@***.com (monty5k) wrote:

> Hi all,
>
> I need to develop a series of classes (zip, unzip, ftp, scp, rsh and
> ssh) in java using the Ant API.

Please go into a bit more detail. When you say "using the Ant API",
what do you mean?

If you want to extend Ant's functionality, you do this by writing new
Ant tasks. It is not difficult in most cases, and the Apache folks have
done a lot of work for you. That said, it already has zip, unzip, and
ftp classes built in or available in external tasks, so I presume that
this is not what you need.

If, on the other hand, you want to use Ant as a build system, which
performs these tasks as part of the build, then you need to look at the
ant manual, both in built in and external tasks. All tasks follow the
same format, so the standard ant usage examples should help.

I found the Hatcher and Loughram book "Java Development With Ant" very
helpful in understanding how to structure build files.

Scott
Java, Cocoa, WebObjects and Database consulting for the life sciences
 
monty5k





PostPosted: 2004-2-21 9:43:00 Top

java-programmer >> Ant API - Examples where? Please help. Scott Ellsworth <email***@***.com> wrote in message news:<email***@***.com>...
> In article <email***@***.com>,
> email***@***.com (monty5k) wrote:
>
> > Hi all,
> >
> > I need to develop a series of classes (zip, unzip, ftp, scp, rsh and
> > ssh) in java using the Ant API.
>
> Please go into a bit more detail. When you say "using the Ant API",
> what do you mean?
>
> If you want to extend Ant's functionality, you do this by writing new
> Ant tasks. It is not difficult in most cases, and the Apache folks have
> done a lot of work for you. That said, it already has zip, unzip, and
> ftp classes built in or available in external tasks, so I presume that
> this is not what you need.


I need to use this implemented tasks in my own java code, for example,
a java program that would zip some files in a certain directory, and
then send it to a remote machine by scp or ftp. Just like you would do
on a build file, but in this case importing Ant Tasks Classes into
your code.


> If, on the other hand, you want to use Ant as a build system, which
> performs these tasks as part of the build, then you need to look at the
> ant manual, both in built in and external tasks. All tasks follow the
> same format, so the standard ant usage examples should help.

No, this is not the case, i do not want to use Ant as a build system.
(Well, i will, but that's another thing. :)

> I found the Hatcher and Loughram book "Java Development With Ant" very
> helpful in understanding how to structure build files.

I've seen several books as well, but they only cover the build system.

Thank you for your response, and sorry for my bad english. :)
Hugo Costa
 
 
Tobias Schierge





PostPosted: 2004-2-22 1:21:00 Top

java-programmer >> Ant API - Examples where? Please help. Hi,

a good article on this subject is

<http://www.onjava.com/pub/a/onjava/2002/07/24/antauto.html>

Regards,

Tobias
--
<http://www.schierge.de/tobias/>
 
 
Scott Ellsworth





PostPosted: 2004-2-24 3:13:00 Top

java-programmer >> Ant API - Examples where? Please help. In article <email***@***.com>,
email***@***.com (monty5k) wrote:

> Scott Ellsworth <email***@***.com> wrote in message
> news:<email***@***.com>...
> > In article <email***@***.com>,
> > email***@***.com (monty5k) wrote:
> >
> > > Hi all,
> > >
> > > I need to develop a series of classes (zip, unzip, ftp, scp, rsh and
> > > ssh) in java using the Ant API.
> >
> > Please go into a bit more detail. When you say "using the Ant API",
> > what do you mean?
> >
> > If you want to extend Ant's functionality, you do this by writing new
> > Ant tasks. It is not difficult in most cases, and the Apache folks have
> > done a lot of work for you. That said, it already has zip, unzip, and
> > ftp classes built in or available in external tasks, so I presume that
> > this is not what you need.
>
>
> I need to use this implemented tasks in my own java code, for example,
> a java program that would zip some files in a certain directory, and
> then send it to a remote machine by scp or ftp. Just like you would do
> on a build file, but in this case importing Ant Tasks Classes into
> your code.

Ah! I understand now.

I cannot help with this, as I have not done it. The closest I have come
dates from when I was writing my own ant task. I did it by writing a
utility class that does the work, and then both an ant task wrapper and
a plain old command line wrapper. In your case, though, you want to use
their _existing_ classes, and that seems very fraught with peril to me.
I suspect that the ant authors have made assumptions about their
environment which running under ANT satisfies, but that just calling
arbitrary code might not.

Talking out of my hat here - you might be best served firing up ant
under your program's control. Runtime.exec would certainly work, but
that is very ugly. (To be fair, it isolates your program from ant
failures very well.) Better might be to find a way to call the main
entry points after setting up the environment.

> > If, on the other hand, you want to use Ant as a build system, which
> > performs these tasks as part of the build, then you need to look at the
> > ant manual, both in built in and external tasks. All tasks follow the
> > same format, so the standard ant usage examples should help.
>
> No, this is not the case, i do not want to use Ant as a build system.
> (Well, i will, but that's another thing. :)

Understood.

> > I found the Hatcher and Loughram book "Java Development With Ant" very
> > helpful in understanding how to structure build files.
>
> I've seen several books as well, but they only cover the build system.

Right - the underlying code is really not meant to embedded, as best I
understand the docs.

> Thank you for your response, and sorry for my bad english. :)

Your English was fine, I just did not quite understand the task you were
trying to accomplish. Good luck - you have picked a tough one.

Scott
 
 
rpnman





PostPosted: 2004-5-16 3:34:00 Top

java-programmer >> Ant API - Examples where? Please help. I recommend "Ant - The Definitive Guide" by Jesse Tilly & Eric M. Burke
(O'Reilly Press) for a fairly complete introduction to extending Ant.

--
ROGER NEYMAN

"monty5k" <email***@***.com> wrote in message
news:email***@***.com...
> Hi all,
>
> I need to develop a series of classes (zip, unzip, ftp, scp, rsh and
> ssh) in java using the Ant API.
>
> But I can't find anything on this, any tutorials, any example code.
> I've searched the net, many books and I got almost nothing. Java
> source code i only get the "How to develop an Ant Task" thing.
>
> Does anyone know where can i get simple examples of using this in
> java?
>
> Thank you all.