Browse Source

MSVSS doesn't extend Exec any longer.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267863 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 25 years ago
parent
commit
20dede5ad8
3 changed files with 71 additions and 58 deletions
  1. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Javadoc.java
  2. +22
    -6
      src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java
  3. +48
    -51
      src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSGET.java

+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/Javadoc.java View File

@@ -675,7 +675,7 @@ public class Javadoc extends Task {
exe.setCommandline(cmd.getCommandline()); exe.setCommandline(cmd.getCommandline());
exe.execute(); exe.execute();
} catch (IOException e) { } catch (IOException e) {
throw new BuildException("Execute failed: " + e, e, location);
throw new BuildException("Javadoc failed: " + e, e, location);
} finally { } finally {
out.logFlush(); out.logFlush();
err.logFlush(); err.logFlush();


+ 22
- 6
src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java View File

@@ -55,7 +55,9 @@
package org.apache.tools.ant.taskdefs.optional.vss; package org.apache.tools.ant.taskdefs.optional.vss;


import org.apache.tools.ant.*; 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; import java.io.File;


@@ -74,7 +76,7 @@ import java.io.File;
* @author Craig Cottingham * @author Craig Cottingham
* @author Andrew Everitt * @author Andrew Everitt
*/ */
public abstract class MSVSS extends Exec {
public abstract class MSVSS extends Task {


private String m_SSDir = ""; private String m_SSDir = "";
private String m_vssLogin = null; private String m_vssLogin = null;
@@ -116,11 +118,11 @@ public abstract class MSVSS extends Exec {
/** /**
* @return the appropriate login command if the 'login' attribute was specified, otherwise an empty string * @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 ) { if ( m_vssLogin == null ) {
return "";
return;
} else { } else {
return new String(" " + FLAG_LOGIN + m_vssLogin);
cmd.createArgument().setValue(FLAG_LOGIN + m_vssLogin);
} }
} }


@@ -144,10 +146,24 @@ public abstract class MSVSS extends Exec {
* @return m_vssPath * @return m_vssPath
*/ */
public String getVsspath() { 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 * Constant for the thing to execute
*/ */


+ 48
- 51
src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSGET.java View File

@@ -55,6 +55,8 @@
package org.apache.tools.ant.taskdefs.optional.vss; package org.apache.tools.ant.taskdefs.optional.vss;


import org.apache.tools.ant.*; import org.apache.tools.ant.*;
import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.Path;


import java.io.File; import java.io.File;


@@ -130,13 +132,13 @@ public class MSVSSGET extends MSVSS {
* to execute the command line. * to execute the command line.
*/ */
public void execute() throws BuildException { public void execute() throws BuildException {
StringBuffer commandLine = new StringBuffer();
Commandline commandLine = new Commandline();
int result = 0; int result = 0;


// first off, make sure that we've got a command and a vssdir ... // first off, make sure that we've got a command and a vssdir ...
if (getVsspath() == null) { if (getVsspath() == null) {
String msg = "vsspath attribute must be set!"; String msg = "vsspath attribute must be set!";
throw new BuildException(msg);
throw new BuildException(msg, location);
} }


// now look for illegal combinations of things ... // now look for illegal combinations of things ...
@@ -144,35 +146,36 @@ public class MSVSSGET extends MSVSS {
// build the command line from what we got the format is // build the command line from what we got the format is
// ss Get VSS items [-G] [-H] [-I-] [-N] [-O] [-R] [-V] [-W] [-Y] [-?] // ss Get VSS items [-G] [-H] [-I-] [-N] [-O] [-R] [-V] [-W] [-Y] [-?]
// as specified in the SS.EXE help // as specified in the SS.EXE help
commandLine.append(getSSCommand()).append(' ').append(COMMAND_GET);
commandLine.setExecutable(getSSCommand());
commandLine.createArgument().setValue(COMMAND_GET);


// VSS items // VSS items
commandLine.append(getVsspath());
commandLine.createArgument().setValue(getVsspath());
// -GL // -GL
commandLine.append(getLocalpathCommand());
getLocalpathCommand(commandLine);
// -I- // -I-
commandLine.append(" -I-"); // ignore all errors
commandLine.createArgument().setValue("-I-"); // ignore all errors
// -R // -R
commandLine.append(getRecursiveCommand());
getRecursiveCommand(commandLine);
// -V // -V
commandLine.append(getVersionCommand());
getVersionCommand(commandLine);
// -W // -W
commandLine.append(getWritableCommand());
getWritableCommand(commandLine);
// -Y // -Y
commandLine.append(getLoginCommand());
getLoginCommand(commandLine);


result = run(commandLine.toString());
result = run(commandLine);
if ( result != 0 ) { if ( result != 0 ) {
String msg = "Failed executing: " + commandLine.toString(); String msg = "Failed executing: " + commandLine.toString();
throw new BuildException(msg);
throw new BuildException(msg, location);
} }
} }


/** /**
* Set the local path. * 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 @@ public class MSVSSGET extends MSVSS {
* <p> * <p>
* The localpath is created if it didn't exist * The localpath is created if it didn't exist
*/ */
public String getLocalpathCommand() {
public void getLocalpathCommand(Commandline cmd) {
if (m_LocalPath == null) { if (m_LocalPath == null) {
return "";
return;
} else { } else {
// make sure m_LocalDir exists, create it if it doesn't // make sure m_LocalDir exists, create it if it doesn't
File dir = project.resolveFile(m_LocalPath); File dir = project.resolveFile(m_LocalPath);
@@ -191,82 +194,82 @@ public class MSVSSGET extends MSVSS {
if (done == false) { if (done == false) {
String msg = "Directory " + m_LocalPath + " creation was not " + String msg = "Directory " + m_LocalPath + " creation was not " +
"succesful for an unknown reason"; "succesful for an unknown reason";
throw new BuildException(msg);
throw new BuildException(msg, location);
} }
project.log("Created dir: " + dir.getAbsolutePath()); 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 * 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 * @return the 'recursive' command if the attribute was 'true', otherwise an empty string
*/ */
public String getRecursiveCommand() {
public void getRecursiveCommand(Commandline cmd) {
if ( !m_Recursive ) { if ( !m_Recursive ) {
return "";
return;
} else { } else {
return new String(" " + FLAG_RECURSION);
cmd.createArgument().setValue(FLAG_RECURSION);
} }
} }


/**
/**
* Set behaviour, used in get command to make files that are 'got' writable * 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 * @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 ) { if ( !m_Writable ) {
return "";
return;
} else { } else {
return new String(" " + FLAG_WRITABLE);
cmd.createArgument().setValue(FLAG_WRITABLE);
} }
} }


/**
/**
* Set the stored version string * Set the stored version string
* <p> * <p>
* Note we assume that if the supplied string has the value "null" that something * 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 * 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 * happens if a ant variable is used e.g. version="${ver_server}" when ver_server
* has not been defined to ant! * has not been defined to ant!
*/
*/
public void setVersion(String version) { public void setVersion(String version) {
if (version.equals("") || version.equals("null") ) { if (version.equals("") || version.equals("null") ) {
m_Version = null; m_Version = null;
} else { } else {
m_Version = version; m_Version = version;
}
}
}
}


/**
/**
* Set the stored date string * Set the stored date string
* <p> * <p>
* Note we assume that if the supplied string has the value "null" that something * 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 * 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 * happens if a ant variable is used e.g. date="${date}" when date
* has not been defined to ant! * has not been defined to ant!
*/
*/
public void setDate(String date) { public void setDate(String date) {
if (date.equals("") || date.equals("null") ) { if (date.equals("") || date.equals("null") ) {
m_Date = null; m_Date = null;
} else { } else {
m_Date = date; m_Date = date;
}
}
}
}


/** /**
* Set the labeled version to operate on in SourceSafe * Set the labeled version to operate on in SourceSafe
@@ -288,21 +291,15 @@ public class MSVSSGET extends MSVSS {
* Simple order of priority. Returns the first specified of version, date, label * Simple order of priority. Returns the first specified of version, date, label
* If none of these was specified returns "" * If none of these was specified returns ""
*/ */
public String getVersionCommand() {
public void getVersionCommand(Commandline cmd) {


if ( m_Version != null) { 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 "";
} }


} }


Loading…
Cancel
Save