ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: [PATCH] Ant's Javadoc & Exec tasks
Date Sun, 06 Feb 2000 20:57:52 GMT

Thanks for the first fix!  I will incorporate it immediately.  As well as
the exit code enhancement.

I've recently been through hell trying to get the second fix right.  I
understand what you are trying to do, and I tried that too, but it breaks
javadoc on Unix.  It seems that javadoc carefully constructs parameters
with quotes around them.  Runtime.exec on Windows uses the command shell,
so these are parsed correctly, whereas on Unix, some other process for
parsing the parameters must be used as the quotes make it all the way to
the application.

This took me quite a while to debug, as the error message you get back is
something along the lines of:

   Directory not found: "/path/to/some/valid/directory"

And, of course, /path/to/some/valid/directory exists!

For this reason, I added the following code to antRun:

   echo $CMD $@ | sh

- Sam Ruby

P.S.  I'm copying ant-dev, so that others can participate.  Had I seen your
first fix, it would have saved me some time debugging this morning.

Michael Smith <> on 02/06/2000 03:39:17 PM

To:   Sam Ruby/Raleigh/IBM@IBMUS
Subject:  [PATCH] Ant's Javadoc & Exec tasks


I submitted a diff to Stefano a few days ago with a patch to correct
possible infinite loops in the JavaReader of Ant's Javadoc task.  He
hasn't gotten a chance to commit those changes yet, and you just
modified the task, so the changes have...  changed.

The attached, updated diff corrects the link for Stefano's mailing
address (which is why I sent it to him in the first place), along with
possible infinite loops in the parsing-- I hate while(true)...  :)

There was also one small problem with the new additions you made for
lines that have quoted text with embedded quotes.  For example, in


the embedded " (following the \) will be recognized as the ending quote,
thus causing anything after the final quote to be ignored as quoted text
in the code. This diff incorporates a fix for that as well.

The second attached diff for the Exec task has two improvements.

First, it removes all dependencies on the OS specific stuff if there is
no need to execute the task from a different location.  That is, if no
"dir" is set on the task, and it will be running from the current
working directory, then don't even bother using OS specific scripts to
change the the appropriate directory.  I'm not positive that it is
accurate to assume that the current directory is where the process will
be executed from, so I don't know whether this part should be included,
but works fine for me.

Second, I added the ability to retrieve the exit code from the exec'd
process, simply by returning it.  This is useful for subclasses of the
exec task that use the run method to exec a process, and are interested
in knowing the error code that the result responded with.  For example,
a subclass could exec something, and if that exec returns a "normal"
result code, then it exec's something else.  If an abnormal error code
is returned, then a build exception can be thrown.

Index: src/main/org/apache/tools/ant/taskdefs/
RCS file:

retrieving revision 1.4
diff -r1.4
<  * @author Stefano Mazzocchi <a href="
>  * @author Stefano Mazzocchi <a href="
<                     while (c != '\n') c =;
>                     while (c != '\n' && c != -1) c =;
<                     while (true) {
>                     while (c != -1) {
<                 while (true) {
>                 while (c != -1) {
<                     if (c == '"') {
>                     else if (c == '"') {

Index: src/main/org/apache/tools/ant/taskdefs/
RCS file:

retrieving revision 1.7
diff -r1.7
<     protected void run(String command) throws BuildException {
>     protected int run(String command) throws BuildException {
<         if (myos.toLowerCase().indexOf("windows") >= 0) {
>         if (!dir.equals(".") && myos.toLowerCase().indexOf("windows") >=
0) {
<         } else {
>         } else if(!dir.equals(".")) {
>             return err;

View raw message