Ant API - Examples where? Please help.

M

monty5k

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.
 
S

Scott Ellsworth

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
 
M

monty5k

Scott Ellsworth said:
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
 
S

Scott Ellsworth

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.
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'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
 
R

rpnman

I recommend "Ant - The Definitive Guide" by Jesse Tilly & Eric M. Burke
(O'Reilly Press) for a fairly complete introduction to extending Ant.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top