ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Burton" <>
Subject Re: Antifying bash?
Date Sat, 27 Oct 2001 20:47:18 GMT

Michael Salmon wrote:
> I recommend you use zsh and it's auto-complete functionality. With makefiles I have
> a perl script that auto-completes the targets, the same can be done with ant and
> it's definitly something I've planned on doing.
> ms-

Yes!  Z-Shell ( is a Most Awesome shell.  Version 4.0
supports programmable completion for probably a couple of hundred commands
or so.  

I thought I'd try and kick start the process of adding Ant completion
support for Z-Shell.  So far I've created an _ant completion function for
Zsh 4.0 which provides support for all Ant options (both short and long
versions).  For instance:

  % ant -l<Ctrl-D>  (displays all options starting with "l")
  -l           -- use given file for log
  -listener    -- add an instance of class as a project listener
  -logfile     -- use given file for log
  -logger      -- class which is to perform logging

Note: in Zsh, Ctrl-D is the list completions key, similar to M-? or
<esc>-? in Bash.

After some more work later in the week, I was able to get target
completion to work in a similar manner showing the target name followed by
the description if any.  It turned out to be fairly easy to parse the
output of the -projecthelp option right from within Zsh.  For instance:

  % ant <Ctrl-D>
  build   -- Clean and then build the jar (DEFAULT)
  clean   -- Remove .class files and jar file
  compile -- Compile classes
  dist    -- Create distribution
  doc     -- Create javadocs
  jars    -- Create jars
  rmic    -- Rebuild the skeleton and stub classes
  war     -- Create a .war file with all the tutorial examples

So you decide to build the jars:

  % ant j<Tab> (which completes to: ant jars)

Although this does work, there is a short pause each time you try and
complete or list the targets because the completion function runs ant
-projecthelp (including -buildfile, -f or -find if specified) to get the
list of targets.  After thinking about it a bit, I believe I've found a
way to reliably cache the results from -projecthelp so that it needs to be
run only once.  I'll try and get this implemented early next week and post
it shortly thereafter.

But for those who can't or won't switch to Z-Shell, Bash 2.0 supports
Programmable Completion although it's very primitive compared with Z-Shell
4.0.  Nonetheless, it should be possible for someone to write some basic
completion support for Ant options, build.xml selection after an -f or
-buildfile option and targets.


> On Fri, Oct 19, 2001 at 10:03:41PM -0400, Chris wrote:
> > Hi all,
> >
> > This might be slightly OT, but I was thinking of how neat it would be for the
> > Ant Community (I'm going to love saying that) to have an enhanced bash, or
> > other shell, that was smart enough to note that if the user is entering 'ant'
> > as their command, if that shell was then smart enough to whip through the
> > build.xml (or other build file if so specified), note all the tasks, and then
> > provide the same auto-complete features you otherwise get with file names.
> >
> > Does anyone have even the foggiest notion of how much work it would be, or if
> > there's a speed bottleneck at parsing the build.xml file? (it's a small file
> > so there shouldn't be, but to fire up an XML parser, particularly one written
> > in Java, every time would probably be prohibitive.
> >
> > Thanks,
> > Chris

View raw message