ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Stirling" <>
Subject Interfacing with Ant in JSP
Date Thu, 11 Jan 2001 02:46:27 GMT

Basic idea is this: a JSP tag library that re-uses the Ant "task library."

I've proposed this on the Jakarta Taglib project, and gotten a lot of good
feedback.  I've implemented several JSP tags that exactly mimic the names
and attributes of Ant tasks, but that act like JSP tags, i.e., logging to
the ServletContext and throwing JspTagExceptions.

So far I've done this by abstracting Task functionality from Project
context.  The Ant taglib (a name some people have objected to unless there's
full compatibility with Ant, so I'm calling it the "build" library for now)
so far does not use the Ant infrastructure at all, except for some methods
I've pulled here and there for reuse (full credit to the Ant Project and the
appropriate Ant developers is in the code and in the docs).  It's small and
light, but it's also only these tags so far: echo, fail, gzip, gunzip,
mkdir, touch, and tstamp.

Looking at the Task API, it's very parallel to the JSP Tag Extensions API.
And IMO, you Ant developers have written a lot of tasks whose user interface
(XML elements) look like well-planned JSP tags; primarily in that the
implementation of tasks is always well hidden from the user, and the user is
provided with a clean and friendly interface.

There are two things I'd like users to be able to do with Ant from JSP.  The
first one was the easier one to begin with, and which I've already started.
But I actually started with the second one and gave up for a while.  The
second is more of a challenge, and I could use some help.  But if the second
could be done cleanly, it might make the first easier, but maybe not:

1. Make all (give or take a few) of the Ant tasks available as stand-alone
JSP custom actions (no Project context required), converting Ant behaviors
to JSP behaviors where appropriate. Examples of changes to make Ant tasks
more like JSP tags are 1) output stream handling -- either JspWriter or
ServletContext.log() instead of System.out, and 2) throwing JspTagExceptions
in places where an Ant task would throw a BuildException.

Examples of changes that make the tasks work as standalone custom actions
are 1) there is no need for a full Ant <project> or even a <target> in order
to use the tasks as individual tags, and 2) task-tags can take sub-tags
where appropriate, such as <property> or <fileset> elements.

2. Interface with the full Ant capabilities via JSP, i.e., full Projects. In
this case you may be able to take a build.xml file and enclose it in a JSP
custom action, or generate (or modify) one on the fly, dynamically or
statically include it from an external source, and so on.

So I'm fishing for ideas.  I've thought of using reflection, of figuring out
what's the minimum Project context that needs to be provided for tasks to be
executed, and I've thought about waiting until Ant 2.0, when perhaps a very
clean interface from external client apps would be in place.

Scott Stirling
West Newton, MA

View raw message