ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@locus.apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/vss MSVSS.java MSVSSGET.java
Date Tue, 01 Aug 2000 13:47:04 GMT
bodewig     00/08/01 06:47:03

  Modified:    src/main/org/apache/tools/ant/taskdefs Javadoc.java
               src/main/org/apache/tools/ant/taskdefs/optional/vss
                        MSVSS.java MSVSSGET.java
  Log:
  MSVSS doesn't extend Exec any longer.
  
  Revision  Changes    Path
  1.21      +1 -1      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
  
  Index: Javadoc.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Javadoc.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- Javadoc.java	2000/08/01 12:47:55	1.20
  +++ Javadoc.java	2000/08/01 13:47:02	1.21
  @@ -675,7 +675,7 @@
               exe.setCommandline(cmd.getCommandline());
               exe.execute();
           } catch (IOException e) {
  -            throw new BuildException("Execute failed: " + e, e, location);
  +            throw new BuildException("Javadoc failed: " + e, e, location);
           } finally {
               out.logFlush();
               err.logFlush();
  
  
  
  1.3       +22 -6     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java
  
  Index: MSVSS.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MSVSS.java	2000/07/17 09:00:03	1.2
  +++ MSVSS.java	2000/08/01 13:47:03	1.3
  @@ -55,7 +55,9 @@
   package org.apache.tools.ant.taskdefs.optional.vss;
   
   import org.apache.tools.ant.*;
  -import org.apache.tools.ant.taskdefs.Exec;
  +import org.apache.tools.ant.taskdefs.Execute;
  +import org.apache.tools.ant.taskdefs.LogStreamHandler;
  +import org.apache.tools.ant.types.Commandline;
   
   import java.io.File;
   
  @@ -74,7 +76,7 @@
    * @author Craig Cottingham
    * @author Andrew Everitt
    */
  -public abstract class MSVSS extends Exec {
  +public abstract class MSVSS extends Task {
   
       private String m_SSDir = "";
       private String m_vssLogin = null;
  @@ -116,11 +118,11 @@
       /**
        * @return the appropriate login command if the 'login' attribute was specified, otherwise
an empty string
        */
  -    public String getLoginCommand() {
  +    public void getLoginCommand(Commandline cmd) {
           if ( m_vssLogin == null ) {
  -            return "";
  +            return;
           } else {
  -            return new String(" " + FLAG_LOGIN + m_vssLogin);
  +            cmd.createArgument().setValue(FLAG_LOGIN + m_vssLogin);
           }
       }
   
  @@ -144,9 +146,23 @@
        * @return m_vssPath
        */
       public String getVsspath() {
  -        return new String(" " + m_vssPath);
  +        return new String(m_vssPath);
       }
   
  +
  +    protected int run(Commandline cmd) {
  +        try {
  +            Execute exe = new Execute(new LogStreamHandler(this, 
  +                                                           Project.MSG_INFO,
  +                                                           Project.MSG_WARN));
  +            exe.setAntRun(project);
  +            exe.setWorkingDirectory(project.getBaseDir());
  +            exe.setCommandline(cmd.getCommandline());
  +            return exe.execute();
  +        } catch (java.io.IOException e) {
  +            throw new BuildException(e, location);
  +        }
  +    }
   
       /**
        * Constant for the thing to execute
  
  
  
  1.3       +48 -51    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSGET.java
  
  Index: MSVSSGET.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSGET.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MSVSSGET.java	2000/07/17 09:00:04	1.2
  +++ MSVSSGET.java	2000/08/01 13:47:03	1.3
  @@ -55,6 +55,8 @@
   package org.apache.tools.ant.taskdefs.optional.vss;
   
   import org.apache.tools.ant.*;
  +import org.apache.tools.ant.types.Commandline;
  +import org.apache.tools.ant.types.Path;
   
   import java.io.File;
   
  @@ -130,13 +132,13 @@
        * to execute the command line.
        */
       public void execute() throws BuildException {
  -        StringBuffer commandLine = new StringBuffer();
  +        Commandline commandLine = new Commandline();
           int result = 0;
   
           // first off, make sure that we've got a command and a vssdir ...
           if (getVsspath() == null) {
               String msg = "vsspath attribute must be set!";
  -            throw new BuildException(msg);
  +            throw new BuildException(msg, location);
           }
   
           // now look for illegal combinations of things ...
  @@ -144,35 +146,36 @@
           // build the command line from what we got the format is
           // ss Get VSS items [-G] [-H] [-I-] [-N] [-O] [-R] [-V] [-W] [-Y] [-?]
           // as specified in the SS.EXE help
  -        commandLine.append(getSSCommand()).append(' ').append(COMMAND_GET);
  +        commandLine.setExecutable(getSSCommand());
  +        commandLine.createArgument().setValue(COMMAND_GET);
   
           // VSS items
  -        commandLine.append(getVsspath());
  +        commandLine.createArgument().setValue(getVsspath());
           // -GL
  -        commandLine.append(getLocalpathCommand());
  +        getLocalpathCommand(commandLine);
           // -I-
  -        commandLine.append(" -I-");  // ignore all errors
  +        commandLine.createArgument().setValue("-I-");  // ignore all errors
           // -R
  -        commandLine.append(getRecursiveCommand());
  +        getRecursiveCommand(commandLine);
           // -V
  -        commandLine.append(getVersionCommand());
  +        getVersionCommand(commandLine);
           // -W
  -        commandLine.append(getWritableCommand());
  +        getWritableCommand(commandLine);
           // -Y
  -        commandLine.append(getLoginCommand());
  +        getLoginCommand(commandLine);
   
  -        result = run(commandLine.toString());
  +        result = run(commandLine);
           if ( result != 0 ) {
               String msg = "Failed executing: " + commandLine.toString();
  -            throw new BuildException(msg);
  +            throw new BuildException(msg, location);
           }
       }
   
       /**
        * Set the local path.
        */
  -    public void setLocalpath(String localPath) {
  -        m_LocalPath = project.translatePath(localPath);
  +    public void setLocalpath(Path localPath) {
  +        m_LocalPath = localPath.toString();
       }
   
       /**
  @@ -180,9 +183,9 @@
        * <p>
        * The localpath is created if it didn't exist
        */
  -    public String getLocalpathCommand() {
  +    public void getLocalpathCommand(Commandline cmd) {
           if (m_LocalPath == null) {
  -            return "";
  +            return;
           } else {
               // make sure m_LocalDir exists, create it if it doesn't
               File dir = project.resolveFile(m_LocalPath);
  @@ -191,82 +194,82 @@
                   if (done == false) {
                       String msg = "Directory " + m_LocalPath + " creation was not " +
                           "succesful for an unknown reason";
  -                    throw new BuildException(msg);
  +                    throw new BuildException(msg, location);
                   }
                   project.log("Created dir: " + dir.getAbsolutePath());
               }
   
  -            return new String(" " + FLAG_OVERRIDE_WORKING_DIR + m_LocalPath);
  +            cmd.createArgument().setValue(FLAG_OVERRIDE_WORKING_DIR + m_LocalPath);
           }
       }
   
       /**
        * Set behaviour recursive or non-recursive
        */
  -    public void setRecursive(String recursive) {
  -        m_Recursive = Project.toBoolean(recursive);
  +    public void setRecursive(boolean recursive) {
  +        m_Recursive = recursive;
       }
   
       /**
        * @return the 'recursive' command if the attribute was 'true', otherwise an empty
string
        */
  -    public String getRecursiveCommand() {
  +    public void getRecursiveCommand(Commandline cmd) {
           if ( !m_Recursive ) {
  -            return "";
  +            return;
           } else {
  -            return new String(" " + FLAG_RECURSION);
  +            cmd.createArgument().setValue(FLAG_RECURSION);
           }
       }
   
  -	/**
  +    /**
        * Set behaviour, used in get command to make files that are 'got' writable
  -	 */
  -    public final void setWritable(String argWritable) {
  -        m_Writable = Project.toBoolean(argWritable);
  -	}
  +     */
  +    public final void setWritable(boolean argWritable) {
  +        m_Writable = argWritable;
  +    }
   
       /**
        * @return the 'make writable' command if the attribute was 'true', otherwise an empty
string
        */
  -    public String getWritableCommand() {
  +    public void getWritableCommand(Commandline cmd) {
           if ( !m_Writable ) {
  -            return "";
  +            return;
           } else {
  -            return new String(" " + FLAG_WRITABLE);
  +            cmd.createArgument().setValue(FLAG_WRITABLE);
           }
       }
   
  -	/**
  +    /**
        * Set the stored version string
        * <p>
        * Note we assume that if the supplied string has the value "null" that something
        * went wrong and that the string value got populated from a null object. This
        * happens if a ant variable is used e.g. version="${ver_server}" when ver_server
        * has not been defined to ant!
  -	 */
  +     */
       public void setVersion(String version) {
           if (version.equals("") || version.equals("null") ) {
               m_Version = null;
           } else {
               m_Version = version;
  -		}
  -	}
  +        }
  +    }
   
  -	/**
  +    /**
        * Set the stored date string
        * <p>
        * Note we assume that if the supplied string has the value "null" that something
        * went wrong and that the string value got populated from a null object. This
        * happens if a ant variable is used e.g. date="${date}" when date
        * has not been defined to ant!
  -	 */
  +     */
       public void setDate(String date) {
           if (date.equals("") || date.equals("null") ) {
               m_Date = null;
           } else {
               m_Date = date;
  -		}
  -	}
  +        }
  +    }
   
       /**
        * Set the labeled version to operate on in SourceSafe
  @@ -288,21 +291,15 @@
        * Simple order of priority. Returns the first specified of version, date, label
        * If none of these was specified returns ""
        */
  -    public String getVersionCommand() {
  +    public void getVersionCommand(Commandline cmd) {
   
           if ( m_Version != null) {
  -            return new String(" " + FLAG_VERSION + m_Version);
  -        }
  -
  -        if ( m_Date != null) {
  -            return new String(" " + FLAG_VERSION_DATE + m_Date);
  -        }
  -
  -        if (m_Label != null) {
  -            return new String(" " + FLAG_VERSION_LABEL + m_Label);
  +            cmd.createArgument().setValue(FLAG_VERSION + m_Version);
  +        } else if ( m_Date != null) {
  +            cmd.createArgument().setValue(FLAG_VERSION_DATE + m_Date);
  +        } else if (m_Label != null) {
  +            cmd.createArgument().setValue(FLAG_VERSION_LABEL + m_Label);
           }
  -
  -        return "";
       }
   
   }
  
  
  

Mime
View raw message