You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by co...@apache.org on 2003/02/10 12:22:46 UTC
cvs commit: jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/optional/sos SOSTest.java
conor 2003/02/10 03:22:46
Modified: src/etc/testcases/taskdefs/optional/sos sos.xml
src/main/org/apache/tools/ant/taskdefs/optional/sos SOS.java
SOSCheckin.java SOSCheckout.java SOSCmd.java
SOSGet.java SOSLabel.java
src/testcases/org/apache/tools/ant/taskdefs/optional/sos
SOSTest.java
Log:
SOS tasks refactor.
PR: 16911
Submitted by: Jesse Stockall
Revision Changes Path
1.2 +1 -1 jakarta-ant/src/etc/testcases/taskdefs/optional/sos/sos.xml
Index: sos.xml
===================================================================
RCS file: /home/cvs/jakarta-ant/src/etc/testcases/taskdefs/optional/sos/sos.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -u -r1.1 -r1.2
--- sos.xml 26 Sep 2002 13:28:41 -0000 1.1
+++ sos.xml 10 Feb 2003 11:22:45 -0000 1.2
@@ -102,7 +102,7 @@
<soslabel sosserverpath="192.168.0.1:8888"
username="ant"
vssserverpath="\\server\vss\srcsafe.ini"
- projectpath="/SourceRoot/Project"/>
+ projectpath="$/SourceRoot/Project"/>
</target>
</project>
1.12 +136 -157 jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOS.java
Index: SOS.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOS.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -w -u -r1.11 -r1.12
--- SOS.java 26 Sep 2002 13:28:41 -0000 1.11
+++ SOS.java 10 Feb 2003 11:22:46 -0000 1.12
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2002-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -64,39 +64,13 @@
/**
* A base class for creating tasks for executing commands on SourceOffSite.
- * <p>
- * The class extends the 'exec' task as it operates by executing the soscmd(.exe) program
- * supplied with SOS. By default the task expects soscmd(.exe) to be in the path,
- * you can override this be specifying the sosdir attribute.
- * </p>
- * <p>
- * This class provides set and get methods for the following attributes
- * <br> 'vssserverpath'
- * <br> 'sosserverpath'
- * <br> 'vsspath'
- * <br> 'projectpath'
- * <br> 'username'
- * <br> 'password'
- * <br> 'soscmddir'
- * <br> 'file'
- * <br> 'soshome'
- * <br> 'localpath"
- * <br> 'comment'
- * <br> 'label'
- * <br> 'version'
- * <br> 'recursive'
- * <br> 'verbose'
- * <br> 'nocache'
- * <br> 'nocompression'
- * <br>
- * It also contains constants for the flags that can be passed to SOS.
- * <p>
+ *
* These tasks were inspired by the VSS tasks
*
- * @author <a href="mailto:jesse@cryptocard.com">Jesse Stockall</a>
+ * @author Jesse Stockall
*/
-public abstract class SOS extends Task {
+public abstract class SOS extends Task implements SOSCmd {
private String sosCmdDir = null;
private String sosUsername = null;
@@ -116,28 +90,28 @@
private boolean recursive = false;
private boolean verbose = false;
+ /** Commandline to be executed */
+ protected Commandline commandLine;
/**
- * flag to disable the cache when set;
- * optional needed if SOSHOME is set as an environment variable.
+ * Flag to disable the cache when set;
+ * optional needed if SOSHOME is set as an environment variable., default false
*
- * @param nocache The new noCache value
+ * @param nocache True to disable caching.
*/
- public void setNoCache(boolean nocache) {
+ public final void setNoCache(boolean nocache) {
noCache = nocache;
}
-
/**
- * Flag that disables compression when set; optional, default
+ * Flag that disables compression when set; optional, default false
*
- * @param nocompress true to disable compression
+ * @param nocompress True to disable compression.
*/
- public void setNoCompress(boolean nocompress) {
+ public final void setNoCompress(boolean nocompress) {
noCompress = nocompress;
}
-
/**
* Set the directory where soscmd(.exe) is located;
* optional, soscmd must be on the path if omitted.
@@ -148,7 +122,6 @@
sosCmdDir = Project.translatePath(dir);
}
-
/**
* Set the SourceSafe username; required.
*
@@ -158,7 +131,6 @@
sosUsername = username;
}
-
/**
* Set the SourceSafe password; optional.
*
@@ -168,11 +140,10 @@
sosPassword = password;
}
-
/**
- * Set the SourceSafe project path without the "$" prefix; required
+ * Set the SourceSafe project path; required.
*
- * @param projectpath The new projectPath value
+ * @param projectpath The new projectpath value
*/
public final void setProjectPath(String projectpath) {
if (projectpath.startsWith(SOSCmd.PROJECT_PREFIX)) {
@@ -182,7 +153,6 @@
}
}
-
/**
* Set the path to the location of the ss.ini file;
* required.
@@ -193,7 +163,6 @@
this.vssServerPath = vssServerPath;
}
-
/**
* The path to the SourceOffSite home directory
*
@@ -203,11 +172,9 @@
this.sosHome = sosHome;
}
-
/**
* Sets the address and port of SourceOffSite Server,
- * for example 192.168.0.1:8888.
- * This attribute is required.
+ * for example 192.168.0.1:8888.; required.
*
* @param sosServerPath The new sosServerPath value
*/
@@ -215,92 +182,56 @@
this.sosServerPath = sosServerPath;
}
-
/**
* Override the working directory and get to the specified path; optional.
*
* @param path The new localPath value
*/
- public void setLocalPath(Path path) {
+ public final void setLocalPath(Path path) {
localPath = path.toString();
}
-
- /**
- * Set the Filename to act upon; optional.
- * If no file is specified then the tasks
- * act upon the project
- *
- * @param filename The new file value
- */
- public final void setFile(String filename) {
- this.filename = filename;
- }
-
-
/**
* Enable verbose output; optional, default false
*
- * @param verbose The new verbose value
+ * @param verbose True for verbose output.
*/
public void setVerbose(boolean verbose) {
this.verbose = verbose;
}
+ // Special setters for the sub-classes
- /**
- * Flag to recursively apply the action (not valid
- * on all SOS tasks ); optional, default false
- *
- * @param recursive The new recursive value
- */
- public void setRecursive(boolean recursive) {
- this.recursive = recursive;
+ protected void setInternalFilename(String file) {
+ filename = file;
}
-
- /**
- * Set the a version number to get -
- * only works with the SOSGet on a file; optional.
- *
- * @param version The new version value
- */
- public void setVersion(String version) {
- this.version = version;
+ protected void setInternalRecursive(boolean recurse) {
+ recursive = recurse;
}
-
- /**
- * Set the labeled version to operate on in SourceSafe
- *
- * @param label The new label value
- */
- public void setLabel(String label) {
- this.label = label;
+ protected void setInternalComment(String text) {
+ comment = text;
}
-
- /**
- * Set the comment to apply to all files being labelled;
- * optional, only valid in SOSLabel
- *
- * @param comment The new comment value
- */
- public void setComment(String comment) {
- this.comment = comment;
+ protected void setInternalLabel(String text) {
+ label = text;
}
+ protected void setInternalVersion(String text) {
+ version = text;
+ }
/**
* Get the executable to run. Add the path if it was specifed in the build file
*
* @return String the executable to run
*/
- public String getSosCommand() {
+ protected String getSosCommand() {
if (sosCmdDir == null) {
- return SOSCmd.COMMAND_SOS_EXE;
+ return COMMAND_SOS_EXE;
} else {
- return sosCmdDir + File.separator + SOSCmd.COMMAND_SOS_EXE;
+ return sosCmdDir + File.separator + COMMAND_SOS_EXE;
}
}
@@ -308,148 +239,118 @@
* Get the comment
* @return String if it was set, null if not
*/
- public String getComment() {
+ protected String getComment() {
return comment;
}
-
/**
* Get the version
* @return String if it was set, null if not
*/
- public String getVersion() {
+ protected String getVersion() {
return version;
}
-
/**
* Get the label
* @return String if it was set, null if not
*/
- public String getLabel() {
+ protected String getLabel() {
return label;
}
-
/**
* Get the username
* @return String if it was set, null if not
*/
- public String getUsername() {
+ protected String getUsername() {
return sosUsername;
}
-
/**
* Get the password
* @return String empty string if it wans't set
*/
- public String getPassword() {
+ protected String getPassword() {
return sosPassword;
}
-
/**
* Get the project path
* @return String if it was set, null if not
*/
- public String getProjectPath() {
+ protected String getProjectPath() {
return projectPath;
}
-
/**
* Get the VSS server path
* @return String if it was set, null if not
*/
- public String getVssServerPath() {
+ protected String getVssServerPath() {
return vssServerPath;
}
-
/**
* Get the SOS home directory
* @return String if it was set, null if not
*/
- public String getSosHome() {
+ protected String getSosHome() {
return sosHome;
}
-
/**
* Get the SOS serve path
* @return String if it was set, null if not
*/
- public String getSosServerPath() {
+ protected String getSosServerPath() {
return sosServerPath;
}
-
/**
* Get the filename to be acted upon
* @return String if it was set, null if not
*/
- public String getFilename() {
+ protected String getFilename() {
return filename;
}
-
/**
* Get the NoCompress flag
*
* @return String the 'nocompress' Flag if the attribute was 'true', otherwise an empty string
*/
- public String getNoCompress() {
- if (!noCompress) {
- return "";
- } else {
- return SOSCmd.FLAG_NO_COMPRESSION;
- }
+ protected String getNoCompress() {
+ return noCompress ? FLAG_NO_COMPRESSION : "";
}
-
/**
* Get the NoCache flag
*
* @return String the 'nocache' Flag if the attribute was 'true', otherwise an empty string
*/
- public String getNoCache() {
- if (!noCache) {
- return "";
- } else {
- return SOSCmd.FLAG_NO_CACHE;
- }
+ protected String getNoCache() {
+ return noCache ? FLAG_NO_CACHE : "";
}
-
/**
* Get the 'verbose' Flag
*
* @return String the 'verbose' Flag if the attribute was 'true', otherwise an empty string
*/
- public String getVerbose() {
- if (!verbose) {
- return "";
- } else {
- return SOSCmd.FLAG_VERBOSE;
+ protected String getVerbose() {
+ return verbose ? FLAG_VERBOSE : "";
}
- }
-
/**
* Get the 'recursive' Flag
*
* @return String the 'recursive' Flag if the attribute was 'true', otherwise an empty string
*/
- public String getRecursive() {
- if (!recursive) {
- return "";
- } else {
- return SOSCmd.FLAG_RECURSION;
- }
+ protected String getRecursive() {
+ return recursive ? FLAG_RECURSION : "";
}
-
/**
* Builds and returns the working directory.
* <p>
@@ -457,7 +358,7 @@
*
* @return String the absolute path of the working directory
*/
- public String getLocalPath() {
+ protected String getLocalPath() {
if (localPath == null) {
return getProject().getBaseDir().getAbsolutePath();
} else {
@@ -476,12 +377,35 @@
}
}
+ /**
+ * Subclasses implement the logic required to construct the command line.
+ *
+ * @return The command line to execute.
+ */
+ abstract Commandline buildCmdLine();
+
/**
- * Execute the created command line
+ * Execute the created command line.
*
- * @param cmd Description of Parameter
- * @return int the exit code
+ * @throws BuildException
+ */
+ public void execute()
+ throws BuildException {
+ int result = 0;
+ buildCmdLine();
+ result = run(commandLine);
+ if (result == 255) { // This is the exit status
+ String msg = "Failed executing: " + commandLine.toString();
+ throw new BuildException(msg, getLocation());
+ }
+ }
+
+ /**
+ * Execute the created command line.
+ *
+ * @param cmd The command line to run.
+ * @return int the exit code.
* @throws BuildException
*/
protected int run(Commandline cmd) {
@@ -493,10 +417,65 @@
exe.setAntRun(getProject());
exe.setWorkingDirectory(getProject().getBaseDir());
exe.setCommandline(cmd.getCommandline());
+ exe.setVMLauncher(false); // Use the OS VM launcher so we get environment variables
return exe.execute();
} catch (java.io.IOException e) {
throw new BuildException(e, getLocation());
}
}
-}
+ /** Sets the executable and add the required attributes to the command line. */
+ protected void getRequiredAttributes() {
+ // Get the path to the soscmd(.exe)
+ commandLine.setExecutable(getSosCommand());
+ // SOS server address is required
+ if (getSosServerPath() == null) {
+ throw new BuildException("sosserverpath attribute must be set!", getLocation());
+ }
+ commandLine.createArgument().setValue(FLAG_SOS_SERVER);
+ commandLine.createArgument().setValue(getSosServerPath());
+ // Login info is required
+ if (getUsername() == null) {
+ throw new BuildException("username attribute must be set!", getLocation());
+ }
+ commandLine.createArgument().setValue(FLAG_USERNAME);
+ commandLine.createArgument().setValue(getUsername());
+ // The SOS class knows that the SOS server needs the password flag,
+ // even if there is no password ,so we send a " "
+ commandLine.createArgument().setValue(FLAG_PASSWORD);
+ commandLine.createArgument().setValue(getPassword());
+ // VSS Info is required
+ if (getVssServerPath() == null) {
+ throw new BuildException("vssserverpath attribute must be set!", getLocation());
+ }
+ commandLine.createArgument().setValue(FLAG_VSS_SERVER);
+ commandLine.createArgument().setValue(getVssServerPath());
+ // VSS project is required
+ if (getProjectPath() == null) {
+ throw new BuildException("projectpath attribute must be set!", getLocation());
+ }
+ commandLine.createArgument().setValue(FLAG_PROJECT);
+ commandLine.createArgument().setValue(getProjectPath());
+ }
+
+ /** Adds the optional attributes to the command line. */
+ protected void getOptionalAttributes() {
+ // -verbose
+ commandLine.createArgument().setValue(getVerbose());
+ // Disable Compression
+ commandLine.createArgument().setValue(getNoCompress());
+ // Path to the SourceOffSite home directory /home/user/.sos
+ if (getSosHome() == null) {
+ // If -soshome was not specified then we can look for nocache
+ commandLine.createArgument().setValue(getNoCache());
+ } else {
+ commandLine.createArgument().setValue(FLAG_SOS_HOME);
+ commandLine.createArgument().setValue(getSosHome());
+ }
+ //If a working directory was specified then add it to the command line
+ if (getLocalPath() != null) {
+ commandLine.createArgument().setValue(FLAG_WORKING_DIR);
+ commandLine.createArgument().setValue(getLocalPath());
+ }
+ }
+}
1.7 +38 -75 jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCheckin.java
Index: SOSCheckin.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCheckin.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -w -u -r1.6 -r1.7
--- SOSCheckin.java 23 Jul 2002 08:39:58 -0000 1.6
+++ SOSCheckin.java 10 Feb 2003 11:22:46 -0000 1.7
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2002-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -85,7 +85,7 @@
* </tr>
* <tr>
* <td>projectpath</td>
- * <td>SourceSafe project path without the "$"</td>
+ * <td>SourceSafe project path</td>
* <td>Yes</td>
* </tr>
* <tr>
@@ -139,50 +139,58 @@
* </tr>
* </table>
*
- * @author <a href="mailto:jesse@cryptocard.com">Jesse Stockall</a>
+ * @author Jesse Stockall
*/
public class SOSCheckin extends SOS {
- Commandline commandLine;
-
/**
- * Executes the task.
- * <br>
- * Builds a command line to execute soscmd and then calls Exec's run method
- * to execute the command line.
- *
- * @exception BuildException Description of Exception
- */
- public void execute() throws BuildException {
- int result = 0;
- buildCmdLine();
- result = run(commandLine);
- if (result == 255) {
- // This is the exit status
- String msg = "Failed executing: " + commandLine.toString();
- throw new BuildException(msg, getLocation());
+ * Set the Filename to act upon; optional.
+ * If no file is specified then the tasks
+ * act upon the project
+ *
+ * @param filename The new file value
+ */
+ public final void setFile(String filename) {
+ super.setInternalFilename(filename);
}
+
+ /**
+ * Flag to recursively apply the action; optional, default false
+ *
+ * @param recursive True for recursive operation.
+ */
+ public void setRecursive(boolean recursive) {
+ super.setInternalRecursive(recursive);
}
+ /**
+ * Set the comment to apply to all files being labelled;
+ * optional
+ *
+ * @param comment The new comment value
+ */
+ public void setComment(String comment) {
+ super.setInternalComment(comment);
+ }
/**
- * Build the command line <br>
+ * Build the command line <p>
*
- * CheckInFile required parameters: -server -name -password -database -project -file<br>
- * CheckInFile optional parameters: -workdir -log -verbose -nocache
- * -nocompression -soshome<br>
- *
- * CheckInProject required parameters: -server -name -password -database -project<br>
- * CheckInProject optional parameters: workdir -recursive -log -verbose -nocache
- * -nocompression -soshome<br>
+ * CheckInFile required parameters: -server -name -password -database -project
+ * -file<br>
+ * CheckInFile optional parameters: -workdir -log -verbose -nocache -nocompression
+ * -soshome<br>
+ * CheckInProject required parameters: -server -name -password -database
+ * -project<br>
+ * CheckInProject optional parameters: workdir -recursive -log -verbose
+ * -nocache -nocompression -soshome<br>
*
* @return Commandline the generated command to be executed
*/
protected Commandline buildCmdLine() {
commandLine = new Commandline();
- // Get the path to the soscmd(.exe)
- commandLine.setExecutable(getSosCommand());
+
// If we find a "file" attribute then act on a file otherwise act on a project
if (getFilename() != null) {
// add -command CheckInFile to the commandline
@@ -198,54 +206,10 @@
// look for a recursive option
commandLine.createArgument().setValue(getRecursive());
}
- // SOS server address is required
- if (getSosServerPath() == null) {
- throw new BuildException("sosserverpath attribute must be set!", getLocation());
- }
- commandLine.createArgument().setValue(SOSCmd.FLAG_SOS_SERVER);
- commandLine.createArgument().setValue(getSosServerPath());
- // Login info is required
- if (getUsername() == null) {
- throw new BuildException("username attribute must be set!", getLocation());
- }
- commandLine.createArgument().setValue(SOSCmd.FLAG_USERNAME);
- commandLine.createArgument().setValue(getUsername());
- // The SOS class knows that the SOS server needs the password flag,
- // even if there is no password ,so we send a " "
- commandLine.createArgument().setValue(SOSCmd.FLAG_PASSWORD);
- commandLine.createArgument().setValue(getPassword());
- // VSS Info is required
- if (getVssServerPath() == null) {
- throw new BuildException("vssserverpath attribute must be set!", getLocation());
- }
- commandLine.createArgument().setValue(SOSCmd.FLAG_VSS_SERVER);
- commandLine.createArgument().setValue(getVssServerPath());
- // VSS project is required
- if (getProjectPath() == null) {
- throw new BuildException("projectpath attribute must be set!", getLocation());
- }
- commandLine.createArgument().setValue(SOSCmd.FLAG_PROJECT);
- commandLine.createArgument().setValue(getProjectPath());
-
- // The following options are optional.
-
- // -verbose
- commandLine.createArgument().setValue(getVerbose());
- // Disable Compression
- commandLine.createArgument().setValue(getNoCompress());
- // Path to the SourceOffSite home directory /home/user/.sos
- if (getSosHome() == null) {
- // If -soshome was not specified then we can look for nocache
- commandLine.createArgument().setValue(getNoCache());
- } else {
- commandLine.createArgument().setValue(SOSCmd.FLAG_SOS_HOME);
- commandLine.createArgument().setValue(getSosHome());
- }
- // If a working directory was specified then add it to the command line
- if (getLocalPath() != null) {
- commandLine.createArgument().setValue(SOSCmd.FLAG_WORKING_DIR);
- commandLine.createArgument().setValue(getLocalPath());
- }
+
+ getRequiredAttributes();
+ getOptionalAttributes();
+
// Look for a comment
if (getComment() != null) {
commandLine.createArgument().setValue(SOSCmd.FLAG_COMMENT);
@@ -254,4 +218,3 @@
return commandLine;
}
}
-
1.7 +20 -68 jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCheckout.java
Index: SOSCheckout.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCheckout.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -w -u -r1.6 -r1.7
--- SOSCheckout.java 23 Jul 2002 08:39:58 -0000 1.6
+++ SOSCheckout.java 10 Feb 2003 11:22:46 -0000 1.7
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2002-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -85,7 +85,7 @@
* </tr>
* <tr>
* <td>projectpath</td>
- * <td>SourceSafe project path without the "$"</td>
+ * <td>SourceSafe project path</td>
* <td>Yes</td>
* </tr>
* <tr>
@@ -135,32 +135,30 @@
* </tr>
* </table>
*
- * @author <a href="mailto:jesse@cryptocard.com">Jesse Stockall</a>
+ * @author Jesse Stockall
*/
public class SOSCheckout extends SOS {
- Commandline commandLine;
-
/**
- * Executes the task.
- * <br>
- * Builds a command line to execute soscmd and then calls Exec's run method
- * to execute the command line.
+ * Set the Filename to act upon; optional.
+ * If no file is specified then the tasks
+ * act upon the project
*
- * @exception BuildException Description of Exception
+ * @param filename The new file value
*/
- public void execute() throws BuildException {
- int result = 0;
- buildCmdLine();
- result = run(commandLine);
- if (result == 255) {
- // This is the exit status
- String msg = "Failed executing: " + commandLine.toString();
- throw new BuildException(msg, getLocation());
- }
+ public final void setFile(String filename) {
+ super.setInternalFilename(filename);
}
+ /**
+ * Flag to recursively apply the action; optional, default false
+ *
+ * @param recursive True for recursive operation.
+ */
+ public void setRecursive(boolean recursive) {
+ super.setInternalRecursive(recursive);
+ }
/**
* Build the command line <br>
@@ -176,8 +174,7 @@
*/
protected Commandline buildCmdLine() {
commandLine = new Commandline();
- // Get the path to the soscmd(.exe)
- commandLine.setExecutable(getSosCommand());
+
// If we find a "file" attribute then act on a file otherwise act on a project
if (getFilename() != null) {
// add -command CheckOutFile to the commandline
@@ -193,55 +190,10 @@
// look for a recursive option
commandLine.createArgument().setValue(getRecursive());
}
- // SOS server address is required
- if (getSosServerPath() == null) {
- throw new BuildException("sosserverpath attribute must be set!", getLocation());
- }
- commandLine.createArgument().setValue(SOSCmd.FLAG_SOS_SERVER);
- commandLine.createArgument().setValue(getSosServerPath());
- // Login info is required
- if (getUsername() == null) {
- throw new BuildException("username attribute must be set!", getLocation());
- }
- commandLine.createArgument().setValue(SOSCmd.FLAG_USERNAME);
- commandLine.createArgument().setValue(getUsername());
- // The SOS class knows that the SOS server needs the password flag,
- // even if there is no password ,so we send a " "
- commandLine.createArgument().setValue(SOSCmd.FLAG_PASSWORD);
- commandLine.createArgument().setValue(getPassword());
- // VSS Info is required
- if (getVssServerPath() == null) {
- throw new BuildException("vssserverpath attribute must be set!", getLocation());
- }
- commandLine.createArgument().setValue(SOSCmd.FLAG_VSS_SERVER);
- commandLine.createArgument().setValue(getVssServerPath());
- // VSS project is required
- if (getProjectPath() == null) {
- throw new BuildException("projectpath attribute must be set!", getLocation());
- }
- commandLine.createArgument().setValue(SOSCmd.FLAG_PROJECT);
- commandLine.createArgument().setValue(getProjectPath());
- // The following options are optional.
+ getRequiredAttributes();
+ getOptionalAttributes();
- // -verbose
- commandLine.createArgument().setValue(getVerbose());
- // Disable Compression
- commandLine.createArgument().setValue(getNoCompress());
- // Path to the SourceOffSite home directory /home/user/.sos
- if (getSosHome() == null) {
- // If -soshome was not specified then we can look for nocache
- commandLine.createArgument().setValue(getNoCache());
- } else {
- commandLine.createArgument().setValue(SOSCmd.FLAG_SOS_HOME);
- commandLine.createArgument().setValue(getSosHome());
- }
- // If a working directory was specified then add it to the command line
- if (getLocalPath() != null) {
- commandLine.createArgument().setValue(SOSCmd.FLAG_WORKING_DIR);
- commandLine.createArgument().setValue(getLocalPath());
- }
return commandLine;
}
}
-
1.5 +2 -3 jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCmd.java
Index: SOSCmd.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCmd.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -w -u -r1.4 -r1.5
--- SOSCmd.java 12 Apr 2002 13:26:53 -0000 1.4
+++ SOSCmd.java 10 Feb 2003 11:22:46 -0000 1.5
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2002-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -56,7 +56,7 @@
/**
* Interface to hold constants used by the SOS tasks
*
- * @author <a href="mailto:jesse@cryptocard.com">Jesse Stockall</a>
+ * @author Jesse Stockall
*/
public interface SOSCmd {
// soscmd Command options
@@ -88,4 +88,3 @@
String FLAG_FILE = "-file";
String FLAG_VERBOSE = "-verbose";
}
-
1.7 +38 -67 jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSGet.java
Index: SOSGet.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSGet.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -w -u -r1.6 -r1.7
--- SOSGet.java 23 Jul 2002 08:39:58 -0000 1.6
+++ SOSGet.java 10 Feb 2003 11:22:46 -0000 1.7
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2002-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -86,7 +86,7 @@
* </tr>
* <tr>
* <td>projectpath</td>
- * <td>SourceSafe project path without the "$"</td>
+ * <td>SourceSafe project path</td>
* <td>Yes</td>
* </tr>
* <tr>
@@ -146,32 +146,49 @@
* <td>No</td>
* </tr>
*
- * @author <a href="mailto:jesse@cryptocard.com">Jesse Stockall</a>
+ * @author Jesse Stockall
*/
public class SOSGet extends SOS {
- Commandline commandLine;
+ /**
+ * Set the Filename to act upon; optional.
+ * If no file is specified then the tasks
+ * act upon the project
+ *
+ * @param filename The new file value
+ */
+ public final void setFile(String filename) {
+ super.setInternalFilename(filename);
+ }
/**
- * Executes the task.
- * <br>
- * Builds a command line to execute soscmd and then calls Exec's run method
- * to execute the command line.
+ * Flag to recursively apply the action; optional, default false
*
- * @exception BuildException Description of Exception
+ * @param recursive True for recursive operation.
*/
- public void execute() throws BuildException {
- int result = 0;
- buildCmdLine();
- result = run(commandLine);
- if (result == 255) {
- // This is the exit status
- String msg = "Failed executing: " + commandLine.toString();
- throw new BuildException(msg, getLocation());
+ public void setRecursive(boolean recursive) {
+ super.setInternalRecursive(recursive);
}
+
+ /**
+ * Set the version number to get -
+ * only works with SOSGet on a file; optional.
+ *
+ * @param version The new version value
+ */
+ public void setVersion(String version) {
+ super.setInternalVersion(version);
}
+ /**
+ * Set the labeled version to operate on in SourceSafe
+ *
+ * @param label The new label value
+ */
+ public void setLabel(String label) {
+ super.setInternalLabel(label);
+ }
/**
* Build the command line <br>
@@ -187,8 +204,7 @@
*/
protected Commandline buildCmdLine() {
commandLine = new Commandline();
- // Get the path to the soscmd(.exe)
- commandLine.setExecutable(getSosCommand());
+
// If we find a "file" attribute then act on a file otherwise act on a project
if (getFilename() != null) {
// add -command GetFile to the commandline
@@ -215,55 +231,10 @@
commandLine.createArgument().setValue(getLabel());
}
}
- // SOS server address is required
- if (getSosServerPath() == null) {
- throw new BuildException("sosserverpath attribute must be set!", getLocation());
- }
- commandLine.createArgument().setValue(SOSCmd.FLAG_SOS_SERVER);
- commandLine.createArgument().setValue(getSosServerPath());
- // Login info is required
- if (getUsername() == null) {
- throw new BuildException("username attribute must be set!", getLocation());
- }
- commandLine.createArgument().setValue(SOSCmd.FLAG_USERNAME);
- commandLine.createArgument().setValue(getUsername());
- // The SOS class knows that the SOS server needs the password flag,
- // even if there is no password ,so we send a " "
- commandLine.createArgument().setValue(SOSCmd.FLAG_PASSWORD);
- commandLine.createArgument().setValue(getPassword());
- // VSS Info is required
- if (getVssServerPath() == null) {
- throw new BuildException("vssserverpath attribute must be set!", getLocation());
- }
- commandLine.createArgument().setValue(SOSCmd.FLAG_VSS_SERVER);
- commandLine.createArgument().setValue(getVssServerPath());
- // SS project path is required
- if (getProjectPath() == null) {
- throw new BuildException("projectpath attribute must be set!", getLocation());
- }
- commandLine.createArgument().setValue(SOSCmd.FLAG_PROJECT);
- commandLine.createArgument().setValue(getProjectPath());
- // The following options are optional.
+ getRequiredAttributes();
+ getOptionalAttributes();
- // -verbose
- commandLine.createArgument().setValue(getVerbose());
- // Disable Compression
- commandLine.createArgument().setValue(getNoCompress());
- // Path to the SourceOffSite home directory /home/user/.sos
- if (getSosHome() == null) {
- // If -soshome was not specified then we can look for nocache
- commandLine.createArgument().setValue(getNoCache());
- } else {
- commandLine.createArgument().setValue(SOSCmd.FLAG_SOS_HOME);
- commandLine.createArgument().setValue(getSosHome());
- }
- //If a working directory was specified then add it to the command line
- if (getLocalPath() != null) {
- commandLine.createArgument().setValue(SOSCmd.FLAG_WORKING_DIR);
- commandLine.createArgument().setValue(getLocalPath());
- }
return commandLine;
}
}
-
1.7 +28 -50 jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSLabel.java
Index: SOSLabel.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSLabel.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -w -u -r1.6 -r1.7
--- SOSLabel.java 23 Jul 2002 08:39:58 -0000 1.6
+++ SOSLabel.java 10 Feb 2003 11:22:46 -0000 1.7
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2002-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -84,7 +84,7 @@
* </tr>
* <tr>
* <td>projectpath</td>
- * <td>SourceSafe project path without the "$"</td>
+ * <td>SourceSafe project</td>
* <td>Yes</td>
* </tr>
* <tr>
@@ -114,31 +114,38 @@
* </tr>
* </table>
*
- * @author <a href="mailto:jesse@cryptocard.com">Jesse Stockall</a>
+ * @author Jesse Stockall
*/
public class SOSLabel extends SOS {
- Commandline commandLine;
-
/**
- * Executes the task. <br>
- * Builds a command line to execute soscmd and then calls Exec's run method
- * to execute the command line.
- *
- * @exception BuildException Description of Exception
- */
- public void execute() throws BuildException {
- int result = 0;
- buildCmdLine();
- result = run(commandLine);
- if (result == 255) {
- // This is the exit status
- String msg = "Failed executing: " + commandLine.toString();
- throw new BuildException(msg, getLocation());
+ * Set the version number to label; optional.
+ *
+ * @param version The new version value
+ */
+ public void setVersion(String version) {
+ super.setInternalVersion(version);
}
+
+ /**
+ * Set the label to apply the the files in SourceSafe.
+ *
+ * @param label The new label value
+ */
+ public void setLabel(String label) {
+ super.setInternalLabel(label);
}
+ /**
+ * Set the comment to apply to all files being labelled;
+ * optional
+ *
+ * @param comment The new comment value
+ */
+ public void setComment(String comment) {
+ super.setInternalComment(comment);
+ }
/**
* Build the command line <br>
@@ -149,39 +156,13 @@
*/
protected Commandline buildCmdLine() {
commandLine = new Commandline();
- // Get the path to the soscmd(.exe)
- commandLine.setExecutable(getSosCommand());
+
// add -command AddLabel to the commandline
commandLine.createArgument().setValue(SOSCmd.FLAG_COMMAND);
commandLine.createArgument().setValue(SOSCmd.COMMAND_LABEL);
- // SOS server address is required
- if (getSosServerPath() == null) {
- throw new BuildException("sosserverpath attribute must be set!", getLocation());
- }
- commandLine.createArgument().setValue(SOSCmd.FLAG_SOS_SERVER);
- commandLine.createArgument().setValue(getSosServerPath());
- // Login info is required
- if (getUsername() == null) {
- throw new BuildException("username attribute must be set!", getLocation());
- }
- commandLine.createArgument().setValue(SOSCmd.FLAG_USERNAME);
- commandLine.createArgument().setValue(getUsername());
- // The SOS class knows that the SOS server needs the password flag,
- // even if there is no password ,so we send a " "
- commandLine.createArgument().setValue(SOSCmd.FLAG_PASSWORD);
- commandLine.createArgument().setValue(getPassword());
- // VSS Info is required
- if (getVssServerPath() == null) {
- throw new BuildException("vssserverpath attribute must be set!", getLocation());
- }
- commandLine.createArgument().setValue(SOSCmd.FLAG_VSS_SERVER);
- commandLine.createArgument().setValue(getVssServerPath());
- // SS project path is required
- if (getProjectPath() == null) {
- throw new BuildException("projectpath attribute must be set!", getLocation());
- }
- commandLine.createArgument().setValue(SOSCmd.FLAG_PROJECT);
- commandLine.createArgument().setValue(getProjectPath());
+
+ getRequiredAttributes();
+
// a label is required
if (getLabel() == null) {
throw new BuildException("label attribute must be set!", getLocation());
@@ -189,8 +170,6 @@
commandLine.createArgument().setValue(SOSCmd.FLAG_LABEL);
commandLine.createArgument().setValue(getLabel());
- // The following options are optional.
-
// -verbose
commandLine.createArgument().setValue(getVerbose());
// Look for a comment
@@ -201,4 +180,3 @@
return commandLine;
}
}
-
1.5 +2 -4 jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java
Index: SOSTest.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -w -u -r1.4 -r1.5
--- SOSTest.java 26 Sep 2002 13:28:41 -0000 1.4
+++ SOSTest.java 10 Feb 2003 11:22:46 -0000 1.5
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2002-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -55,18 +55,16 @@
import java.io.File;
-import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.BuildFileTest;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.Path;
-import org.apache.tools.ant.util.FileUtils;
/**
* Testcase to ensure that command line generation and required attributes are
* correct.
*
- * @author <a href="mailto:jesse@cryptocard.com">Jesse Stockall</a>
+ * @author Jesse Stockall
*/
public class SOSTest extends BuildFileTest {