diff --git a/docs/manual/OptionalTasks/sos.html b/docs/manual/OptionalTasks/sos.html new file mode 100644 index 000000000..9c252958a --- /dev/null +++ b/docs/manual/OptionalTasks/sos.html @@ -0,0 +1,531 @@ + + + + + + Ant User Manual + + + + +
+

SourceOffSite Tasks User Manual

+ +
by
+
+ + + Version 1.1 2002/01/23
+
+ +
+

Contents

+ + +
+ +

Introduction

+ +

These tasks provide an interface to the + Microsoft Visual SourceSafe SCM via + SourceGear's SourceOffSite + product. SourceOffSite is an add-on to Microsoft's VSS, that +allows remote development teams and tele-commuters that need +fast and secure read/write access to a centralized SourceSafe + database via any TCP/IP connection . SOS also provides Linux & Solaris +clients. The org.apache.tools.ant.taskdefs.optional.sos + package consists of a simple framework to support SOS functionality as well +as some Ant tasks encapsulating frequently used SOS commands. Although it +is possible to use these commands on the desktop, they were primarily intended +to be used by automated build systems. These tasks have been tested with +SourceOffSite version 3.5.1 connecting to VisualSourceSafe 6.0. The tasks +have been tested with Linux, Solaris & Windows2000

+ +

The Tasks

+ + + + + + + + + + + + + + + + + + + + + +
sosget Retrieves a read-only copy of the specified project or file.
soslabel Assigns a label to the specified project.
soscheckin Updates VSS with changes made to a checked out file or project, + and unlocks the VSS master copy.
soscheckout Retrieves a read-write copy of the specified project +or file, locking the VSS master copy
+
+ +
+

Task Descriptions

+ +

SOSGet
+

+

Description

+ Task to perform GET commands from Microsoft Visual SourceSafe via SOS
+

Parameters

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeValuesRequired
soscmddirDirectory which contains soscmd(.exe)
+ soscmd(.exe) must be in the path if this is not specified
No
vssserverpathpath to the srcsafe.ini - eg. \\server\vss\srcsafe.iniYes
sosserverpathaddress & port of the SOS server - eg. 192.168.0.1:8888Yes
projectpathSourceSafe project path without the "$"Yes
fileFilename to act upon
+ If no file is specified then act upon the project
No
usernameSourceSafe usernameYes
passwordSourceSafe passwordNo
localpathOverride the working directory and get to the specified pathNo
soshomeThe path to the SourceOffSite home directoryNo
nocompressiontrue or false - disable compressionNo
recursivetrue or false - Only works with the GetProject commandNo
versiona version number to get - Only works with the GetFile commandNo
labela label version to get - Only works with the GetProject commandNo
nocachetrue or false - Only needed if SOSHOME is set as an enviroment variableNo
verbosetrue or false - Status messages are displayedNo
+ +

Example

+     <sosget    + verbose="true"
+                 +     recursive="true"
+                 +     login="build"
+                 +     pass="build"
+                 +     localpath="tmp"
+                 +     projectpath="/SourceRoot/project1"
+
            +             sosserverpath="192.168.10.6:8888"
+                 +     vssserverpath="d:\vss\srcsafe.ini"/>
+   
+ Connects to a SourceOffsite server on
192.168.10.6:8888 + with build,build as the username & password . The + SourceSafe database resides on the same box as the SOS server & the + VSS database is at "d:\vss\srcsafe.ini"
+ Does a recursive GetProject on $/SourceRoot/project1 + , using tmp as the working directory.
+
+ +
+

SOSLabel

+ +

Description

+ Task to perform Label commands from Microsoft Visual SourceSafe via SOS
+

Parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeValuesRequired
soscmddirDirectory which contains soscmd(.exe)
+ soscmd(.exe) must be in the path if this is not specified
No
vssserverpathpath to the srcsafe.ini - eg. \\server\vss\srcsafe.iniYes
sosserverpathaddress and port of the SOS server - eg. 192.168.0.1:8888Yes
projectpathSourceSafe project path without the "$"Yes
usernameSourceSafe usernameYes
passwordSourceSafe passwordNo
labelThe label to apply to a projectYes
commentA comment to be applied to all files being labeledNo
verbosetrue or false - Status messages are displayedNo
+ +

Example

+     <soslabel    +   login="build"
+
              +           pass="build"
+
            +             label="test +label"
+
            +             projectpath=" + /SourceRoot/project1 "
+
            +             sosserverpath="192.168.10.6:8888"
+
                +         vssserverpath="d:\vss\srcsafe.ini"/>
+

+ Connects to a SourceOffsite server on 192.168.10.6:8888 + with build,build as the username & password + . The SourceSafe database resides on the same box +as the SOS server & the VSS database is at "d:\vss\srcsafe.ini"
+ Labels the $/SourceRoot/project1 project with + "test label".
+
+ +

+ +

SOSCheckIn

+ +

Description

+ Task to perform CheckIn commands from a Microsoft Visual Source Safe via SOS
+

Parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeValuesRequired
soscmddirDirectory which contains soscmd(.exe)
+ soscmd(.exe) must be in the path if this is not specified
No
vssserverpathpath to the srcsafe.ini - eg. \\server\vss\srcsafe.iniYes
sosserverpathaddress and port of the SOS server - eg. 192.168.0.1:8888Yes
projectpathSourceSafe project path without the "$"Yes
fileFilename to act upon
If no file is specified then act upon the project
No
usernameSourceSafe usernameYes
passwordSourceSafe passwordNo
localpathOverride the working directory and get to the specified pathNo
soshomeThe path to the SourceOffSite home directoryNo
nocompressiontrue or false - disable compressionNo
recursivetrue or false - Only works with the CheckOutProject commandNo
nocachetrue or false - Only needed if SOSHOME is set as an enviroment variableNo
verbosetrue or false - Status messages are displayedNo
commentA comment to be applied to all files being checked inNo
+ +

Example

+     <soscheckin        +  login="build"
+
            +                 +     pass="build"
+
            +                 +     file="foobar.txt"
+                  +                verbose="true"

+                 +                 + comment="comment abc"
+
            +                 +     projectpath="/SourceRoot/project1"
+
            +                 +     sosserverpath="server1:8888"
+
            +                 +     vssserverpath="\\server2\vss\srcsafe.ini"/>
+

+ Connects to a SourceOffsite server on
server1:8888 + with build,build as the username & password . + The SourceSafe database resides on a different box (server2)  + & the VSS database is on a share called "vss"
+ Checks-in only the "foobar.txt" file adding a comment of "comment + abc" . Extra status messages will be displayed on screen.
+
+ +
+

SOSCheckOut

+ +

Description

+ Task to perform CheckOut commands from a Microsoft Visual Source Safe via SOS
+ +

Parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeValuesRequired
soscmddirDirectory which contains soscmd(.exe)
+ soscmd(.exe) must be in the path if this is not specified
No
vssserverpathpath to the srcsafe.ini - eg. \\server\vss\srcsafe.iniYes
sosserverpathaddress and port of the SOS server - eg. 192.168.0.1:8888Yes
projectpathSourceSafe project path without the "$"Yes
fileFilename to act upon
If no file is specified then act upon the project
No
usernameSourceSafe usernameYes
passwordSourceSafe passwordNo
localpathOverride the working directory and get to the specified pathNo
soshomeThe path to the SourceOffSite home directoryNo
nocompressiontrue or false - disable compressionNo
recursivetrue or false - Only works with the CheckOutProject commandNo
nocachetrue or false - Only needed if SOSHOME is set as an enviroment variableNo
verbosetrue or false - Status messages are displayedNo
+
+ +

Example

+     <soscheckout   soscmddir="/usr/bin"
+
            +                 + verbose="true"
+
            +                 + login="build"
+
            +                 + pass="build"
+
            +                 + ProjectPath=" /SourceRoot/project1"
+
            +                 + sosserverpath="192.168.10.6:8888"
+
            +                 + vssserverpath="\\server2\vss\srcsafe.ini"/>
+

+ Connects to a SourceOffsite server on server1:8888 + with build,build as the username & password . + The SourceSafe database resides on a different box (server2)  + & the VSS database is on a share called "vss"
+ Checks-out "project1" Only the "project1" directory + will be locked as the recursive option was not set. Extra status messages + will be displayed on screen. The soscmd(.exe) file to be + used resides in /usr/bin
+
+
+

+

+
+
+
+
+ + + diff --git a/docs/manual/optionaltasklist.html b/docs/manual/optionaltasklist.html index 7d002cc2a..eaabaa3d3 100644 --- a/docs/manual/optionaltasklist.html +++ b/docs/manual/optionaltasklist.html @@ -43,6 +43,7 @@ Rpm
Script
Sound
+SourceOffSite
Starteam Tasks
Stylebook
Telnet
diff --git a/src/main/org/apache/tools/ant/taskdefs/defaults.properties b/src/main/org/apache/tools/ant/taskdefs/defaults.properties index eb16bc559..9fb93441e 100644 --- a/src/main/org/apache/tools/ant/taskdefs/defaults.properties +++ b/src/main/org/apache/tools/ant/taskdefs/defaults.properties @@ -135,6 +135,10 @@ p4add=org.apache.tools.ant.taskdefs.optional.perforce.P4Add jspc=org.apache.tools.ant.taskdefs.optional.jsp.JspC replaceregexp=org.apache.tools.ant.taskdefs.optional.ReplaceRegExp translate=org.apache.tools.ant.taskdefs.optional.i18n.Translate +sosget=org.apache.tools.ant.taskdefs.optional.sos.SOSGet +soscheckin=org.apache.tools.ant.taskdefs.optional.sos.SOSCheckin +soscheckout=org.apache.tools.ant.taskdefs.optional.sos.SOSCheckout +soslabel=org.apache.tools.ant.taskdefs.optional.sos.SOSLabel # deprecated ant tasks (kept for back compatibility) starteam=org.apache.tools.ant.taskdefs.optional.scm.AntStarTeamCheckOut diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOS.java b/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOS.java new file mode 100644 index 000000000..e7d9b3b00 --- /dev/null +++ b/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOS.java @@ -0,0 +1,488 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2000 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 "The Jakarta Project", "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 + * . + */ +package org.apache.tools.ant.taskdefs.optional.sos; + +import java.io.File; +import org.apache.tools.ant.*; +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.Path; + +/** + * A base class for creating tasks for executing commands on SourceOffSite + *

+ * 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. + *

+ *

+ * This class provides set and get methods for the following attributes + *
'vssserverpath' + *
'sosserverpath' + *
'vsspath' + *
'projectpath' + *
'username' + *
'password' + *
'soscmddir' + *
'file' + *
'soshome' + *
'localpath" + *
'comment' + *
'label' + *
'version' + *
'recursive' + *
'verbose' + *
'nocache' + *
'nocompression' + *
+ * It also contains constants for the flags that can be passed to SOS. + *

+ * These tasks were inspired by the VSS tasks + * + * @author Jesse Stockall + */ + +public abstract class SOS extends Task { + + private String sosCmdDir = null; + private String sosUsername = null; + private String sosPassword = ""; + private String projectPath = null; + private String vssServerPath = null; + private String sosServerPath = null; + private String sosHome = null; + private String localPath = null; + private String version = null; + private String label = null; + private String comment = null; + private String filename = null; + + private boolean noCompress = false; + private boolean noCache = false; + private boolean recursive = false; + private boolean verbose = false; + + + /** + * Disable the cache + * + * @param nocache The new noCache value + */ + public void setNoCache(boolean nocache) { + noCache = nocache; + } + + + /** + * Disable compression + * + * @param nocompress The new noCompress value + */ + public void setNoCompress(boolean nocompress) { + noCompress = nocompress; + } + + + /** + * Set the directory where soscmd(.exe) is located + * + * @param dir The new sosCmd value + */ + public final void setSosCmd(String dir) { + sosCmdDir = project.translatePath(dir); + } + + + /** + * Set the username to use to access SOS. + * + * @param username The new username value + */ + public final void setUsername(String username) { + sosUsername = username; + } + + + /** + * Set the password to use to access SOS. + * + * @param password The new password value + */ + public final void setPassword(String password) { + sosPassword = password; + } + + + /** + * Set the path to the item in SOS to operate on + *

+ * To avoid the "$$" in th build file we add it here + * + * @param projectpath The new projectPath value + */ + public final void setProjectPath(String projectpath) { + projectPath = SOSCmd.PROJECT_PREFIX + projectpath; + } + + + /** + * Set the path to the location of the ss.ini + * + * @param vssServerPath The new vssServerPath value + */ + public final void setVssServerPath(String vssServerPath) { + this.vssServerPath = vssServerPath; + } + + + /** + * Set the path of soshome + * + * @param sosHome The new sosHome value + */ + public final void setSosHome(String sosHome) { + this.sosHome = sosHome; + } + + + /** + * Set the address & port of SourceOffSite Server + * + * @param sosServerPath The new sosServerPath value + */ + public final void setSosServerPath(String sosServerPath) { + this.sosServerPath = sosServerPath; + } + + + /** + * Set the local path. + * + * @param path The new localPath value + */ + public void setLocalPath(Path path) { + localPath = path.toString(); + } + + + /** + * Set the filename to get from SOS + * + * @param filename The new file value + */ + public final void setFile(String filename) { + this.filename = filename; + } + + + /** + * Set behaviour verbose or quiet + * + * @param verbose The new verbose value + */ + public void setVerbose(boolean verbose) { + this.verbose = verbose; + } + + + /** + * Set behaviour recursive or non-recursive + * + * @param recursive The new recursive value + */ + public void setRecursive(boolean recursive) { + this.recursive = recursive; + } + + + /** + * Set the stored version string + * + * @param version The new version value + */ + public void setVersion(String version) { + this.version = version; + } + + + /** + * Set the labeled version to operate on in SourceSafe + * + * @param label The new label value + */ + public void setLabel(String label) { + this.label = label; + } + + + /** + * Set the comment to get + * + * @param comment The new comment value + */ + public void setComment(String comment) { + this.comment = comment; + } + + + /** + * 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() { + if (sosCmdDir == null) { + return SOSCmd.COMMAND_SOS_EXE; + } else { + return sosCmdDir + File.separator + SOSCmd.COMMAND_SOS_EXE; + } + } + + /** + * Get the comment + * @return String if it was set, null if not + */ + public String getComment() { + return comment; + } + + + /** + * Get the version + * @return String if it was set, null if not + */ + public String getVersion() { + return version; + } + + + /** + * Get the label + * @return String if it was set, null if not + */ + public String getLabel() { + return label; + } + + + /** + * Get the username + * @return String if it was set, null if not + */ + public String getUsername() { + return sosUsername; + } + + + /** + * Get the password + * @return String empty string if it wans't set + */ + public String getPassword() { + return sosPassword; + } + + + /** + * Get the project path + * @return String if it was set, null if not + */ + public String getProjectPath() { + return projectPath; + } + + + /** + * Get the VSS server path + * @return String if it was set, null if not + */ + public String getVssServerPath() { + return vssServerPath; + } + + + /** + * Get the SOS home directory + * @return String if it was set, null if not + */ + public String getSosHome() { + return sosHome; + } + + + /** + * Get the SOS serve path + * @return String if it was set, null if not + */ + public String getSosServerPath() { + return sosServerPath; + } + + + /** + * Get the filename to be acted upon + * @return String if it was set, null if not + */ + public 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; + } + } + + + /** + * 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; + } + } + + + /** + * 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; + } + } + + + /** + * 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; + } + } + + + /** + * Builds and returns the working directory + *

+ * The localpath is created if it didn't exist + * + * @return String the absolute path of the working directory + */ + public String getLocalPath() { + if (localPath == null) { + return project.getBaseDir().getAbsolutePath(); + } else { + // make sure localDir exists, create it if it doesn't + File dir = project.resolveFile(localPath); + if (!dir.exists()) { + boolean done = dir.mkdirs(); + if (!done) { + String msg = "Directory " + localPath + " creation was not " + + "successful for an unknown reason"; + throw new BuildException(msg, location); + } + project.log("Created dir: " + dir.getAbsolutePath()); + } + return dir.getAbsolutePath(); + } + } + + + /** + * Execute the created command line + * + * @param cmd Description of Parameter + * @return int the exit code + * @throws BuildException + */ + 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); + } + } +} + diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCheckin.java b/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCheckin.java new file mode 100644 index 000000000..c8b45f770 --- /dev/null +++ b/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCheckin.java @@ -0,0 +1,257 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2000 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 "The Jakarta Project", "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 + * . + */ +package org.apache.tools.ant.taskdefs.optional.sos; + +import org.apache.tools.ant.*; +import org.apache.tools.ant.types.Commandline; +import org.apache.tools.ant.types.Path; + +/** + * Task to commit and unlock file(s) in Visual Source Safe via a SourceOffSite server. + *

+ * The following attributes are interpretted: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
AttributeValuesRequired
soscmddirDirectory which contains soscmd(.exe)
+ * soscmd(.exe) must be in the path if this is not specified
No
vssserverpathpath to the srcsafe.ini - eg. \\server\vss\srcsafe.iniYes
sosserverpathaddress and port of the SOS server - eg. 192.168.0.1:8888Yes
projectpathSourceSafe project path without the "$"Yes
fileFilename to act upon
If no file is specified then act upon the project
No
usernameSourceSafe usernameYes
passwordSourceSafe passwordNo
localpathOverride the working directory and get to the specified pathNo
soshomeThe path to the SourceOffSite home directoryNo
nocompressiontrue or false - disable compressionNo
recursivetrue or false - Only works with the CheckOutProject commandNo
nocachetrue or false - Only needed if SOSHOME is set as an enviroment variableNo
verbosetrue or false - Status messages are displayedNo
commentA comment to be applied to all files being checked inNo
+ * + * @author Jesse Stockall + */ + +public class SOSCheckin extends SOS { + Commandline commandLine; + + + /** + * Executes the task. + *
+ * 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, location); + } + } + + + /** + * Build the command line
+ * + * CheckInFile required parameters: -server -name -password -database -project -file
+ * CheckInFile optional parameters: -workdir -log -verbose -nocache + * -nocompression -soshome
+ * + * CheckInProject required parameters: -server -name -password -database -project
+ * CheckInProject optional parameters: workdir -recursive -log -verbose -nocache + * -nocompression -soshome
+ * + * @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 + commandLine.createArgument().setValue(SOSCmd.FLAG_COMMAND); + commandLine.createArgument().setValue(SOSCmd.COMMAND_CHECKIN_FILE); + // add -file xxxxx to the commandline + commandLine.createArgument().setValue(SOSCmd.FLAG_FILE); + commandLine.createArgument().setValue(getFilename()); + } else { + // add -command CheckInProject to the commandline + commandLine.createArgument().setValue(SOSCmd.FLAG_COMMAND); + commandLine.createArgument().setValue(SOSCmd.COMMAND_CHECKIN_PROJECT); + // 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!", location); + } + 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!", location); + } + 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!", location); + } + 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!", location); + } + 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()); + } + // Look for a comment + if (getComment() != null) { + commandLine.createArgument().setValue(SOSCmd.FLAG_COMMENT); + commandLine.createArgument().setValue(getComment()); + } + return commandLine; + } +} + diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCheckout.java b/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCheckout.java new file mode 100644 index 000000000..1389bba78 --- /dev/null +++ b/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCheckout.java @@ -0,0 +1,247 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2000 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 "The Jakarta Project", "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 + * . + */ +package org.apache.tools.ant.taskdefs.optional.sos; + +import org.apache.tools.ant.*; +import org.apache.tools.ant.types.Commandline; +import org.apache.tools.ant.types.Path; + +/** + * Task to retreive and lock file(s) in Visual Source Safe via a SourceOffSite server. + *

+ * The following attributes are interpretted: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
AttributeValuesRequired
soscmddirDirectory which contains soscmd(.exe)
+ * soscmd(.exe) must be in the path if this is not specified
No
vssserverpathpath to the srcsafe.ini - eg. \\server\vss\srcsafe.iniYes
sosserverpathaddress and port of the SOS server - eg. 192.168.0.1:8888Yes
projectpathSourceSafe project path without the "$"Yes
fileFilename to act upon
If no file is specified then act upon the project
No
usernameSourceSafe usernameYes
passwordSourceSafe passwordNo
localpathOverride the working directory and get to the specified pathNo
soshomeThe path to the SourceOffSite home directoryNo
nocompressiontrue or false - disable compressionNo
recursivetrue or false - Only works with the CheckOutProject commandNo
nocachetrue or false - Only needed if SOSHOME is set as an enviroment variableNo
verbosetrue or false - Status messages are displayedNo
+ * + * @author Jesse Stockall + */ + +public class SOSCheckout extends SOS { + Commandline commandLine; + + + /** + * Executes the task. + *
+ * 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, location); + } + } + + + /** + * Build the command line
+ * + * CheckOutFile required parameters: -server -name -password -database -project -file
+ * CheckOutFile optional parameters: -workdir -verbose -nocache -nocompression -soshome
+ * + * CheckOutProject required parameters: -server -name -password -database -project
+ * CheckOutProject optional parameters:-workdir -recursive -verbose -nocache + * -nocompression -soshome
+ * + * @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 CheckOutFile to the commandline + commandLine.createArgument().setValue(SOSCmd.FLAG_COMMAND); + commandLine.createArgument().setValue(SOSCmd.COMMAND_CHECKOUT_FILE); + // add -file xxxxx to the commandline + commandLine.createArgument().setValue(SOSCmd.FLAG_FILE); + commandLine.createArgument().setValue(getFilename()); + } else { + // add -command CheckOutProject to the commandline + commandLine.createArgument().setValue(SOSCmd.FLAG_COMMAND); + commandLine.createArgument().setValue(SOSCmd.COMMAND_CHECKOUT_PROJECT); + // 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!", location); + } + 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!", location); + } + 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!", location); + } + 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!", location); + } + 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()); + } + return commandLine; + } +} + diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCmd.java b/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCmd.java new file mode 100644 index 000000000..44e41a27a --- /dev/null +++ b/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCmd.java @@ -0,0 +1,93 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2000 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 "The Jakarta Project", "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 + * . + * + */ + +package org.apache.tools.ant.taskdefs.optional.sos; + +/** + * Interface to hold constants used by the SOS tasks + * + * @author Jesse Stockall + */ +public interface SOSCmd { + // soscmd Command options + public final static String COMMAND_SOS_EXE = "soscmd"; + public final static String COMMAND_GET_FILE = "GetFile"; + public final static String COMMAND_GET_PROJECT = "GetProject"; + public final static String COMMAND_CHECKOUT_FILE = "CheckOutFile"; + public final static String COMMAND_CHECKOUT_PROJECT = "CheckOutProject"; + public final static String COMMAND_CHECKIN_FILE = "CheckInFile"; + public final static String COMMAND_CHECKIN_PROJECT = "CheckInProject"; + public final static String COMMAND_HISTORY = "GetFileHistory"; + public final static String COMMAND_LABEL = "AddLabel"; + public final static String PROJECT_PREFIX = "$"; + // soscmd Option flags + public final static String FLAG_COMMAND = "-command"; + public final static String FLAG_VSS_SERVER = "-database"; + public final static String FLAG_USERNAME = "-name"; + public final static String FLAG_PASSWORD = "-password"; + public final static String FLAG_COMMENT = "-log"; + public final static String FLAG_WORKING_DIR = "-workdir"; + public final static String FLAG_RECURSION = "-recursive"; + public final static String FLAG_VERSION = "-revision"; + public final static String FLAG_LABEL = "-label"; + public final static String FLAG_NO_COMPRESSION = "-nocompress"; + public final static String FLAG_NO_CACHE = "-nocache"; + public final static String FLAG_SOS_SERVER = "-server"; + public final static String FLAG_SOS_HOME = "-soshome"; + public final static String FLAG_PROJECT = "-project"; + public final static String FLAG_FILE = "-file"; + public final static String FLAG_VERBOSE = "-verbose"; +} + diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSGet.java b/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSGet.java new file mode 100644 index 000000000..a8b59e4de --- /dev/null +++ b/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSGet.java @@ -0,0 +1,268 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2000 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 "The Jakarta Project", "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 + * . + */ +package org.apache.tools.ant.taskdefs.optional.sos; + +import org.apache.tools.ant.*; +import org.apache.tools.ant.types.Commandline; + +/** + * Task to retreive file(s) from Visual Source Safe via a SourceOffSite server. + *

+ * The following attributes are interpretted: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * @author Jesse Stockall + */ + +public class SOSGet extends SOS { + Commandline commandLine; + + + /** + * Executes the task. + *
+ * 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, location); + } + } + + + /** + * Build the command line
+ * + * GetFile required parameters: -server -name -password -database -project -file
+ * GetFile optional parameters: -workdir -revision -verbose -nocache -nocompression -soshome
+ * + * GetProject required parameters: -server -name -password -database -project
+ * GetProject optional parameters: -label -workdir -recursive -verbose -nocache + * -nocompression -soshome
+ * + * @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 GetFile to the commandline + commandLine.createArgument().setValue(SOSCmd.FLAG_COMMAND); + commandLine.createArgument().setValue(SOSCmd.COMMAND_GET_FILE); + // add -file xxxxx to the commandline + commandLine.createArgument().setValue(SOSCmd.FLAG_FILE); + commandLine.createArgument().setValue(getFilename()); + // look for a version attribute + if (getVersion() != null) { + //add -revision xxxxx to the commandline + commandLine.createArgument().setValue(SOSCmd.FLAG_VERSION); + commandLine.createArgument().setValue(getVersion()); + } + } else { + // add -command GetProject to the commandline + commandLine.createArgument().setValue(SOSCmd.FLAG_COMMAND); + commandLine.createArgument().setValue(SOSCmd.COMMAND_GET_PROJECT); + // look for a recursive option + commandLine.createArgument().setValue(getRecursive()); + // look for a label option + if (getLabel() != null) { + commandLine.createArgument().setValue(SOSCmd.FLAG_LABEL); + commandLine.createArgument().setValue(getLabel()); + } + } + // SOS server address is required + if (getSosServerPath() == null) { + throw new BuildException("sosserverpath attribute must be set!", location); + } + 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!", location); + } + 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!", location); + } + 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!", location); + } + 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()); + } + return commandLine; + } +} + diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSLabel.java b/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSLabel.java new file mode 100644 index 000000000..380199708 --- /dev/null +++ b/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSLabel.java @@ -0,0 +1,204 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2000 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 "The Jakarta Project", "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 + * . + */ +package org.apache.tools.ant.taskdefs.optional.sos; + +import org.apache.tools.ant.*; +import org.apache.tools.ant.types.Commandline; + +/** + * Task to label a Visual Source Safe via a SourceOffSite server. + *

+ * The following attributes are interpretted: + *

AttributeValuesRequired
soscmddirDirectory which contains soscmd(.exe)
+ * soscmd(.exe) must be in the path if this is not specified
No
vssserverpathpath to the srcsafe.ini - eg. \\server\vss\srcsafe.iniYes
sosserverpathaddress and port of the SOS server - eg. 192.168.0.1:8888Yes
projectpathSourceSafe project path without the "$"Yes
fileFilename to act upon
+ * If no file is specified then act upon the project
No
usernameSourceSafe usernameYes
passwordSourceSafe passwordNo
localpathOverride the working directory and get to the specified pathNo
soshomeThe path to the SourceOffSite home directoryNo
nocompressiontrue or false - disable compressionNo
recursivetrue or false - Only works with the GetProject commandNo
versiona version number to get - Only works with the GetFile commandNo
labela label version to get - Only works with the GetProject commandNo
nocachetrue or false - Only needed if SOSHOME is set as an enviroment variableNo
verbosetrue or false - Status messages are displayedNo
+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
AttributeValuesRequired
soscmddirDirectory which contains soscmd(.exe)
+ * soscmd(.exe) must be in the path if this is not specified
No
vssserverpathpath to the srcsafe.ini - eg. \\server\vss\srcsafe.iniYes
sosserverpathaddress and port of the SOS server - eg. 192.168.0.1:8888Yes
projectpathSourceSafe project path without the "$"Yes
usernameSourceSafe usernameYes
passwordSourceSafe passwordNo
labelThe label to apply to a projectYes
commentA comment to be applied to all files being labeledNo
verbosetrue or false - Status messages are displayedNo
+ * + * @author Jesse Stockall + */ + +public class SOSLabel extends SOS { + Commandline commandLine; + + + /** + * Executes the task.
+ * 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, location); + } + } + + + /** + * Build the command line
+ * AddLabel required parameters: -server -name -password -database -project -label
+ * AddLabel optional parameters: -verbose -comment
+ * + * @return Commandline the generated command to be executed + */ + 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!", location); + } + 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!", location); + } + 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!", location); + } + 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!", location); + } + commandLine.createArgument().setValue(SOSCmd.FLAG_PROJECT); + commandLine.createArgument().setValue(getProjectPath()); + // a label is required + if (getLabel() == null) { + throw new BuildException("label attribute must be set!", location); + } + commandLine.createArgument().setValue(SOSCmd.FLAG_LABEL); + commandLine.createArgument().setValue(getLabel()); + + // The following options are optional. + + // -verbose + commandLine.createArgument().setValue(getVerbose()); + // Look for a comment + if (getComment() != null) { + commandLine.createArgument().setValue(SOSCmd.FLAG_COMMENT); + commandLine.createArgument().setValue(getComment()); + } + return commandLine; + } +} + diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/sos/package.html b/src/main/org/apache/tools/ant/taskdefs/optional/sos/package.html new file mode 100644 index 000000000..73b8a6559 --- /dev/null +++ b/src/main/org/apache/tools/ant/taskdefs/optional/sos/package.html @@ -0,0 +1,13 @@ + + +

+ Ant tasks for working with a SourceOffSite source control system +

+

+ The <SOSGet> Retreives file(s) from a SOS database
+ The <SOSCheckin> Commits and unlocks file(s) in a SOS database
+ The <SOSCheckout> Retreives and lock file(s) in a SOS database
+ The <SOSLabel> Label a SOS database
+

+ + diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java new file mode 100644 index 000000000..82a551d38 --- /dev/null +++ b/src/testcases/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java @@ -0,0 +1,690 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 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 "The Jakarta Project", "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 + * . + */ +package org.apache.tools.ant.taskdefs.optional.sos; + +import junit.framework.TestCase; +import junit.framework.AssertionFailedError; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.types.Commandline; +import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.util.FileUtils; +import org.apache.tools.ant.taskdefs.optional.sos.*; + +/** + * Basic testcase to ensure that command line generation is ok + * @author Jesse Stockall + */ +public class SOSTest extends TestCase { + + private SOSGet sosGet; + private SOSCheckin sosCheckin; + private SOSCheckout sosCheckout; + private SOSLabel sosLabel; + private Project project; + private Commandline commandline; + private FileUtils fileUtils; + + private static final String VSS_SERVER_PATH = "\\\\server\\vss\\srcsafe.ini"; + private static final String VSS_PROJECT_PATH = "/SourceRoot/Project"; + private static final String SOS_SERVER_PATH = "192.168.0.1:8888"; + private static final String SOS_USERNAME = "ant"; + private static final String SOS_PASSWORD = "rocks"; + private static final String LOCAL_PATH = "/home/jesse/source/dir"; + private static final String SRC_FILE = "Class1.java"; + private static final String SRC_LABEL = "label1"; + private static final String SRC_COMMENT = "I fixed a bug"; + private static final String SOS_HOME = "/home/user/.sos"; + private static final String VERSION = "007"; + + public SOSTest(String s) { + super(s); + } + + protected void setUp() throws Exception { + sosGet = new SOSGet(); + sosCheckin = new SOSCheckin(); + sosCheckout = new SOSCheckout(); + sosLabel = new SOSLabel(); + project = new Project(); + project.setBasedir("."); + fileUtils = FileUtils.newFileUtils(); + } + + /** + * Test SOSGetFile flags & commandline generation + */ + public void testGetFileFlags() { + String[] sTestCmdLine = { "soscmd", "-command", "GetFile", "-file", + SRC_FILE, "-revision", "007", "-server", SOS_SERVER_PATH, "-name", + SOS_USERNAME, "-password", SOS_PASSWORD, "-database", VSS_SERVER_PATH, + "-project", "$"+VSS_PROJECT_PATH, "-verbose", "-nocompress", + "-nocache", "-workdir", fileUtils.normalize(LOCAL_PATH).getAbsolutePath() }; + + Path path = new Path(project, LOCAL_PATH); + + // Set up a SOSGet task + sosGet.setProject(project); + sosGet.setVssServerPath(VSS_SERVER_PATH); + sosGet.setSosServerPath(SOS_SERVER_PATH); + sosGet.setProjectPath(VSS_PROJECT_PATH); + sosGet.setFile(SRC_FILE); + sosGet.setUsername(SOS_USERNAME); + sosGet.setPassword(SOS_PASSWORD); + sosGet.setVersion(VERSION); + sosGet.setLocalPath(path); + sosGet.setNoCache(true); + sosGet.setNoCompress(true); + sosGet.setVerbose(true); + sosGet.setRecursive(true); + + commandline = sosGet.buildCmdLine(); + String[] sGeneratedCmdLine = commandline.getCommandline(); + int i = 0; + while (i < sTestCmdLine.length) { + try { + assertEquals("GetFile arg # " + String.valueOf(i), + sTestCmdLine[i], + sGeneratedCmdLine[i]); + i++; + } catch (ArrayIndexOutOfBoundsException aioob) { + fail("GetFile missing arg"); + } + + } + if (sGeneratedCmdLine.length > sTestCmdLine.length) { + // We have extra elements + fail("GetFile extra args"); + } + } + + /** + * Test SOSGetProject flags & commandline generation + */ + public void testGetProjectFlags() { + String[] sTestCmdLine = { "soscmd", "-command", "GetProject", "-recursive", + "-label", SRC_LABEL, "-server", SOS_SERVER_PATH, "-name", SOS_USERNAME, + "-password", "", "-database", VSS_SERVER_PATH , "-project", + "$"+VSS_PROJECT_PATH, "", "", "-soshome", SOS_HOME, "-workdir", + project.getBaseDir().getAbsolutePath() }; + // Set up a SOSGet task + sosGet.setProject(project); + sosGet.setVssServerPath(VSS_SERVER_PATH); + sosGet.setSosServerPath(SOS_SERVER_PATH); + sosGet.setProjectPath(VSS_PROJECT_PATH); + sosGet.setLabel(SRC_LABEL); + sosGet.setUsername(SOS_USERNAME); + sosGet.setSosHome(SOS_HOME); + sosGet.setNoCache(true); + sosGet.setNoCompress(false); + sosGet.setVerbose(false); + sosGet.setRecursive(true); + + commandline = sosGet.buildCmdLine(); + String[] sGeneratedCmdLine = commandline.getCommandline(); + + int i = 0; + while (i < sTestCmdLine.length) { + try { + assertEquals("GetProject arg # " + String.valueOf(i), + sTestCmdLine[i], + sGeneratedCmdLine[i]); + i++; + } catch (ArrayIndexOutOfBoundsException aioob) { + fail("GetProject missing arg"); + } + + } + if (sGeneratedCmdLine.length > sTestCmdLine.length) { + // We have extra elements + fail("GetProject extra args"); + } + } + + /** + * Test SOSGet required attributes 1 by 1 + */ + public void testGetExceptions() { + boolean buildEx = false; + + // Set up a SOSGet task + sosGet.setProject(project); + // No options set - SosServerPath should fail + try { + commandline = sosGet.buildCmdLine(); + } catch (BuildException be) { + if (be.getMessage().compareTo("sosserverpath attribute must be set!") == 0) { + buildEx = true; + } + } + assertTrue("GetException SosServerPath", buildEx); + buildEx = false; + + // Set SosServerPath - Username should fail + sosGet.setSosServerPath(SOS_SERVER_PATH); + try { + commandline = sosGet.buildCmdLine(); + } catch (BuildException be) { + if (be.getMessage().compareTo("username attribute must be set!") == 0) { + buildEx = true; + } + } + assertTrue("GetException Username", buildEx); + buildEx = false; + + // Set Username - VssServerPath should fail + sosGet.setUsername(SOS_USERNAME); + try { + commandline = sosGet.buildCmdLine(); + } catch (BuildException be) { + if (be.getMessage().compareTo("vssserverpath attribute must be set!") == 0) { + buildEx = true; + } + } + assertTrue("GetException VssServerPath", buildEx); + buildEx = false; + + // Set VssServerPath - ProjectPath should fail + sosGet.setVssServerPath(VSS_SERVER_PATH); + try { + commandline = sosGet.buildCmdLine(); + } catch (BuildException be) { + if (be.getMessage().compareTo("projectpath attribute must be set!") == 0) { + buildEx = true; + } + } + assertTrue("GetException ProjectPath", buildEx); + + // Set ProjectPath - All required options set + sosGet.setProjectPath(VSS_PROJECT_PATH); + try { + commandline = sosGet.buildCmdLine(); + buildEx = true; + } catch (BuildException be) { + buildEx = false; + } + assertTrue("GetException All required options set", buildEx); + } + + /** + * Test CheckInFile option flags + */ + public void testCheckinFileFlags() { + String[] sTestCmdLine = { "soscmd", "-command", "CheckInFile", "-file", + SRC_FILE, "-server", SOS_SERVER_PATH, "-name", SOS_USERNAME, + "-password", SOS_PASSWORD, "-database", VSS_SERVER_PATH, "-project", + "$"+VSS_PROJECT_PATH, "-verbose", "-nocompress", "-nocache", + "-workdir", fileUtils.normalize(LOCAL_PATH).getAbsolutePath(), "-log", SRC_COMMENT }; + + Path path = new Path(project, LOCAL_PATH); + + // Set up a SOSCheckin task + sosCheckin.setProject(project); + sosCheckin.setVssServerPath(VSS_SERVER_PATH); + sosCheckin.setSosServerPath(SOS_SERVER_PATH); + sosCheckin.setProjectPath(VSS_PROJECT_PATH); + sosCheckin.setFile(SRC_FILE); + sosCheckin.setComment(SRC_COMMENT); + sosCheckin.setUsername(SOS_USERNAME); + sosCheckin.setPassword(SOS_PASSWORD); + sosCheckin.setLocalPath(path); + sosCheckin.setNoCache(true); + sosCheckin.setNoCompress(true); + sosCheckin.setVerbose(true); + sosCheckin.setRecursive(true); + + commandline = sosCheckin.buildCmdLine(); + String[] sGeneratedCmdLine = commandline.getCommandline(); + + int i = 0; + while (i < sTestCmdLine.length) { + try { + assertEquals("CheckInFile arg # " + String.valueOf(i), + sTestCmdLine[i], + sGeneratedCmdLine[i]); + i++; + } catch (ArrayIndexOutOfBoundsException aioob) { + fail("CheckInFile missing arg"); + } + + } + if (sGeneratedCmdLine.length > sTestCmdLine.length) { + // We have extra elements + fail("CheckInFile extra args"); + } + } + + /** + * Test CheckInProject option flags + */ + public void testCheckinProjectFlags() { + String[] sTestCmdLine = { "soscmd", "-command", "CheckInProject", + "-recursive", "-server", SOS_SERVER_PATH, "-name", SOS_USERNAME, + "-password", "", "-database", VSS_SERVER_PATH , "-project", + "$"+VSS_PROJECT_PATH, "", "", "-soshome", SOS_HOME, "-workdir", + project.getBaseDir().getAbsolutePath(), "-log", SRC_COMMENT, }; + + // Set up a SOSCheckin task + sosCheckin.setProject(project); + sosCheckin.setVssServerPath(VSS_SERVER_PATH); + sosCheckin.setSosServerPath(SOS_SERVER_PATH); + sosCheckin.setProjectPath(VSS_PROJECT_PATH); + sosCheckin.setComment(SRC_COMMENT); + sosCheckin.setUsername(SOS_USERNAME); + sosCheckin.setSosHome(SOS_HOME); + sosCheckin.setNoCache(true); + sosCheckin.setNoCompress(false); + sosCheckin.setVerbose(false); + sosCheckin.setRecursive(true); + + commandline = sosCheckin.buildCmdLine(); + String[] sGeneratedCmdLine = commandline.getCommandline(); + + int i = 0; + while (i < sTestCmdLine.length) { + try { + assertEquals("CheckInProject arg # " + String.valueOf(i), + sTestCmdLine[i], + sGeneratedCmdLine[i]); + i++; + } catch (ArrayIndexOutOfBoundsException aioob) { + fail("CheckInProject missing arg"); + } + + } + if (sGeneratedCmdLine.length > sTestCmdLine.length) { + // We have extra elements + fail("CheckInProject extra args"); + } + } + + /** + * Test SOSCheckIn required attributes 1 by 1 + */ + public void testCheckinExceptions() { + boolean buildEx = false; + + // Set up a sosCheckin task + sosCheckin.setProject(project); + // No options set - SosServerPath should fail + try { + commandline = sosCheckin.buildCmdLine(); + } catch (BuildException be) { + if (be.getMessage().compareTo("sosserverpath attribute must be set!") == 0) { + buildEx = true; + } + } + assertTrue("CheckinException SosServerPath", buildEx); + buildEx = false; + + // Set SosServerPath - Username should fail + sosCheckin.setSosServerPath(SOS_SERVER_PATH); + try { + commandline = sosCheckin.buildCmdLine(); + } catch (BuildException be) { + if (be.getMessage().compareTo("username attribute must be set!") == 0) { + buildEx = true; + } + } + assertTrue("CheckinException Username", buildEx); + buildEx = false; + + // Set Username - VssServerPath should fail + sosCheckin.setUsername(SOS_USERNAME); + try { + commandline = sosCheckin.buildCmdLine(); + } catch (BuildException be) { + if (be.getMessage().compareTo("vssserverpath attribute must be set!") == 0) { + buildEx = true; + } + } + assertTrue("CheckinException VssServerPath", buildEx); + buildEx = false; + + // Set VssServerPath - ProjectPath should fail + sosCheckin.setVssServerPath(VSS_SERVER_PATH); + try { + commandline = sosCheckin.buildCmdLine(); + } catch (BuildException be) { + if (be.getMessage().compareTo("projectpath attribute must be set!") == 0) { + buildEx = true; + } + } + assertTrue("CheckinException ProjectPath", buildEx); + + // Set ProjectPath - All required options set + sosCheckin.setProjectPath(VSS_PROJECT_PATH); + try { + commandline = sosCheckin.buildCmdLine(); + buildEx = true; + } catch (BuildException be) { + buildEx = false; + } + assertTrue("CheckinException All required options set", buildEx); + } + + /** + * Test CheckOutFile option flags + */ + public void testCheckoutFileFlags() { + String[] sTestCmdLine = { "soscmd", "-command", "CheckOutFile", "-file", + SRC_FILE, "-server", SOS_SERVER_PATH, "-name", SOS_USERNAME, + "-password", SOS_PASSWORD, "-database", VSS_SERVER_PATH, "-project", + "$"+VSS_PROJECT_PATH, "-verbose", "-nocompress", "-nocache", + "-workdir", fileUtils.normalize(LOCAL_PATH).getAbsolutePath() }; + + Path path = new Path(project, LOCAL_PATH); + + // Set up a SOSCheckout task + sosCheckout.setProject(project); + sosCheckout.setVssServerPath(VSS_SERVER_PATH); + sosCheckout.setSosServerPath(SOS_SERVER_PATH); + sosCheckout.setProjectPath(VSS_PROJECT_PATH); + sosCheckout.setFile(SRC_FILE); + sosCheckout.setUsername(SOS_USERNAME); + sosCheckout.setPassword(SOS_PASSWORD); + sosCheckout.setLocalPath(path); + sosCheckout.setNoCache(true); + sosCheckout.setNoCompress(true); + sosCheckout.setVerbose(true); + sosCheckout.setRecursive(true); + + commandline = sosCheckout.buildCmdLine(); + String[] sGeneratedCmdLine = commandline.getCommandline(); + + int i = 0; + while (i < sTestCmdLine.length) { + try { + assertEquals("CheckOutFile arg # " + String.valueOf(i), + sTestCmdLine[i], + sGeneratedCmdLine[i]); + i++; + } catch (ArrayIndexOutOfBoundsException aioob) { + fail("CheckOutFile missing arg"); + } + + } + if (sGeneratedCmdLine.length > sTestCmdLine.length) { + // We have extra elements + fail("CheckOutFile extra args"); + } + } + + /** + * Test CheckOutProject option flags + */ + public void testCheckoutProjectFlags() { + String[] sTestCmdLine = { "soscmd", "-command", "CheckOutProject", + "-recursive", "-server", SOS_SERVER_PATH, "-name", SOS_USERNAME, + "-password", "", "-database", VSS_SERVER_PATH , "-project", + "$"+VSS_PROJECT_PATH, "", "", "-soshome", SOS_HOME, "-workdir", + project.getBaseDir().getAbsolutePath() }; + + // Set up a sosCheckout task + sosCheckout.setProject(project); + sosCheckout.setVssServerPath(VSS_SERVER_PATH); + sosCheckout.setSosServerPath(SOS_SERVER_PATH); + sosCheckout.setProjectPath(VSS_PROJECT_PATH); + sosCheckout.setUsername(SOS_USERNAME); + sosCheckout.setSosHome(SOS_HOME); + sosCheckout.setNoCache(true); + sosCheckout.setNoCompress(false); + sosCheckout.setVerbose(false); + sosCheckout.setRecursive(true); + + commandline = sosCheckout.buildCmdLine(); + String[] sGeneratedCmdLine = commandline.getCommandline(); + + int i = 0; + while (i < sTestCmdLine.length) { + try { + assertEquals("CheckOutProject arg # " + String.valueOf(i), + sTestCmdLine[i], + sGeneratedCmdLine[i]); + i++; + } catch (ArrayIndexOutOfBoundsException aioob) { + fail("CheckOutProject missing arg"); + } + + } + if (sGeneratedCmdLine.length > sTestCmdLine.length) { + // We have extra elements + fail("CheckOutProject extra args"); + } + } + + /** + * Test SOSCheckout required attributes 1 by 1 + */ + public void testCheckoutExceptions() { + boolean buildEx = false; + + // Set up a sosCheckout task + sosCheckout.setProject(project); + // No options set - SosServerPath should fail + try { + commandline = sosCheckout.buildCmdLine(); + } catch (BuildException be) { + if (be.getMessage().compareTo("sosserverpath attribute must be set!") == 0) { + buildEx = true; + } + } + assertTrue("CheckoutException SosServerPath", buildEx); + buildEx = false; + + // Set SosServerPath - Username should fail + sosCheckout.setSosServerPath(SOS_SERVER_PATH); + try { + commandline = sosCheckout.buildCmdLine(); + } catch (BuildException be) { + if (be.getMessage().compareTo("username attribute must be set!") == 0) { + buildEx = true; + } + } + assertTrue("CheckoutException Username", buildEx); + buildEx = false; + + // Set Username - VssServerPath should fail + sosCheckout.setUsername(SOS_USERNAME); + try { + commandline = sosCheckout.buildCmdLine(); + } catch (BuildException be) { + if (be.getMessage().compareTo("vssserverpath attribute must be set!") == 0) { + buildEx = true; + } + } + assertTrue("CheckoutException VssServerPath", buildEx); + buildEx = false; + + // Set VssServerPath - ProjectPath should fail + sosCheckout.setVssServerPath(VSS_SERVER_PATH); + try { + commandline = sosCheckout.buildCmdLine(); + } catch (BuildException be) { + if (be.getMessage().compareTo("projectpath attribute must be set!") == 0) { + buildEx = true; + } + } + assertTrue("CheckoutException ProjectPath", buildEx); + + // Set ProjectPath - All required options set + sosCheckout.setProjectPath(VSS_PROJECT_PATH); + try { + commandline = sosCheckout.buildCmdLine(); + buildEx = true; + } catch (BuildException be) { + buildEx = false; + } + assertTrue("CheckoutException All required options set", buildEx); + } + + /** + * Test Label option flags + */ + public void testLabelFlags() { + String[] sTestCmdLine = { "soscmd", "-command", "AddLabel", "-server", + SOS_SERVER_PATH, "-name", SOS_USERNAME, "-password", "", "-database", + VSS_SERVER_PATH , "-project", "$"+VSS_PROJECT_PATH, "-label", + SRC_LABEL, "-verbose", "-log", SRC_COMMENT }; + + // Set up a sosCheckout task + sosLabel.setVssServerPath(VSS_SERVER_PATH); + sosLabel.setSosServerPath(SOS_SERVER_PATH); + sosLabel.setProjectPath(VSS_PROJECT_PATH); + sosLabel.setUsername(SOS_USERNAME); + sosLabel.setSosHome(SOS_HOME); + sosLabel.setComment(SRC_COMMENT); + sosLabel.setLabel(SRC_LABEL); + sosLabel.setNoCache(true); + sosLabel.setNoCompress(false); + sosLabel.setVerbose(true); + + commandline = sosLabel.buildCmdLine(); + String[] sGeneratedCmdLine = commandline.getCommandline(); + + int i = 0; + while (i < sTestCmdLine.length) { + try { + assertEquals("AddLabel arg # " + String.valueOf(i), + sTestCmdLine[i], + sGeneratedCmdLine[i]); + i++; + } catch (ArrayIndexOutOfBoundsException aioob) { + fail("AddLabel missing arg"); + } + + } + if (sGeneratedCmdLine.length > sTestCmdLine.length) { + // We have extra elements + fail("AddLabel extra args"); + } + } + + /** + * Test SOSLabel required attributes 1 by 1 + */ + public void testLabelExceptions() { + boolean buildEx = false; + + // Set up a sosLabel task + sosLabel.setProject(project); + // No options set - SosServerPath should fail + try { + commandline = sosLabel.buildCmdLine(); + } catch (BuildException be) { + if (be.getMessage().compareTo("sosserverpath attribute must be set!") == 0) { + buildEx = true; + } + } + assertTrue("LabelException SosServerPath", buildEx); + buildEx = false; + + // Set SosServerPath - Username should fail + sosLabel.setSosServerPath(SOS_SERVER_PATH); + try { + commandline = sosLabel.buildCmdLine(); + } catch (BuildException be) { + if (be.getMessage().compareTo("username attribute must be set!") == 0) { + buildEx = true; + } + } + assertTrue("LabelException Username", buildEx); + buildEx = false; + + // Set Username - VssServerPath should fail + sosLabel.setUsername(SOS_USERNAME); + try { + commandline = sosLabel.buildCmdLine(); + } catch (BuildException be) { + if (be.getMessage().compareTo("vssserverpath attribute must be set!") == 0) { + buildEx = true; + } + } + assertTrue("LabelException VssServerPath", buildEx); + buildEx = false; + + // Set VssServerPath - ProjectPath should fail + sosLabel.setVssServerPath(VSS_SERVER_PATH); + try { + commandline = sosLabel.buildCmdLine(); + } catch (BuildException be) { + if (be.getMessage().compareTo("projectpath attribute must be set!") == 0) { + buildEx = true; + } + } + assertTrue("LabelException ProjectPath", buildEx); + + // Set ProjectPath - Label should fail + sosLabel.setProjectPath(VSS_PROJECT_PATH); + try { + commandline = sosLabel.buildCmdLine(); + } catch (BuildException be) { + if (be.getMessage().compareTo("label attribute must be set!") == 0) { + buildEx = true; + } + } + assertTrue("LabelException Label", buildEx); + + // Set Label - All required options set + sosLabel.setLabel(SRC_LABEL); + try { + commandline = sosLabel.buildCmdLine(); + buildEx = true; + } catch (BuildException be) { + buildEx = false; + } + assertTrue("LabelException All required options set", buildEx); + } + +}