ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anto...@apache.org
Subject cvs commit: ant/docs/manual/OptionalTasks jjdoc.html rexec.html
Date Sat, 13 Sep 2003 12:37:05 GMT
antoine     2003/09/13 05:37:04

  Modified:    src/testcases/org/apache/tools/ant/util
                        UnPackageNameMapperTest.java
               src/main/org/apache/tools/ant/taskdefs/optional/net
                        RExecTask.java
               src/main/org/apache/tools/ant/taskdefs/optional/javacc
                        JJDoc.java
               docs/manual/CoreTypes zipfileset.html
               docs/manual/OptionalTasks jjdoc.html rexec.html
  Log:
  Removed hard coded \n from files.
  Thanks to a remark of Larry Shatzer (Larry dot Shatzer at Spirent dot com).
  
  Revision  Changes    Path
  1.2       +76 -76    ant/src/testcases/org/apache/tools/ant/util/UnPackageNameMapperTest.java
  
  Index: UnPackageNameMapperTest.java
  ===================================================================
  RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/util/UnPackageNameMapperTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- UnPackageNameMapperTest.java	16 Jun 2003 09:28:29 -0000	1.1
  +++ UnPackageNameMapperTest.java	13 Sep 2003 12:37:04 -0000	1.2
  @@ -1,76 +1,76 @@
  -/*
  - *  The Apache Software License, Version 1.1
  - *
  - *  Copyright (c) 2003 The Apache Software Foundation.  All rights
  - *  reserved.
  - *
  - *  Redistribution and use in source and binary forms, with or without
  - *  modification, are permitted provided that the following conditions
  - *  are met:
  - *
  - *  1. Redistributions of source code must retain the above copyright
  - *  notice, this list of conditions and the following disclaimer.
  - *
  - *  2. Redistributions in binary form must reproduce the above copyright
  - *  notice, this list of conditions and the following disclaimer in
  - *  the documentation and/or other materials provided with the
  - *  distribution.
  - *
  - *  3. The end-user documentation included with the redistribution, if
  - *  any, must include the following acknowlegement:
  - *  "This product includes software developed by the
  - *  Apache Software Foundation (http://www.apache.org/)."
  - *  Alternately, this acknowlegement may appear in the software itself,
  - *  if and wherever such third-party acknowlegements normally appear.
  - *
  - *  4. The names "Ant" and "Apache Software
  - *  Foundation" must not be used to endorse or promote products derived
  - *  from this software without prior written permission. For written
  - *  permission, please contact apache@apache.org.
  - *
  - *  5. Products derived from this software may not be called "Apache"
  - *  nor may "Apache" appear in their names without prior written
  - *  permission of the Apache Group.
  - *
  - *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - *  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - *  DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - *  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - *  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - *  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - *  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - *  SUCH DAMAGE.
  - *  ====================================================================
  - *
  - *  This software consists of voluntary contributions made by many
  - *  individuals on behalf of the Apache Software Foundation.  For more
  - *  information on the Apache Software Foundation, please see
  - *  <http://www.apache.org/>.
  - */
  -package org.apache.tools.ant.util;
  -
  -import java.io.File;
  -import junit.framework.TestCase;
  -
  -public class UnPackageNameMapperTest extends TestCase {
  -    public UnPackageNameMapperTest(String name) { super(name); }
  -    
  -    public void testMapping() {
  -        UnPackageNameMapper mapper = new UnPackageNameMapper();
  -        mapper.setFrom("TEST-*.xml");
  -        mapper.setTo("*.java");
  -        String file ="TEST-org.apache.tools.ant.util.UnPackageNameMapperTest.xml";
  -        String result = mapper.mapFileName(file)[0];
  -        String expected = fixupPath("org/apache/tools/ant/util/UnPackageNameMapperTest.java");
  -        
  -        assertEquals(expected, result);
  -    }
  -    
  -    private String fixupPath(String file) {
  -        return file.replace('/', File.separatorChar);
  -    }
  -}
  +/*
  + *  The Apache Software License, Version 1.1
  + *
  + *  Copyright (c) 2003 The Apache Software Foundation.  All rights
  + *  reserved.
  + *
  + *  Redistribution and use in source and binary forms, with or without
  + *  modification, are permitted provided that the following conditions
  + *  are met:
  + *
  + *  1. Redistributions of source code must retain the above copyright
  + *  notice, this list of conditions and the following disclaimer.
  + *
  + *  2. Redistributions in binary form must reproduce the above copyright
  + *  notice, this list of conditions and the following disclaimer in
  + *  the documentation and/or other materials provided with the
  + *  distribution.
  + *
  + *  3. The end-user documentation included with the redistribution, if
  + *  any, must include the following acknowlegement:
  + *  "This product includes software developed by the
  + *  Apache Software Foundation (http://www.apache.org/)."
  + *  Alternately, this acknowlegement may appear in the software itself,
  + *  if and wherever such third-party acknowlegements normally appear.
  + *
  + *  4. The names "Ant" and "Apache Software
  + *  Foundation" must not be used to endorse or promote products derived
  + *  from this software without prior written permission. For written
  + *  permission, please contact apache@apache.org.
  + *
  + *  5. Products derived from this software may not be called "Apache"
  + *  nor may "Apache" appear in their names without prior written
  + *  permission of the Apache Group.
  + *
  + *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + *  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + *  DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + *  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + *  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + *  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + *  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + *  SUCH DAMAGE.
  + *  ====================================================================
  + *
  + *  This software consists of voluntary contributions made by many
  + *  individuals on behalf of the Apache Software Foundation.  For more
  + *  information on the Apache Software Foundation, please see
  + *  <http://www.apache.org/>.
  + */
  +package org.apache.tools.ant.util;
  +
  +import java.io.File;
  +import junit.framework.TestCase;
  +
  +public class UnPackageNameMapperTest extends TestCase {
  +    public UnPackageNameMapperTest(String name) { super(name); }
  +    
  +    public void testMapping() {
  +        UnPackageNameMapper mapper = new UnPackageNameMapper();
  +        mapper.setFrom("TEST-*.xml");
  +        mapper.setTo("*.java");
  +        String file ="TEST-org.apache.tools.ant.util.UnPackageNameMapperTest.xml";
  +        String result = mapper.mapFileName(file)[0];
  +        String expected = fixupPath("org/apache/tools/ant/util/UnPackageNameMapperTest.java");
  +        
  +        assertEquals(expected, result);
  +    }
  +    
  +    private String fixupPath(String file) {
  +        return file.replace('/', File.separatorChar);
  +    }
  +}
  
  
  
  1.4       +433 -433  ant/src/main/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java
  
  Index: RExecTask.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- RExecTask.java	19 Jul 2003 11:20:20 -0000	1.3
  +++ RExecTask.java	13 Sep 2003 12:37:04 -0000	1.4
  @@ -1,433 +1,433 @@
  -/*
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 2003 The Apache Software Foundation.  All rights
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  - *
  - * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowlegement may appear in the software itself,
  - *    if and wherever such third-party acknowlegements normally appear.
  - *
  - * 4. The names "Ant" and "Apache Software
  - *    Foundation" must not be used to endorse or promote products derived
  - *    from this software without prior written permission. For written
  - *    permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache"
  - *    nor may "Apache" appear in their names without prior written
  - *    permission of the Apache Group.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  - * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - */
  -
  -package org.apache.tools.ant.taskdefs.optional.net;
  -
  -import org.apache.commons.net.bsd.RExecClient;
  -
  -import java.io.IOException;
  -import java.io.InputStream;
  -import java.io.OutputStream;
  -import java.util.Calendar;
  -import java.util.Enumeration;
  -import java.util.Vector;
  -import org.apache.tools.ant.BuildException;
  -import org.apache.tools.ant.Project;
  -import org.apache.tools.ant.Task;
  -
  -/**
  - * Automates the rexec protocol.
  - *
  - * @since Ant 1.6
  - */
  -
  -public class RExecTask extends Task {
  -    /**
  -     *  The userid to login with, if automated login is used
  -     */
  -    private String userid  = null;
  -
  -    /**
  -     *  The password to login with, if automated login is used
  -     */
  -    private String password = null;
  -
  -    /**
  -     *  The command to execute
  -     */
  -    private String command = null;
  -
  -    /**
  -     *  The server to connect to.
  -     */
  -    private String server  = null;
  -
  -    /**
  -     *  The tcp port to connect to.
  -     */
  -    private int port = RExecClient.DEFAULT_PORT;
  -
  -    /**
  -     *  The Object which handles the rexec session.
  -     */
  -    private AntRExecClient rexec = null;
  -
  -    /**
  -     *  The list of read/write commands for this session
  -     */
  -    private Vector rexecTasks = new Vector();
  -
  -    /**
  -     *  If true, adds a CR to beginning of login script
  -     */
  -    private boolean addCarriageReturn = false;
  -
  -    /**
  -     *  Default time allowed for waiting for a valid response
  -     *  for all child reads.  A value of 0 means no limit.
  -     */
  -    private Integer defaultTimeout = null;
  -
  -    /**
  -     *  This class is the parent of the Read and Write tasks.
  -     *  It handles the common attributes for both.
  -     */
  -    public class RExecSubTask {
  -        protected String taskString = "";
  -        public void execute(AntRExecClient rexec)
  -                throws BuildException {
  -            throw new BuildException("Shouldn't be able instantiate a SubTask directly");
  -        }
  -
  -        /**
  -         *  the message as nested text
  -         */
  -        public void addText(String s) {
  -            setString(getProject().replaceProperties(s));
  -        }
  -
  -        /**
  -         * the message as an attribute
  -         */
  -        public void setString(String s) {
  -           taskString += s;
  -        }
  -    }
  -
  -    /**
  -     *  Sends text to the connected server
  -     */
  -    public class RExecWrite extends RExecSubTask {
  -        private boolean echoString = true;
  -        public void execute(AntRExecClient rexec)
  -               throws BuildException {
  -           rexec.sendString(taskString, echoString);
  -        }
  -
  -        /**
  -         * Whether or not the message should be echoed to the log.
  -         * Defaults to <code>true</code>.
  -         */
  -        public void setEcho(boolean b) {
  -           echoString = b;
  -        }
  -    }
  -
  -    /**
  -     *  Reads the output from the connected server
  -     *  until the required string is found or we time out.
  -     */
  -    public class RExecRead extends RExecSubTask {
  -        private Integer timeout = null;
  -        public void execute(AntRExecClient rexec)
  -               throws BuildException {
  -            rexec.waitForString(taskString, timeout);
  -        }
  -        /**
  -         *  a timeout value that overrides any task wide timeout.
  -         */
  -        public void setTimeout(Integer i) {
  -           this.timeout = i;
  -        }
  -
  -        /**
  -         * Sets the default timeout if none has been set already
  -         * @ant.attribute ignore="true"
  -         */
  -        public void setDefaultTimeout(Integer defaultTimeout) {
  -           if (timeout == null) {
  -              timeout = defaultTimeout;
  -           }
  -        }
  -    }
  -
  -    /**
  -     *  This class handles the abstraction of the rexec protocol.
  -     *  Currently it is a wrapper around <a
  -     *  href="http://jakarta.apache.org/commons/net/index.html">Jakarta
  -     *  Commons Net</a>.
  -     */
  -    public class AntRExecClient extends RExecClient {
  -        /**
  -         * Read from the rexec session until the string we are
  -         * waiting for is found
  -         * @param s The string to wait on
  -         */
  -        public void waitForString(String s) {
  -            waitForString(s, null);
  -        }
  -
  -        /**
  -         * Read from the rexec session until the string we are
  -         * waiting for is found or the timeout has been reached
  -         * @param s The string to wait on
  -         * @param timeout The maximum number of seconds to wait
  -         */
  -        public void waitForString(String s, Integer timeout) {
  -            InputStream is = this.getInputStream();
  -            try {
  -                StringBuffer sb = new StringBuffer();
  -                if (timeout == null || timeout.intValue() == 0) {
  -                    while (sb.toString().indexOf(s) == -1) {
  -                        sb.append((char) is.read());
  -                    }
  -                } else {
  -                    Calendar endTime = Calendar.getInstance();
  -                    endTime.add(Calendar.SECOND, timeout.intValue());
  -                    while (sb.toString().indexOf(s) == -1) {
  -                        while (Calendar.getInstance().before(endTime)
  -                            && is.available() == 0) {
  -                            Thread.sleep(250);
  -                        }
  -                        if (is.available() == 0) {
  -                            throw new BuildException(
  -                                "Response timed-out waiting for \"" + s + '\"',
  -                                getLocation());
  -                        }
  -                        sb.append((char) is.read());
  -                    }
  -                }
  -                log(sb.toString(), Project.MSG_INFO);
  -            } catch (BuildException be) {
  -                throw be;
  -            } catch (Exception e) {
  -                throw new BuildException(e, getLocation());
  -            }
  -        }
  -
  -        /**
  -         * Write this string to the rexec session.
  -         * @param echoString  Logs string sent
  -         */
  -        public void sendString(String s, boolean echoString) {
  -            OutputStream os = this.getOutputStream();
  -            try {
  -                os.write((s + "\n").getBytes());
  -                if (echoString) {
  -                    log(s, Project.MSG_INFO);
  -                }
  -                os.flush();
  -            } catch (Exception e) {
  -                throw new BuildException(e, getLocation());
  -            }
  -        }
  -        /**
  -         * Read from the rexec session until the EOF is found or
  -         * the timeout has been reached
  -         * @param timeout The maximum number of seconds to wait
  -         */
  -        public void waitForEOF(Integer timeout) {
  -            InputStream is = this.getInputStream();
  -            try {
  -                StringBuffer sb = new StringBuffer();
  -                if (timeout == null || timeout.intValue() == 0) {
  -                int read;
  -                    while ((read = is.read()) != -1) {
  -                        char c = (char) read;
  -                        sb.append(c);
  -                        if (c == '\n') {
  -                        log(sb.toString(), Project.MSG_INFO);
  -                        sb.delete(0, sb.length());
  -                        }
  -                    }
  -                } else {
  -                    Calendar endTime = Calendar.getInstance();
  -                    endTime.add(Calendar.SECOND, timeout.intValue());
  -                int read = 0;
  -                    while (read != -1) {
  -                        while (Calendar.getInstance().before(endTime) && is.available() == 0) {
  -                            Thread.sleep(250);
  -                        }
  -                        if (is.available() == 0) {
  -                        log(sb.toString(), Project.MSG_INFO);
  -                            throw new BuildException(
  -                                                     "Response timed-out waiting for EOF",
  -                                                     getLocation());
  -                        }
  -                        read =  is.read();
  -                        if (read != -1) {
  -                        char c = (char) read;
  -                        sb.append(c);
  -                        if (c == '\n') {
  -                                log(sb.toString(), Project.MSG_INFO);
  -                                sb.delete(0, sb.length());
  -                        }
  -                        }
  -                    }
  -                }
  -                if (sb.length() > 0) {
  -                log(sb.toString(), Project.MSG_INFO);
  -                }
  -            } catch (BuildException be) {
  -                throw be;
  -            } catch (Exception e) {
  -                throw new BuildException(e, getLocation());
  -            }
  -        }
  -
  -    }
  -    /**
  -     *  A string to wait for from the server.
  -     *  A subTask &lt;read&gt; tag was found.  Create the object,
  -     *  Save it in our list, and return it.
  -     */
  -
  -    public RExecSubTask createRead() {
  -        RExecSubTask task = (RExecSubTask) new RExecRead();
  -        rexecTasks.addElement(task);
  -        return task;
  -    }
  -    /**
  -     *  Add text to send to the server
  -     *  A subTask &lt;write&gt; tag was found.  Create the object,
  -     *  Save it in our list, and return it.
  -     */
  -    public RExecSubTask createWrite() {
  -        RExecSubTask task = (RExecSubTask) new RExecWrite();
  -        rexecTasks.addElement(task);
  -        return task;
  -    }
  -    /**
  -     *  Verify that all parameters are included.
  -     *  Connect and possibly login
  -     *  Iterate through the list of Reads and writes
  -     */
  -    public void execute() throws BuildException {
  -        /**  A server name is required to continue */
  -        if (server == null) {
  -            throw new BuildException("No Server Specified");
  -        }
  -        /**  A userid and password must appear together
  -         *   if they appear.  They are not required.
  -         */
  -        if (userid == null && password != null) {
  -            throw new BuildException("No Userid Specified");
  -        }
  -        if (password == null && userid != null) {
  -            throw new BuildException("No Password Specified");
  -        }
  -
  -        /**  Create the telnet client object */
  -        rexec = new AntRExecClient();
  -        try {
  -            rexec.connect(server, port);
  -        } catch (IOException e) {
  -            throw new BuildException("Can't connect to " + server);
  -        }
  -        /**  Login if userid and password were specified */
  -        if (userid != null && password != null) {
  -            login();
  -        }
  -        /**  Process each sub command */
  -        Enumeration tasksToRun = rexecTasks.elements();
  -        while (tasksToRun != null && tasksToRun.hasMoreElements()) {
  -            RExecSubTask task = (RExecSubTask) tasksToRun.nextElement();
  -            if (task instanceof RExecRead && defaultTimeout != null) {
  -                ((RExecRead) task).setDefaultTimeout(defaultTimeout);
  -            }
  -            task.execute(rexec);
  -        }
  -
  -        /** Keep reading input stream until end of it or time-out */
  -        rexec.waitForEOF(defaultTimeout);
  -    }
  -    /**
  -     *  Process a 'typical' login.  If it differs, use the read
  -     *  and write tasks explicitely
  -     */
  -    private void login() {
  -        if (addCarriageReturn) {
  -            rexec.sendString("\n", true);
  -        }
  -        rexec.waitForString("ogin:");
  -        rexec.sendString(userid, true);
  -        rexec.waitForString("assword:");
  -        rexec.sendString(password, false);
  -    }
  -    /**
  -     * Set the the comand to execute on the server;
  -     */
  -    public void setCommand(String c) { this.command = c; }
  -    /**
  -     *  send a carriage return after connecting; optional, defaults to false.
  -     */
  -    public void setInitialCR(boolean b) {
  -        this.addCarriageReturn = b;
  -    }
  -    /**
  -     *  Set the the login password to use
  -     * required if <tt>userid</tt> is set.
  -     */
  -    public void setPassword(String p) { this.password = p; }
  -    /**
  -     *  Set the tcp port to connect to; default is 23.
  -     */
  -    public void setPort(int p) { this.port = p; }
  -    /**
  -     *  Set the hostname or address of the remote server.
  -     */
  -    public void setServer(String m) { this.server = m; }
  -    /**
  -     * set a default timeout in seconds to wait for a response,
  -     * zero means forever (the default)
  -     */
  -    public void setTimeout(Integer i) {
  -        this.defaultTimeout = i;
  -    }
  -    /**
  -     * Set the the login id to use on the server;
  -     * required if <tt>password</tt> is set.
  -     */
  -    public void setUserid(String u) { this.userid = u; }
  -}
  +/*
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 2003 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution, if
  + *    any, must include the following acknowlegement:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowlegement may appear in the software itself,
  + *    if and wherever such third-party acknowlegements normally appear.
  + *
  + * 4. The names "Ant" and "Apache Software
  + *    Foundation" must not be used to endorse or promote products derived
  + *    from this software without prior written permission. For written
  + *    permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache"
  + *    nor may "Apache" appear in their names without prior written
  + *    permission of the Apache Group.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + */
  +
  +package org.apache.tools.ant.taskdefs.optional.net;
  +
  +import org.apache.commons.net.bsd.RExecClient;
  +
  +import java.io.IOException;
  +import java.io.InputStream;
  +import java.io.OutputStream;
  +import java.util.Calendar;
  +import java.util.Enumeration;
  +import java.util.Vector;
  +import org.apache.tools.ant.BuildException;
  +import org.apache.tools.ant.Project;
  +import org.apache.tools.ant.Task;
  +
  +/**
  + * Automates the rexec protocol.
  + *
  + * @since Ant 1.6
  + */
  +
  +public class RExecTask extends Task {
  +    /**
  +     *  The userid to login with, if automated login is used
  +     */
  +    private String userid  = null;
  +
  +    /**
  +     *  The password to login with, if automated login is used
  +     */
  +    private String password = null;
  +
  +    /**
  +     *  The command to execute
  +     */
  +    private String command = null;
  +
  +    /**
  +     *  The server to connect to.
  +     */
  +    private String server  = null;
  +
  +    /**
  +     *  The tcp port to connect to.
  +     */
  +    private int port = RExecClient.DEFAULT_PORT;
  +
  +    /**
  +     *  The Object which handles the rexec session.
  +     */
  +    private AntRExecClient rexec = null;
  +
  +    /**
  +     *  The list of read/write commands for this session
  +     */
  +    private Vector rexecTasks = new Vector();
  +
  +    /**
  +     *  If true, adds a CR to beginning of login script
  +     */
  +    private boolean addCarriageReturn = false;
  +
  +    /**
  +     *  Default time allowed for waiting for a valid response
  +     *  for all child reads.  A value of 0 means no limit.
  +     */
  +    private Integer defaultTimeout = null;
  +
  +    /**
  +     *  This class is the parent of the Read and Write tasks.
  +     *  It handles the common attributes for both.
  +     */
  +    public class RExecSubTask {
  +        protected String taskString = "";
  +        public void execute(AntRExecClient rexec)
  +                throws BuildException {
  +            throw new BuildException("Shouldn't be able instantiate a SubTask directly");
  +        }
  +
  +        /**
  +         *  the message as nested text
  +         */
  +        public void addText(String s) {
  +            setString(getProject().replaceProperties(s));
  +        }
  +
  +        /**
  +         * the message as an attribute
  +         */
  +        public void setString(String s) {
  +           taskString += s;
  +        }
  +    }
  +
  +    /**
  +     *  Sends text to the connected server
  +     */
  +    public class RExecWrite extends RExecSubTask {
  +        private boolean echoString = true;
  +        public void execute(AntRExecClient rexec)
  +               throws BuildException {
  +           rexec.sendString(taskString, echoString);
  +        }
  +
  +        /**
  +         * Whether or not the message should be echoed to the log.
  +         * Defaults to <code>true</code>.
  +         */
  +        public void setEcho(boolean b) {
  +           echoString = b;
  +        }
  +    }
  +
  +    /**
  +     *  Reads the output from the connected server
  +     *  until the required string is found or we time out.
  +     */
  +    public class RExecRead extends RExecSubTask {
  +        private Integer timeout = null;
  +        public void execute(AntRExecClient rexec)
  +               throws BuildException {
  +            rexec.waitForString(taskString, timeout);
  +        }
  +        /**
  +         *  a timeout value that overrides any task wide timeout.
  +         */
  +        public void setTimeout(Integer i) {
  +           this.timeout = i;
  +        }
  +
  +        /**
  +         * Sets the default timeout if none has been set already
  +         * @ant.attribute ignore="true"
  +         */
  +        public void setDefaultTimeout(Integer defaultTimeout) {
  +           if (timeout == null) {
  +              timeout = defaultTimeout;
  +           }
  +        }
  +    }
  +
  +    /**
  +     *  This class handles the abstraction of the rexec protocol.
  +     *  Currently it is a wrapper around <a
  +     *  href="http://jakarta.apache.org/commons/net/index.html">Jakarta
  +     *  Commons Net</a>.
  +     */
  +    public class AntRExecClient extends RExecClient {
  +        /**
  +         * Read from the rexec session until the string we are
  +         * waiting for is found
  +         * @param s The string to wait on
  +         */
  +        public void waitForString(String s) {
  +            waitForString(s, null);
  +        }
  +
  +        /**
  +         * Read from the rexec session until the string we are
  +         * waiting for is found or the timeout has been reached
  +         * @param s The string to wait on
  +         * @param timeout The maximum number of seconds to wait
  +         */
  +        public void waitForString(String s, Integer timeout) {
  +            InputStream is = this.getInputStream();
  +            try {
  +                StringBuffer sb = new StringBuffer();
  +                if (timeout == null || timeout.intValue() == 0) {
  +                    while (sb.toString().indexOf(s) == -1) {
  +                        sb.append((char) is.read());
  +                    }
  +                } else {
  +                    Calendar endTime = Calendar.getInstance();
  +                    endTime.add(Calendar.SECOND, timeout.intValue());
  +                    while (sb.toString().indexOf(s) == -1) {
  +                        while (Calendar.getInstance().before(endTime)
  +                            && is.available() == 0) {
  +                            Thread.sleep(250);
  +                        }
  +                        if (is.available() == 0) {
  +                            throw new BuildException(
  +                                "Response timed-out waiting for \"" + s + '\"',
  +                                getLocation());
  +                        }
  +                        sb.append((char) is.read());
  +                    }
  +                }
  +                log(sb.toString(), Project.MSG_INFO);
  +            } catch (BuildException be) {
  +                throw be;
  +            } catch (Exception e) {
  +                throw new BuildException(e, getLocation());
  +            }
  +        }
  +
  +        /**
  +         * Write this string to the rexec session.
  +         * @param echoString  Logs string sent
  +         */
  +        public void sendString(String s, boolean echoString) {
  +            OutputStream os = this.getOutputStream();
  +            try {
  +                os.write((s + "\n").getBytes());
  +                if (echoString) {
  +                    log(s, Project.MSG_INFO);
  +                }
  +                os.flush();
  +            } catch (Exception e) {
  +                throw new BuildException(e, getLocation());
  +            }
  +        }
  +        /**
  +         * Read from the rexec session until the EOF is found or
  +         * the timeout has been reached
  +         * @param timeout The maximum number of seconds to wait
  +         */
  +        public void waitForEOF(Integer timeout) {
  +            InputStream is = this.getInputStream();
  +            try {
  +                StringBuffer sb = new StringBuffer();
  +                if (timeout == null || timeout.intValue() == 0) {
  +                int read;
  +                    while ((read = is.read()) != -1) {
  +                        char c = (char) read;
  +                        sb.append(c);
  +                        if (c == '\n') {
  +                        log(sb.toString(), Project.MSG_INFO);
  +                        sb.delete(0, sb.length());
  +                        }
  +                    }
  +                } else {
  +                    Calendar endTime = Calendar.getInstance();
  +                    endTime.add(Calendar.SECOND, timeout.intValue());
  +                int read = 0;
  +                    while (read != -1) {
  +                        while (Calendar.getInstance().before(endTime) && is.available() == 0) {
  +                            Thread.sleep(250);
  +                        }
  +                        if (is.available() == 0) {
  +                        log(sb.toString(), Project.MSG_INFO);
  +                            throw new BuildException(
  +                                                     "Response timed-out waiting for EOF",
  +                                                     getLocation());
  +                        }
  +                        read =  is.read();
  +                        if (read != -1) {
  +                        char c = (char) read;
  +                        sb.append(c);
  +                        if (c == '\n') {
  +                                log(sb.toString(), Project.MSG_INFO);
  +                                sb.delete(0, sb.length());
  +                        }
  +                        }
  +                    }
  +                }
  +                if (sb.length() > 0) {
  +                log(sb.toString(), Project.MSG_INFO);
  +                }
  +            } catch (BuildException be) {
  +                throw be;
  +            } catch (Exception e) {
  +                throw new BuildException(e, getLocation());
  +            }
  +        }
  +
  +    }
  +    /**
  +     *  A string to wait for from the server.
  +     *  A subTask &lt;read&gt; tag was found.  Create the object,
  +     *  Save it in our list, and return it.
  +     */
  +
  +    public RExecSubTask createRead() {
  +        RExecSubTask task = (RExecSubTask) new RExecRead();
  +        rexecTasks.addElement(task);
  +        return task;
  +    }
  +    /**
  +     *  Add text to send to the server
  +     *  A subTask &lt;write&gt; tag was found.  Create the object,
  +     *  Save it in our list, and return it.
  +     */
  +    public RExecSubTask createWrite() {
  +        RExecSubTask task = (RExecSubTask) new RExecWrite();
  +        rexecTasks.addElement(task);
  +        return task;
  +    }
  +    /**
  +     *  Verify that all parameters are included.
  +     *  Connect and possibly login
  +     *  Iterate through the list of Reads and writes
  +     */
  +    public void execute() throws BuildException {
  +        /**  A server name is required to continue */
  +        if (server == null) {
  +            throw new BuildException("No Server Specified");
  +        }
  +        /**  A userid and password must appear together
  +         *   if they appear.  They are not required.
  +         */
  +        if (userid == null && password != null) {
  +            throw new BuildException("No Userid Specified");
  +        }
  +        if (password == null && userid != null) {
  +            throw new BuildException("No Password Specified");
  +        }
  +
  +        /**  Create the telnet client object */
  +        rexec = new AntRExecClient();
  +        try {
  +            rexec.connect(server, port);
  +        } catch (IOException e) {
  +            throw new BuildException("Can't connect to " + server);
  +        }
  +        /**  Login if userid and password were specified */
  +        if (userid != null && password != null) {
  +            login();
  +        }
  +        /**  Process each sub command */
  +        Enumeration tasksToRun = rexecTasks.elements();
  +        while (tasksToRun != null && tasksToRun.hasMoreElements()) {
  +            RExecSubTask task = (RExecSubTask) tasksToRun.nextElement();
  +            if (task instanceof RExecRead && defaultTimeout != null) {
  +                ((RExecRead) task).setDefaultTimeout(defaultTimeout);
  +            }
  +            task.execute(rexec);
  +        }
  +
  +        /** Keep reading input stream until end of it or time-out */
  +        rexec.waitForEOF(defaultTimeout);
  +    }
  +    /**
  +     *  Process a 'typical' login.  If it differs, use the read
  +     *  and write tasks explicitely
  +     */
  +    private void login() {
  +        if (addCarriageReturn) {
  +            rexec.sendString("\n", true);
  +        }
  +        rexec.waitForString("ogin:");
  +        rexec.sendString(userid, true);
  +        rexec.waitForString("assword:");
  +        rexec.sendString(password, false);
  +    }
  +    /**
  +     * Set the the comand to execute on the server;
  +     */
  +    public void setCommand(String c) { this.command = c; }
  +    /**
  +     *  send a carriage return after connecting; optional, defaults to false.
  +     */
  +    public void setInitialCR(boolean b) {
  +        this.addCarriageReturn = b;
  +    }
  +    /**
  +     *  Set the the login password to use
  +     * required if <tt>userid</tt> is set.
  +     */
  +    public void setPassword(String p) { this.password = p; }
  +    /**
  +     *  Set the tcp port to connect to; default is 23.
  +     */
  +    public void setPort(int p) { this.port = p; }
  +    /**
  +     *  Set the hostname or address of the remote server.
  +     */
  +    public void setServer(String m) { this.server = m; }
  +    /**
  +     * set a default timeout in seconds to wait for a response,
  +     * zero means forever (the default)
  +     */
  +    public void setTimeout(Integer i) {
  +        this.defaultTimeout = i;
  +    }
  +    /**
  +     * Set the the login id to use on the server;
  +     * required if <tt>password</tt> is set.
  +     */
  +    public void setUserid(String u) { this.userid = u; }
  +}
  
  
  
  1.4       +242 -242  ant/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJDoc.java
  
  Index: JJDoc.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJDoc.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JJDoc.java	1 Aug 2003 10:08:12 -0000	1.3
  +++ JJDoc.java	13 Sep 2003 12:37:04 -0000	1.4
  @@ -1,242 +1,242 @@
  -/*
  - * The Apache Software License, Version 1.1
  - *
  - * Copyright (c) 2003 The Apache Software Foundation.  All rights
  - * reserved.
  - *
  - * Redistribution and use in source and binary forms, with or without
  - * modification, are permitted provided that the following conditions
  - * are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  - *
  - * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowlegement may appear in the software itself,
  - *    if and wherever such third-party acknowlegements normally appear.
  - *
  - * 4. The names "Ant" and "Apache Software
  - *    Foundation" must not be used to endorse or promote products derived
  - *    from this software without prior written permission. For written
  - *    permission, please contact apache@apache.org.
  - *
  - * 5. Products derived from this software may not be called "Apache"
  - *    nor may "Apache" appear in their names without prior written
  - *    permission of the Apache Group.
  - *
  - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  - * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  - * SUCH DAMAGE.
  - * ====================================================================
  - *
  - * This software consists of voluntary contributions made by many
  - * individuals on behalf of the Apache Software Foundation.  For more
  - * information on the Apache Software Foundation, please see
  - * <http://www.apache.org/>.
  - */
  -
  -package org.apache.tools.ant.taskdefs.optional.javacc;
  -
  -import java.io.File;
  -import java.io.IOException;
  -import java.util.Enumeration;
  -import java.util.Hashtable;
  -import org.apache.tools.ant.BuildException;
  -import org.apache.tools.ant.Project;
  -import org.apache.tools.ant.Task;
  -import org.apache.tools.ant.taskdefs.Execute;
  -import org.apache.tools.ant.taskdefs.LogStreamHandler;
  -import org.apache.tools.ant.types.Commandline;
  -import org.apache.tools.ant.types.CommandlineJava;
  -import org.apache.tools.ant.types.Path;
  -import org.apache.tools.ant.util.JavaEnvUtils;
  -
  -/**
  - * Runs the JJDoc compiler compiler.
  - *
  - * @author Jene Jasper <a href="mailto:jjasper@abz.nl">jjasper@abz.nl</a>
  - * @author thomas.haas@softwired-inc.com
  - * @author Michael Saunders 
  - *         <a href="mailto:michael@amtec.com">michael@amtec.com</a>
  - */
  -public class JJDoc extends Task {
  -
  -    // keys to optional attributes
  -    private static final String OUTPUT_FILE       = "OUTPUT_FILE";
  -    private static final String TEXT              = "TEXT";
  -    private static final String ONE_TABLE         = "ONE_TABLE";
  -
  -    private final Hashtable optionalAttrs = new Hashtable();
  -
  -    private String outputFile = null;
  -    private boolean plainText = false;
  -
  -    private static final String DEFAULT_SUFFIX_HTML = ".html";
  -    private static final String DEFAULT_SUFFIX_TEXT = ".txt";
  -
  -    // required attributes
  -    private File target          = null;
  -    private File javaccHome      = null;
  -
  -    private CommandlineJava cmdl = new CommandlineJava();
  -
  -
  -    /**
  -     * Sets the TEXT BNF documentation option.
  -     */
  -    public void setText(boolean plainText) {
  -        optionalAttrs.put(TEXT, new Boolean(plainText));
  -        this.plainText = plainText;
  -    }
  -
  -    /**
  -     * Sets the ONE_TABLE documentation option.
  -     */
  -    public void setOnetable(boolean oneTable) {
  -        optionalAttrs.put(ONE_TABLE, new Boolean(oneTable));
  -    }
  -
  -    /**
  -     * The outputfile to write the generated BNF documentation file to.
  -     * If not set, the file is written with the same name as
  -     * the JavaCC grammar file with a suffix .html or .txt.
  -     */
  -    public void setOutputfile(String outputFile) {
  -        this.outputFile = outputFile;
  -    }
  -
  -    /**
  -     * The javacc grammar file to process.
  -     */
  -    public void setTarget(File target) {
  -        this.target = target;
  -    }
  -
  -    /**
  -     * The directory containing the JavaCC distribution.
  -     */
  -    public void setJavacchome(File javaccHome) {
  -        this.javaccHome = javaccHome;
  -    }
  -
  -    public JJDoc() {
  -        cmdl.setVm(JavaEnvUtils.getJreExecutable("java"));
  -    }
  -
  -    public void execute() throws BuildException {
  -
  -        // load command line with optional attributes
  -        Enumeration iter = optionalAttrs.keys();
  -        while (iter.hasMoreElements()) {
  -            String name  = (String) iter.nextElement();
  -            Object value = optionalAttrs.get(name);
  -            cmdl.createArgument()
  -                .setValue("-" + name + ":" + value.toString());
  -        }
  -
  -        if (target == null || !target.isFile()) {
  -            throw new BuildException("Invalid target: " + target);
  -        }
  -
  -        if (outputFile != null) {
  -            cmdl.createArgument() .setValue("-" + OUTPUT_FILE + ":" 
  -                                            + outputFile.replace('\\', '/'));
  -        }
  -
  -        // use the directory containing the target as the output directory
  -        File javaFile = new File(createOutputFileName(target, outputFile, 
  -                                                      plainText));
  -
  -        if (javaFile.exists()
  -             && target.lastModified() < javaFile.lastModified()) {
  -            log("Target is already built - skipping (" + target + ")",
  -                Project.MSG_VERBOSE);
  -            return;
  -        }
  -
  -        cmdl.createArgument().setValue(target.getAbsolutePath());
  -
  -        cmdl.setClassname(JavaCC.getMainClass(javaccHome, 
  -                                              JavaCC.TASKDEF_TYPE_JJDOC));
  -
  -        final Path classpath = cmdl.createClasspath(getProject());
  -        final File javaccJar = JavaCC.getArchiveFile(javaccHome);
  -        classpath.createPathElement().setPath(javaccJar.getAbsolutePath());
  -        classpath.addJavaRuntime();
  -
  -        final Commandline.Argument arg = cmdl.createVmArgument();
  -        arg.setValue("-mx140M");
  -        arg.setValue("-Dinstall.root=" + javaccHome.getAbsolutePath());
  -
  -        final Execute process =
  -            new Execute(new LogStreamHandler(this,
  -                                             Project.MSG_INFO,
  -                                             Project.MSG_INFO),
  -                        null);
  -        log(cmdl.describeCommand(), Project.MSG_VERBOSE);
  -        process.setCommandline(cmdl.getCommandline());
  -
  -        try {
  -            if (process.execute() != 0) {
  -                throw new BuildException("JJDoc failed.");
  -            }
  -        } catch (IOException e) {
  -            throw new BuildException("Failed to launch JJDoc", e);
  -        }
  -    }
  -
  -    private String createOutputFileName(File target, String optionalOutputFile,
  -                                        boolean plainText) {
  -        String suffix = DEFAULT_SUFFIX_HTML;
  -        String javaccFile = target.getAbsolutePath().replace('\\','/');
  -
  -        if (plainText) {
  -            suffix = DEFAULT_SUFFIX_TEXT;
  -        }
  -
  -        if ((optionalOutputFile == null) || optionalOutputFile.equals("")) {
  -            int filePos = javaccFile.lastIndexOf("/");
  -
  -            if (filePos >= 0) {
  -                javaccFile = javaccFile.substring(filePos + 1);
  -            }
  -
  -            int suffixPos = javaccFile.lastIndexOf('.');
  -
  -            if (suffixPos == -1) {
  -                optionalOutputFile = javaccFile + suffix;
  -            } else {
  -                String currentSuffix = javaccFile.substring(suffixPos);
  -
  -                if (currentSuffix.equals(suffix)) {
  -                    optionalOutputFile = javaccFile + suffix;
  -                } else {
  -                    optionalOutputFile = javaccFile.substring(0, suffixPos) 
  -                        + suffix;
  -                }
  -            }
  -        } else {
  -            optionalOutputFile = optionalOutputFile.replace('\\','/');
  -        }
  -
  -        return (getProject().getBaseDir() + "/" + optionalOutputFile)
  -            .replace('\\', '/');
  -    }
  -}
  +/*
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 2003 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution, if
  + *    any, must include the following acknowlegement:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowlegement may appear in the software itself,
  + *    if and wherever such third-party acknowlegements normally appear.
  + *
  + * 4. The names "Ant" and "Apache Software
  + *    Foundation" must not be used to endorse or promote products derived
  + *    from this software without prior written permission. For written
  + *    permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache"
  + *    nor may "Apache" appear in their names without prior written
  + *    permission of the Apache Group.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + */
  +
  +package org.apache.tools.ant.taskdefs.optional.javacc;
  +
  +import java.io.File;
  +import java.io.IOException;
  +import java.util.Enumeration;
  +import java.util.Hashtable;
  +import org.apache.tools.ant.BuildException;
  +import org.apache.tools.ant.Project;
  +import org.apache.tools.ant.Task;
  +import org.apache.tools.ant.taskdefs.Execute;
  +import org.apache.tools.ant.taskdefs.LogStreamHandler;
  +import org.apache.tools.ant.types.Commandline;
  +import org.apache.tools.ant.types.CommandlineJava;
  +import org.apache.tools.ant.types.Path;
  +import org.apache.tools.ant.util.JavaEnvUtils;
  +
  +/**
  + * Runs the JJDoc compiler compiler.
  + *
  + * @author Jene Jasper <a href="mailto:jjasper@abz.nl">jjasper@abz.nl</a>
  + * @author thomas.haas@softwired-inc.com
  + * @author Michael Saunders 
  + *         <a href="mailto:michael@amtec.com">michael@amtec.com</a>
  + */
  +public class JJDoc extends Task {
  +
  +    // keys to optional attributes
  +    private static final String OUTPUT_FILE       = "OUTPUT_FILE";
  +    private static final String TEXT              = "TEXT";
  +    private static final String ONE_TABLE         = "ONE_TABLE";
  +
  +    private final Hashtable optionalAttrs = new Hashtable();
  +
  +    private String outputFile = null;
  +    private boolean plainText = false;
  +
  +    private static final String DEFAULT_SUFFIX_HTML = ".html";
  +    private static final String DEFAULT_SUFFIX_TEXT = ".txt";
  +
  +    // required attributes
  +    private File target          = null;
  +    private File javaccHome      = null;
  +
  +    private CommandlineJava cmdl = new CommandlineJava();
  +
  +
  +    /**
  +     * Sets the TEXT BNF documentation option.
  +     */
  +    public void setText(boolean plainText) {
  +        optionalAttrs.put(TEXT, new Boolean(plainText));
  +        this.plainText = plainText;
  +    }
  +
  +    /**
  +     * Sets the ONE_TABLE documentation option.
  +     */
  +    public void setOnetable(boolean oneTable) {
  +        optionalAttrs.put(ONE_TABLE, new Boolean(oneTable));
  +    }
  +
  +    /**
  +     * The outputfile to write the generated BNF documentation file to.
  +     * If not set, the file is written with the same name as
  +     * the JavaCC grammar file with a suffix .html or .txt.
  +     */
  +    public void setOutputfile(String outputFile) {
  +        this.outputFile = outputFile;
  +    }
  +
  +    /**
  +     * The javacc grammar file to process.
  +     */
  +    public void setTarget(File target) {
  +        this.target = target;
  +    }
  +
  +    /**
  +     * The directory containing the JavaCC distribution.
  +     */
  +    public void setJavacchome(File javaccHome) {
  +        this.javaccHome = javaccHome;
  +    }
  +
  +    public JJDoc() {
  +        cmdl.setVm(JavaEnvUtils.getJreExecutable("java"));
  +    }
  +
  +    public void execute() throws BuildException {
  +
  +        // load command line with optional attributes
  +        Enumeration iter = optionalAttrs.keys();
  +        while (iter.hasMoreElements()) {
  +            String name  = (String) iter.nextElement();
  +            Object value = optionalAttrs.get(name);
  +            cmdl.createArgument()
  +                .setValue("-" + name + ":" + value.toString());
  +        }
  +
  +        if (target == null || !target.isFile()) {
  +            throw new BuildException("Invalid target: " + target);
  +        }
  +
  +        if (outputFile != null) {
  +            cmdl.createArgument() .setValue("-" + OUTPUT_FILE + ":" 
  +                                            + outputFile.replace('\\', '/'));
  +        }
  +
  +        // use the directory containing the target as the output directory
  +        File javaFile = new File(createOutputFileName(target, outputFile, 
  +                                                      plainText));
  +
  +        if (javaFile.exists()
  +             && target.lastModified() < javaFile.lastModified()) {
  +            log("Target is already built - skipping (" + target + ")",
  +                Project.MSG_VERBOSE);
  +            return;
  +        }
  +
  +        cmdl.createArgument().setValue(target.getAbsolutePath());
  +
  +        cmdl.setClassname(JavaCC.getMainClass(javaccHome, 
  +                                              JavaCC.TASKDEF_TYPE_JJDOC));
  +
  +        final Path classpath = cmdl.createClasspath(getProject());
  +        final File javaccJar = JavaCC.getArchiveFile(javaccHome);
  +        classpath.createPathElement().setPath(javaccJar.getAbsolutePath());
  +        classpath.addJavaRuntime();
  +
  +        final Commandline.Argument arg = cmdl.createVmArgument();
  +        arg.setValue("-mx140M");
  +        arg.setValue("-Dinstall.root=" + javaccHome.getAbsolutePath());
  +
  +        final Execute process =
  +            new Execute(new LogStreamHandler(this,
  +                                             Project.MSG_INFO,
  +                                             Project.MSG_INFO),
  +                        null);
  +        log(cmdl.describeCommand(), Project.MSG_VERBOSE);
  +        process.setCommandline(cmdl.getCommandline());
  +
  +        try {
  +            if (process.execute() != 0) {
  +                throw new BuildException("JJDoc failed.");
  +            }
  +        } catch (IOException e) {
  +            throw new BuildException("Failed to launch JJDoc", e);
  +        }
  +    }
  +
  +    private String createOutputFileName(File target, String optionalOutputFile,
  +                                        boolean plainText) {
  +        String suffix = DEFAULT_SUFFIX_HTML;
  +        String javaccFile = target.getAbsolutePath().replace('\\','/');
  +
  +        if (plainText) {
  +            suffix = DEFAULT_SUFFIX_TEXT;
  +        }
  +
  +        if ((optionalOutputFile == null) || optionalOutputFile.equals("")) {
  +            int filePos = javaccFile.lastIndexOf("/");
  +
  +            if (filePos >= 0) {
  +                javaccFile = javaccFile.substring(filePos + 1);
  +            }
  +
  +            int suffixPos = javaccFile.lastIndexOf('.');
  +
  +            if (suffixPos == -1) {
  +                optionalOutputFile = javaccFile + suffix;
  +            } else {
  +                String currentSuffix = javaccFile.substring(suffixPos);
  +
  +                if (currentSuffix.equals(suffix)) {
  +                    optionalOutputFile = javaccFile + suffix;
  +                } else {
  +                    optionalOutputFile = javaccFile.substring(0, suffixPos) 
  +                        + suffix;
  +                }
  +            }
  +        } else {
  +            optionalOutputFile = optionalOutputFile.replace('\\','/');
  +        }
  +
  +        return (getProject().getBaseDir() + "/" + optionalOutputFile)
  +            .replace('\\', '/');
  +    }
  +}
  
  
  
  1.2       +96 -96    ant/docs/manual/CoreTypes/zipfileset.html
  
  Index: zipfileset.html
  ===================================================================
  RCS file: /home/cvs/ant/docs/manual/CoreTypes/zipfileset.html,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- zipfileset.html	18 Apr 2003 22:02:58 -0000	1.1
  +++ zipfileset.html	13 Sep 2003 12:37:04 -0000	1.2
  @@ -1,96 +1,96 @@
  -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  -<html>
  -<head>
  -  <meta http-equiv="Content-Language" content="en-us">
  -  <title>ZipFileSet Type</title>
  -</head>
  -<body>
  -<h2><a name="fileset">ZipFileSet</a></h2>
  -<p>A <code>&lt;zipfileset&gt;</code> is a special form of a <code>&lt;<a
  - href="fileset.html">fileset</a>&gt;</code> which can behave in 2
  -different ways : <br>
  -</p>
  -<ul>
  -  <li>When the <span style="font-style: italic;">src</span> attribute
  -is used, the zipfileset is populated with zip entries found in the file <span
  - style="font-style: italic;">src</span>.<br>
  -  </li>
  -  <li>When the <span style="font-style: italic;">dir</span> attribute
  -is used, the zipfileset is populated with filesystem files found under <span
  - style="font-style: italic;">dir</span>.<br>
  -  </li>
  -</ul>
  -<p><code>&lt;zipfileset&gt;</code> supports all attributes of <code>&lt;<a
  - href="file:///C:/dev/gnu/ant/docs/manual/CoreTypes/fileset.html">fileset</a>&gt;</code>
  -in addition to those listed below.<br>
  -</p>
  -<p>Since Ant 1.6, a zipfileset can be defined with the <span
  - style="font-style: italic;">id </span>attribute and referred to with
  -the <span style="font-style: italic;">refid</span> attribute.<br>
  -</p>
  -<h3>Parameters</h3>
  -<table border="1" cellpadding="2" cellspacing="0">
  -  <tbody>
  -    <tr>
  -      <td valign="top"><b>Attribute</b></td>
  -      <td valign="top"><b>Description</b></td>
  -      <td valign="top" align="center"><b>Required</b></td>
  -    </tr>
  -    <tr>
  -      <td valign="top">prefix</td>
  -      <td valign="top">all files in the fileset are prefixed with that 
  -path in the archive.</td>
  -      <td align="center" valign="top">No</td>
  -    </tr>
  -    <tr>
  -      <td valign="top">fullpath</td>
  -      <td valign="top">the file described by the fileset is placed at  
  -that exact location in the archive.</td>
  -      <td align="center" valign="top">No</td>
  -    </tr>
  -    <tr>
  -      <td valign="top">src</td>
  -      <td valign="top">may be used in place of the <i>dir</i> attribute
  - to specify a zip file whose contents will be extracted and     included
  -in the archive.</td>
  -      <td align="center" valign="top">No</td>
  -    </tr>
  -    <tr>
  -      <td valign="top">filemode</td>
  -      <td valign="top">A 3 digit octal string, specify the user, group 
  -and other modes in the standard Unix fashion.  Only applies to    
  -plain files.  Default is 644. <em>since Ant 1.5.2</em>.</td>
  -      <td align="center" valign="top">No</td>
  -    </tr>
  -    <tr>
  -      <td valign="top">dirmode</td>
  -      <td valign="top">A 3 digit octal string, specify the user, group 
  -and other modes in the standard Unix fashion.  Only applies to    
  -directories.  Default is 755. <em>since Ant 1.5.2</em>.</td>
  -      <td align="center" valign="top">No</td>
  -    </tr>
  -  </tbody>
  -</table>
  -<p>The <i>fullpath</i> attribute can only be set for filesets that
  -represent a single file. The <i>prefix</i> and <i>fullpath</i>
  -attributes cannot both be set on the same fileset.</p>
  -<p>When using the <i>src</i> attribute, include and exclude patterns
  -may be used to specify a subset of the zip file for inclusion in the
  -archive as with the <i>dir</i> attribute.</p>
  -<h4>Examples</h4>
  -<blockquote>
  -  <pre>  &lt;zip destfile="${dist}/manual.zip"&gt;<br>    &lt;zipfileset dir="htdocs/manual" prefix="docs/user-guide"/&gt;<br>    &lt;zipfileset dir="." includes="ChangeLog27.txt" fullpath="docs/ChangeLog.txt"/&gt;<br>    &lt;zipfileset src="examples.zip" includes="**/*.html" prefix="docs/examples"/&gt;<br>  &lt;/zip&gt;<br></pre>
  -  <p>zips all files in the <code>htdocs/manual</code> directory into
  -the <code>docs/user-guide</code> directory in the archive, adds the
  -file <code>ChangeLog27.txt</code> in the current directory as <code>docs/ChangeLog.txt</code>,
  -and includes all the html files in <code>examples.zip</code> under <code>docs/examples</code>.
  -The archive might end up containing the files:</p>
  -  <code> docs/user-guide/html/index.html<br>
  -docs/ChangeLog.txt<br>
  -docs/examples/index.html<br>
  -  </code></blockquote>
  -<hr>
  -<p align="center">Copyright &copy; 2003 Apache Software Foundation. All
  -rights Reserved.</p>
  -</body>
  -</html>
  +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  +<html>
  +<head>
  +  <meta http-equiv="Content-Language" content="en-us">
  +  <title>ZipFileSet Type</title>
  +</head>
  +<body>
  +<h2><a name="fileset">ZipFileSet</a></h2>
  +<p>A <code>&lt;zipfileset&gt;</code> is a special form of a <code>&lt;<a
  + href="fileset.html">fileset</a>&gt;</code> which can behave in 2
  +different ways : <br>
  +</p>
  +<ul>
  +  <li>When the <span style="font-style: italic;">src</span> attribute
  +is used, the zipfileset is populated with zip entries found in the file <span
  + style="font-style: italic;">src</span>.<br>
  +  </li>
  +  <li>When the <span style="font-style: italic;">dir</span> attribute
  +is used, the zipfileset is populated with filesystem files found under <span
  + style="font-style: italic;">dir</span>.<br>
  +  </li>
  +</ul>
  +<p><code>&lt;zipfileset&gt;</code> supports all attributes of <code>&lt;<a
  + href="file:///C:/dev/gnu/ant/docs/manual/CoreTypes/fileset.html">fileset</a>&gt;</code>
  +in addition to those listed below.<br>
  +</p>
  +<p>Since Ant 1.6, a zipfileset can be defined with the <span
  + style="font-style: italic;">id </span>attribute and referred to with
  +the <span style="font-style: italic;">refid</span> attribute.<br>
  +</p>
  +<h3>Parameters</h3>
  +<table border="1" cellpadding="2" cellspacing="0">
  +  <tbody>
  +    <tr>
  +      <td valign="top"><b>Attribute</b></td>
  +      <td valign="top"><b>Description</b></td>
  +      <td valign="top" align="center"><b>Required</b></td>
  +    </tr>
  +    <tr>
  +      <td valign="top">prefix</td>
  +      <td valign="top">all files in the fileset are prefixed with that 
  +path in the archive.</td>
  +      <td align="center" valign="top">No</td>
  +    </tr>
  +    <tr>
  +      <td valign="top">fullpath</td>
  +      <td valign="top">the file described by the fileset is placed at  
  +that exact location in the archive.</td>
  +      <td align="center" valign="top">No</td>
  +    </tr>
  +    <tr>
  +      <td valign="top">src</td>
  +      <td valign="top">may be used in place of the <i>dir</i> attribute
  + to specify a zip file whose contents will be extracted and     included
  +in the archive.</td>
  +      <td align="center" valign="top">No</td>
  +    </tr>
  +    <tr>
  +      <td valign="top">filemode</td>
  +      <td valign="top">A 3 digit octal string, specify the user, group 
  +and other modes in the standard Unix fashion.  Only applies to    
  +plain files.  Default is 644. <em>since Ant 1.5.2</em>.</td>
  +      <td align="center" valign="top">No</td>
  +    </tr>
  +    <tr>
  +      <td valign="top">dirmode</td>
  +      <td valign="top">A 3 digit octal string, specify the user, group 
  +and other modes in the standard Unix fashion.  Only applies to    
  +directories.  Default is 755. <em>since Ant 1.5.2</em>.</td>
  +      <td align="center" valign="top">No</td>
  +    </tr>
  +  </tbody>
  +</table>
  +<p>The <i>fullpath</i> attribute can only be set for filesets that
  +represent a single file. The <i>prefix</i> and <i>fullpath</i>
  +attributes cannot both be set on the same fileset.</p>
  +<p>When using the <i>src</i> attribute, include and exclude patterns
  +may be used to specify a subset of the zip file for inclusion in the
  +archive as with the <i>dir</i> attribute.</p>
  +<h4>Examples</h4>
  +<blockquote>
  +  <pre>  &lt;zip destfile="${dist}/manual.zip"&gt;<br>    &lt;zipfileset dir="htdocs/manual" prefix="docs/user-guide"/&gt;<br>    &lt;zipfileset dir="." includes="ChangeLog27.txt" fullpath="docs/ChangeLog.txt"/&gt;<br>    &lt;zipfileset src="examples.zip" includes="**/*.html" prefix="docs/examples"/&gt;<br>  &lt;/zip&gt;<br></pre>
  +  <p>zips all files in the <code>htdocs/manual</code> directory into
  +the <code>docs/user-guide</code> directory in the archive, adds the
  +file <code>ChangeLog27.txt</code> in the current directory as <code>docs/ChangeLog.txt</code>,
  +and includes all the html files in <code>examples.zip</code> under <code>docs/examples</code>.
  +The archive might end up containing the files:</p>
  +  <code> docs/user-guide/html/index.html<br>
  +docs/ChangeLog.txt<br>
  +docs/examples/index.html<br>
  +  </code></blockquote>
  +<hr>
  +<p align="center">Copyright &copy; 2003 Apache Software Foundation. All
  +rights Reserved.</p>
  +</body>
  +</html>
  
  
  
  1.2       +101 -101  ant/docs/manual/OptionalTasks/jjdoc.html
  
  Index: jjdoc.html
  ===================================================================
  RCS file: /home/cvs/ant/docs/manual/OptionalTasks/jjdoc.html,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- jjdoc.html	23 Jul 2003 14:12:11 -0000	1.1
  +++ jjdoc.html	13 Sep 2003 12:37:04 -0000	1.2
  @@ -1,101 +1,101 @@
  -<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
  -<html>
  -<head>
  -   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  -   <meta http-equiv="Content-Language" content="en-us">
  -   <title>JJDoc Task</title>
  -</head>
  -<body>
  -
  -<h2>
  -<a NAME="jjtree"></a>JJDoc</h2>
  -<p><em>Since Ant 1.6</em></p>
  -<h3>Description</h3>
  -
  -<p>Invokes the <a href="http://javacc.dev.java.net/">JJDoc</a> preprocessor
  -for the JavaCC compiler compiler. It takes a JavaCC parser specification
  -and produces documentation for the BNF grammar.
  -It can operate in three modes, determined by command line options.
  -<p>To use the jjdoc task, set the <i>target</i> attribute to the name
  -of the JavaCC grammar file to process. You also need to specify the directory
  -containing the JavaCC installation using the <i>javacchome</i> attribute,
  -so that ant can find the JavaCC classes. Optionally, you can also set the
  -<i>outputfile</i> to write the generated BNF documentation file to a specific (directory and) file.
  -Otherwise jjdoc writes the generated BNF documentation file as the JavaCC
  -grammar file with a suffix .txt or .html.</p>
  -<p>This task only invokes JJDoc if the grammar file is newer than the
  -generated BNF documentation file.</p>
  -
  -<h3>Parameters</h3>
  -
  -<table BORDER CELLSPACING=0 CELLPADDING=2 >
  -<tr>
  -<td VALIGN=TOP><b>Attribute</b></td>
  -
  -<td VALIGN=TOP><b>Description</b></td>
  -
  -<td ALIGN=CENTER VALIGN=TOP><b>Required</b></td>
  -</tr>
  -
  -<tr>
  -<td VALIGN=TOP>target</td>
  -
  -<td VALIGN=TOP>The javacc grammar file to process.</td>
  -
  -<td ALIGN=CENTER VALIGN=TOP>Yes</td>
  -</tr>
  -
  -<tr>
  -<td VALIGN=TOP>javacchome</td>
  -
  -<td VALIGN=TOP>The directory containing the JavaCC distribution.</td>
  -
  -<td ALIGN=CENTER VALIGN=TOP>Yes</td>
  -</tr>
  -
  -<tr>
  -<td VALIGN=TOP>outputfile</td>
  -
  -<td VALIGN=TOP>The file to write the generated BNF documentation file to. If not set,
  -the file is written with the same name as the JavaCC grammar file but with a the suffix .html or .txt.&nbsp;</td>
  -
  -<td ALIGN=CENTER VALIGN=TOP>No</td>
  -</tr>
  -
  -<tr>
  -<td VALIGN=TOP>text</td>
  -
  -<td VALIGN=TOP>Sets the TEXT BNF documentation option. This is a boolean
  -option.</td>
  -
  -<td ALIGN=CENTER VALIGN=TOP>No</td>
  -</tr>
  -
  -<tr>
  -<td VALIGN=TOP>onetable</td>
  -
  -<td VALIGN=TOP>Sets the ONE_TABLE BNF documentation option. This is a boolean option.</td>
  -
  -<td ALIGN=CENTER VALIGN=TOP>No</td>
  -</tr>
  -</table>
  -
  -<h3>
  -Example</h3>
  -
  -<blockquote>
  -<pre>&lt;jjdoc&nbsp;
  -&nbsp;&nbsp;&nbsp; target="src/Parser.jj"&nbsp;
  -&nbsp;&nbsp;&nbsp; outputfile="doc/ParserBNF.html"
  -&nbsp;&nbsp;&nbsp; javacchome="c:/program files/JavaCC"&nbsp;
  -/&gt;</pre>
  -</blockquote>
  -This invokes JJDoc on grammar file src/Parser.jj, writing the generated
  -BNF documentation file, ParserBNF.html, file to doc.
  -<br>
  -<hr>
  -<p align="center">Copyright &copy; 2003 Apache Software Foundation. All rights
  -Reserved.</p>
  -</body>
  -</html>
  -
  +<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
  +<html>
  +<head>
  +   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  +   <meta http-equiv="Content-Language" content="en-us">
  +   <title>JJDoc Task</title>
  +</head>
  +<body>
  +
  +<h2>
  +<a NAME="jjtree"></a>JJDoc</h2>
  +<p><em>Since Ant 1.6</em></p>
  +<h3>Description</h3>
  +
  +<p>Invokes the <a href="http://javacc.dev.java.net/">JJDoc</a> preprocessor
  +for the JavaCC compiler compiler. It takes a JavaCC parser specification
  +and produces documentation for the BNF grammar.
  +It can operate in three modes, determined by command line options.
  +<p>To use the jjdoc task, set the <i>target</i> attribute to the name
  +of the JavaCC grammar file to process. You also need to specify the directory
  +containing the JavaCC installation using the <i>javacchome</i> attribute,
  +so that ant can find the JavaCC classes. Optionally, you can also set the
  +<i>outputfile</i> to write the generated BNF documentation file to a specific (directory and) file.
  +Otherwise jjdoc writes the generated BNF documentation file as the JavaCC
  +grammar file with a suffix .txt or .html.</p>
  +<p>This task only invokes JJDoc if the grammar file is newer than the
  +generated BNF documentation file.</p>
  +
  +<h3>Parameters</h3>
  +
  +<table BORDER CELLSPACING=0 CELLPADDING=2 >
  +<tr>
  +<td VALIGN=TOP><b>Attribute</b></td>
  +
  +<td VALIGN=TOP><b>Description</b></td>
  +
  +<td ALIGN=CENTER VALIGN=TOP><b>Required</b></td>
  +</tr>
  +
  +<tr>
  +<td VALIGN=TOP>target</td>
  +
  +<td VALIGN=TOP>The javacc grammar file to process.</td>
  +
  +<td ALIGN=CENTER VALIGN=TOP>Yes</td>
  +</tr>
  +
  +<tr>
  +<td VALIGN=TOP>javacchome</td>
  +
  +<td VALIGN=TOP>The directory containing the JavaCC distribution.</td>
  +
  +<td ALIGN=CENTER VALIGN=TOP>Yes</td>
  +</tr>
  +
  +<tr>
  +<td VALIGN=TOP>outputfile</td>
  +
  +<td VALIGN=TOP>The file to write the generated BNF documentation file to. If not set,
  +the file is written with the same name as the JavaCC grammar file but with a the suffix .html or .txt.&nbsp;</td>
  +
  +<td ALIGN=CENTER VALIGN=TOP>No</td>
  +</tr>
  +
  +<tr>
  +<td VALIGN=TOP>text</td>
  +
  +<td VALIGN=TOP>Sets the TEXT BNF documentation option. This is a boolean
  +option.</td>
  +
  +<td ALIGN=CENTER VALIGN=TOP>No</td>
  +</tr>
  +
  +<tr>
  +<td VALIGN=TOP>onetable</td>
  +
  +<td VALIGN=TOP>Sets the ONE_TABLE BNF documentation option. This is a boolean option.</td>
  +
  +<td ALIGN=CENTER VALIGN=TOP>No</td>
  +</tr>
  +</table>
  +
  +<h3>
  +Example</h3>
  +
  +<blockquote>
  +<pre>&lt;jjdoc&nbsp;
  +&nbsp;&nbsp;&nbsp; target="src/Parser.jj"&nbsp;
  +&nbsp;&nbsp;&nbsp; outputfile="doc/ParserBNF.html"
  +&nbsp;&nbsp;&nbsp; javacchome="c:/program files/JavaCC"&nbsp;
  +/&gt;</pre>
  +</blockquote>
  +This invokes JJDoc on grammar file src/Parser.jj, writing the generated
  +BNF documentation file, ParserBNF.html, file to doc.
  +<br>
  +<hr>
  +<p align="center">Copyright &copy; 2003 Apache Software Foundation. All rights
  +Reserved.</p>
  +</body>
  +</html>
  +
  
  
  
  1.2       +96 -96    ant/docs/manual/OptionalTasks/rexec.html
  
  Index: rexec.html
  ===================================================================
  RCS file: /home/cvs/ant/docs/manual/OptionalTasks/rexec.html,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- rexec.html	13 May 2003 14:37:02 -0000	1.1
  +++ rexec.html	13 Sep 2003 12:37:04 -0000	1.2
  @@ -1,96 +1,96 @@
  -<html>
  -
  -<head>
  -<meta http-equiv="Content-Language" content="en-us">
  -<title>RExec Task</title>
  -</head>
  -
  -<body>
  -
  -<h2><a name="rexec">RExec</a></h2>
  -<h3>Description</h3>
  -Task to automate a remote rexec session. Just like the Telnet task,
  -it uses nested <tt>&lt;read&gt;</tt> to indicate strings to wait for, and
  -<tt>&lt;write&gt;</tt> tags to specify text to send to the remote process.
  -
  -<p><b>Note:</b> This task depends on external libraries not included in the Ant distribution.
  -See <a href="../install.html#librarydependencies">Library Dependencies</a> for more information.</p>
  -
  -<h3>Parameters</h3>
  -<table border="1" cellpadding="2" cellspacing="0">
  -  <tr>
  -    <th>Attribute</th>
  -    <th>Values</th>
  -    <th>Required</th>
  -  </tr>
  -  <tr>
  -     <td>userid</td>
  -     <td>the login id to use on the remote server.</td>
  -     <td>Yes</td>
  -  </tr>
  -  <tr>
  -     <td>password</td>
  -     <td>the login password to use on the remote server.</td>
  -     <td>Yes</td>
  -  </tr>
  -  <tr>
  -     <td>server</td>
  -     <td>the address of the remote rexec server.</td>
  -     <td>Yes</td>
  -  </tr>
  -  <tr>
  -     <td>command</td>
  -     <td>the command to execute on the remote server.</td>
  -     <td>Yes</td>
  -  </tr>
  -  <tr>
  -     <td>port</td>
  -     <td>the port number of the remote rexec server. Defaults to port 512 in BSD Unix systems.</td>
  -     <td>No</td>
  -  </tr>
  -  <tr>
  -     <td>timeout</td>
  -     <td>set a default timeout to wait for a response. Specified in seconds. Default is no timeout.</td>
  -     <td>No</td>
  -  </tr>
  -</table>
  -<h3><a name="nested">Nested Elements</a></h3>
  -The input to send to the server, and responses to wait for, are
  -described as nested elements.  
  -
  -<h4>read</h4>
  -
  -<p>declare (as a text child of this element) a string to wait for.
  -The element supports the timeout attribute, which overrides any
  -timeout specified for the task as a whole. It also has a <tt>string</tt>
  -attribute, which is an alternative to specifying the string as 
  -a text element.
  -</p>
  -<i>It is not necessary to declare a closing &lt;read&gt; element like for the Telnet task. The connection is not broken until the command has completed and
  -the input stream (output of the command) is terminated.
  -</i>
  -<h4>write</h4>
  -
  -<p>describes the text to send to the server. The <tt>echo</tt> boolean
  -attribute controls whether the string is echoed to the local log; 
  -this is "true" by default
  -</p>
  -<h3>Example</h3>
  -A simple example of connecting to a server and running a command.
  -
  -<blockquote><pre>
  -&lt;rexec userid=&quot;bob&quot; password=&quot;badpass&quot; server=&quot;localhost&quot; command=&quot;ls&quot;/&gt;
  -</pre></blockquote>
  -
  -The task can be used with other ports as well:
  -<blockquote><pre>
  -&lt;rexec port=&quot;80&quot; userid=&quot;bob&quot; password=&quot;badpass&quot; server=&quot;localhost&quot; command=&quot;ls&quot;/&gt;
  -</pre></blockquote>
  -
  -<hr>
  -<p align="center">Copyright &copy; 2003 Apache Software Foundation. All rights
  -Reserved.</p>
  -
  -</body>
  -</html>
  -
  +<html>
  +
  +<head>
  +<meta http-equiv="Content-Language" content="en-us">
  +<title>RExec Task</title>
  +</head>
  +
  +<body>
  +
  +<h2><a name="rexec">RExec</a></h2>
  +<h3>Description</h3>
  +Task to automate a remote rexec session. Just like the Telnet task,
  +it uses nested <tt>&lt;read&gt;</tt> to indicate strings to wait for, and
  +<tt>&lt;write&gt;</tt> tags to specify text to send to the remote process.
  +
  +<p><b>Note:</b> This task depends on external libraries not included in the Ant distribution.
  +See <a href="../install.html#librarydependencies">Library Dependencies</a> for more information.</p>
  +
  +<h3>Parameters</h3>
  +<table border="1" cellpadding="2" cellspacing="0">
  +  <tr>
  +    <th>Attribute</th>
  +    <th>Values</th>
  +    <th>Required</th>
  +  </tr>
  +  <tr>
  +     <td>userid</td>
  +     <td>the login id to use on the remote server.</td>
  +     <td>Yes</td>
  +  </tr>
  +  <tr>
  +     <td>password</td>
  +     <td>the login password to use on the remote server.</td>
  +     <td>Yes</td>
  +  </tr>
  +  <tr>
  +     <td>server</td>
  +     <td>the address of the remote rexec server.</td>
  +     <td>Yes</td>
  +  </tr>
  +  <tr>
  +     <td>command</td>
  +     <td>the command to execute on the remote server.</td>
  +     <td>Yes</td>
  +  </tr>
  +  <tr>
  +     <td>port</td>
  +     <td>the port number of the remote rexec server. Defaults to port 512 in BSD Unix systems.</td>
  +     <td>No</td>
  +  </tr>
  +  <tr>
  +     <td>timeout</td>
  +     <td>set a default timeout to wait for a response. Specified in seconds. Default is no timeout.</td>
  +     <td>No</td>
  +  </tr>
  +</table>
  +<h3><a name="nested">Nested Elements</a></h3>
  +The input to send to the server, and responses to wait for, are
  +described as nested elements.  
  +
  +<h4>read</h4>
  +
  +<p>declare (as a text child of this element) a string to wait for.
  +The element supports the timeout attribute, which overrides any
  +timeout specified for the task as a whole. It also has a <tt>string</tt>
  +attribute, which is an alternative to specifying the string as 
  +a text element.
  +</p>
  +<i>It is not necessary to declare a closing &lt;read&gt; element like for the Telnet task. The connection is not broken until the command has completed and
  +the input stream (output of the command) is terminated.
  +</i>
  +<h4>write</h4>
  +
  +<p>describes the text to send to the server. The <tt>echo</tt> boolean
  +attribute controls whether the string is echoed to the local log; 
  +this is "true" by default
  +</p>
  +<h3>Example</h3>
  +A simple example of connecting to a server and running a command.
  +
  +<blockquote><pre>
  +&lt;rexec userid=&quot;bob&quot; password=&quot;badpass&quot; server=&quot;localhost&quot; command=&quot;ls&quot;/&gt;
  +</pre></blockquote>
  +
  +The task can be used with other ports as well:
  +<blockquote><pre>
  +&lt;rexec port=&quot;80&quot; userid=&quot;bob&quot; password=&quot;badpass&quot; server=&quot;localhost&quot; command=&quot;ls&quot;/&gt;
  +</pre></blockquote>
  +
  +<hr>
  +<p align="center">Copyright &copy; 2003 Apache Software Foundation. All rights
  +Reserved.</p>
  +
  +</body>
  +</html>
  +
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message