diff options
Diffstat (limited to 'framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/sos')
7 files changed, 982 insertions, 0 deletions
diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOS.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOS.java new file mode 100644 index 00000000..03031d5e --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOS.java @@ -0,0 +1,479 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.tools.ant.taskdefs.optional.sos; + +import java.io.File; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.Task; +import org.apache.tools.ant.taskdefs.Execute; +import org.apache.tools.ant.taskdefs.LogStreamHandler; +import org.apache.tools.ant.types.Commandline; +import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.util.FileUtils; + +/** + * A base class for creating tasks for executing commands on SourceOffSite. + * + * These tasks were inspired by the VSS tasks. + * + */ + +public abstract class SOS extends Task implements SOSCmd { + + private static final int ERROR_EXIT_STATUS = 255; + + 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; + + // CheckStyle:VisibilityModifier OFF - bc + /** Commandline to be executed. */ + protected Commandline commandLine; + // CheckStyle:VisibilityModifier ON + + /** + * Flag to disable the cache when set. + * Required if SOSHOME is set as an environment variable. + * Defaults to false. + * + * @param nocache True to disable caching. + */ + public final void setNoCache(boolean nocache) { + noCache = nocache; + } + + /** + * Flag to disable compression when set. Defaults to false. + * + * @param nocompress True to disable compression. + */ + public final void setNoCompress(boolean nocompress) { + noCompress = nocompress; + } + + /** + * The directory where soscmd(.exe) is located. + * soscmd must be on the path if omitted. + * + * @param dir The new sosCmd value. + */ + public final void setSosCmd(String dir) { + sosCmdDir = FileUtils.translatePath(dir); + } + + /** + * The SourceSafe username. + * + * @param username The new username value. + * + * @ant.attribute group="required" + */ + public final void setUsername(String username) { + sosUsername = username; + } + + /** + * The SourceSafe password. + * + * @param password The new password value. + */ + public final void setPassword(String password) { + sosPassword = password; + } + + /** + * The SourceSafe project path. + * + * @param projectpath The new projectpath value. + * + * @ant.attribute group="required" + */ + public final void setProjectPath(String projectpath) { + if (projectpath.startsWith(SOSCmd.PROJECT_PREFIX)) { + projectPath = projectpath; + } else { + projectPath = SOSCmd.PROJECT_PREFIX + projectpath; + } + } + + /** + * The path to the location of the ss.ini file. + * + * @param vssServerPath The new vssServerPath value. + * + * @ant.attribute group="required" + */ + public final void setVssServerPath(String vssServerPath) { + this.vssServerPath = vssServerPath; + } + + /** + * Path to the SourceOffSite home directory. + * + * @param sosHome The new sosHome value. + */ + public final void setSosHome(String sosHome) { + this.sosHome = sosHome; + } + + /** + * The address and port of SourceOffSite Server, + * for example 192.168.0.1:8888. + * + * @param sosServerPath The new sosServerPath value. + * + * @ant.attribute group="required" + */ + public final void setSosServerPath(String sosServerPath) { + this.sosServerPath = sosServerPath; + } + + /** + * Override the working directory and get to the specified path. + * + * @param path The new localPath value. + */ + public final void setLocalPath(Path path) { + localPath = path.toString(); + } + + /** + * Enable verbose output. Defaults to false. + * + * @param verbose True for verbose output. + */ + public void setVerbose(boolean verbose) { + this.verbose = verbose; + } + + // Special setters for the sub-classes + + /** + * Set the file name. + * @param file the filename to use. + */ + protected void setInternalFilename(String file) { + filename = file; + } + + /** + * Set the recursive flag. + * @param recurse if true use the recursive flag on the command line. + */ + protected void setInternalRecursive(boolean recurse) { + recursive = recurse; + } + + /** + * Set the comment text. + * @param text the comment text to use. + */ + protected void setInternalComment(String text) { + comment = text; + } + + /** + * Set the label. + * @param text the label to use. + */ + protected void setInternalLabel(String text) { + label = text; + } + + /** + * Set the version. + * @param text the version to use. + */ + protected void setInternalVersion(String text) { + version = text; + } + + /** + * Get the executable to run. Add the path if it was specified in the build file + * + * @return the executable to run. + */ + protected String getSosCommand() { + if (sosCmdDir == null) { + return COMMAND_SOS_EXE; + } else { + return sosCmdDir + File.separator + COMMAND_SOS_EXE; + } + } + + /** + * Get the comment + * @return if it was set, null if not. + */ + protected String getComment() { + return comment; + } + + /** + * Get the version + * @return if it was set, null if not. + */ + protected String getVersion() { + return version; + } + + /** + * Get the label + * @return if it was set, null if not. + */ + protected String getLabel() { + return label; + } + + /** + * Get the username + * @return if it was set, null if not. + */ + protected String getUsername() { + return sosUsername; + } + + /** + * Get the password + * @return empty string if it wasn't set. + */ + protected String getPassword() { + return sosPassword; + } + + /** + * Get the project path + * @return if it was set, null if not. + */ + protected String getProjectPath() { + return projectPath; + } + + /** + * Get the VSS server path + * @return if it was set, null if not. + */ + protected String getVssServerPath() { + return vssServerPath; + } + + /** + * Get the SOS home directory. + * @return if it was set, null if not. + */ + protected String getSosHome() { + return sosHome; + } + + /** + * Get the SOS serve path. + * @return if it was set, null if not. + */ + protected String getSosServerPath() { + return sosServerPath; + } + + /** + * Get the filename to be acted upon. + * @return if it was set, null if not. + */ + protected String getFilename() { + return filename; + } + + /** + * Get the NoCompress flag. + * + * @return the 'nocompress' Flag if the attribute was 'true', + * otherwise an empty string. + */ + protected String getNoCompress() { + return noCompress ? FLAG_NO_COMPRESSION : ""; + } + + /** + * Get the NoCache flag. + * + * @return the 'nocache' Flag if the attribute was 'true', otherwise an empty string. + */ + protected String getNoCache() { + return noCache ? FLAG_NO_CACHE : ""; + } + + /** + * Get the 'verbose' Flag. + * + * @return the 'verbose' Flag if the attribute was 'true', otherwise an empty string. + */ + protected String getVerbose() { + return verbose ? FLAG_VERBOSE : ""; + } + + /** + * Get the 'recursive' Flag. + * + * @return the 'recursive' Flag if the attribute was 'true', otherwise an empty string. + */ + protected String getRecursive() { + return recursive ? FLAG_RECURSION : ""; + } + + /** + * Builds and returns the working directory. + * <p> + * The localpath is created if it didn't exist. + * + * @return the absolute path of the working directory. + */ + protected String getLocalPath() { + if (localPath == null) { + return getProject().getBaseDir().getAbsolutePath(); + } else { + // make sure localDir exists, create it if it doesn't + File dir = getProject().resolveFile(localPath); + if (!dir.exists()) { + boolean done = dir.mkdirs() || dir.isDirectory(); + if (!done) { + String msg = "Directory " + localPath + " creation was not " + + "successful for an unknown reason"; + throw new BuildException(msg, getLocation()); + } + getProject().log("Created dir: " + dir.getAbsolutePath()); + } + return dir.getAbsolutePath(); + } + } + + /** + * Subclasses implement the logic required to construct the command line. + * + * @return The command line to execute. + */ + abstract Commandline buildCmdLine(); + + + /** + * Execute the created command line. + * + * @throws BuildException on error. + */ + public void execute() + throws BuildException { + int result = 0; + buildCmdLine(); + result = run(commandLine); + if (result == ERROR_EXIT_STATUS) { // 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) { + try { + Execute exe = new Execute(new LogStreamHandler(this, + Project.MSG_INFO, + Project.MSG_WARN)); + + 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()); + } + } +} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCheckin.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCheckin.java new file mode 100644 index 00000000..9095f075 --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCheckin.java @@ -0,0 +1,101 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.tools.ant.taskdefs.optional.sos; + +import org.apache.tools.ant.types.Commandline; + +/** + * Commits and unlocks files in Visual SourceSafe via a SourceOffSite server. + * + * @ant.task name="soscheckin" category="scm" + */ +public class SOSCheckin extends SOS { + + /** + * The filename to act upon. + * If no file is specified then the task + * acts upon the project. + * + * @param filename The new file value + */ + public final void setFile(String filename) { + super.setInternalFilename(filename); + } + + /** + * Flag to recursively apply the action. Defaults to false. + * + * @param recursive True for recursive operation. + */ + public void setRecursive(boolean recursive) { + super.setInternalRecursive(recursive); + } + + /** + * The comment to apply to all files being labelled. + * + * @param comment The new comment value + */ + public void setComment(String comment) { + super.setInternalComment(comment); + } + + /** + * 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> + * + * @return Commandline the generated command to be executed + */ + protected Commandline buildCmdLine() { + commandLine = new Commandline(); + + // 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()); + } + + getRequiredAttributes(); + getOptionalAttributes(); + + // Look for a comment + if (getComment() != null) { + commandLine.createArgument().setValue(SOSCmd.FLAG_COMMENT); + commandLine.createArgument().setValue(getComment()); + } + return commandLine; + } +} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCheckout.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCheckout.java new file mode 100644 index 00000000..fab6fb9f --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCheckout.java @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.tools.ant.taskdefs.optional.sos; + +import org.apache.tools.ant.types.Commandline; + +/** + * Retrieves and locks files in Visual SourceSafe via a SourceOffSite server. + * + * @ant.task name="soscheckout" category="scm" + */ +public class SOSCheckout extends SOS { + + /** + * The filename to act upon. + * If no file is specified then the task + * acts upon the project. + * + * @param filename The new file value + */ + public final void setFile(String filename) { + super.setInternalFilename(filename); + } + + /** + * Flag to recursively apply the action. Defaults to false. + * + * @param recursive True for recursive operation. + */ + public void setRecursive(boolean recursive) { + super.setInternalRecursive(recursive); + } + + /** + * Build the command line <br> + * + * CheckOutFile required parameters: -server -name -password -database -project -file<br> + * CheckOutFile optional parameters: -workdir -verbose -nocache -nocompression -soshome<br> + * + * CheckOutProject required parameters: -server -name -password -database -project<br> + * CheckOutProject optional parameters:-workdir -recursive -verbose -nocache + * -nocompression -soshome<br> + * + * @return Commandline the generated command to be executed + */ + protected Commandline buildCmdLine() { + commandLine = new Commandline(); + + // 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()); + } + + getRequiredAttributes(); + getOptionalAttributes(); + + return commandLine; + } +} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCmd.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCmd.java new file mode 100644 index 00000000..3543c414 --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSCmd.java @@ -0,0 +1,81 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.tools.ant.taskdefs.optional.sos; + +/** + * Interface to hold constants used by the SOS tasks + * + */ +// CheckStyle:InterfaceIsTypeCheck OFF (bc) +public interface SOSCmd { + // soscmd Command options + /** The sos executable */ + String COMMAND_SOS_EXE = "soscmd"; + /** The get file command */ + String COMMAND_GET_FILE = "GetFile"; + /** The get project command */ + String COMMAND_GET_PROJECT = "GetProject"; + /** The checkout file command */ + String COMMAND_CHECKOUT_FILE = "CheckOutFile"; + /** The checkout project command */ + String COMMAND_CHECKOUT_PROJECT = "CheckOutProject"; + /** The checkin file command */ + String COMMAND_CHECKIN_FILE = "CheckInFile"; + /** The checkin project command */ + String COMMAND_CHECKIN_PROJECT = "CheckInProject"; + /** The get history command */ + String COMMAND_HISTORY = "GetFileHistory"; + /** The add label command */ + String COMMAND_LABEL = "AddLabel"; + /** The project prefix */ + String PROJECT_PREFIX = "$"; + + // soscmd Option flags + /** The command option */ + String FLAG_COMMAND = "-command"; + /** The database (vss server) option */ + String FLAG_VSS_SERVER = "-database"; + /** The username option */ + String FLAG_USERNAME = "-name"; + /** The password option */ + String FLAG_PASSWORD = "-password"; + /** The log option */ + String FLAG_COMMENT = "-log"; + /** The workdir option */ + String FLAG_WORKING_DIR = "-workdir"; + /** The recursive option */ + String FLAG_RECURSION = "-recursive"; + /** The revision option */ + String FLAG_VERSION = "-revision"; + /** The label option */ + String FLAG_LABEL = "-label"; + /** The no compression option */ + String FLAG_NO_COMPRESSION = "-nocompress"; + /** The no cache option */ + String FLAG_NO_CACHE = "-nocache"; + /** The server option */ + String FLAG_SOS_SERVER = "-server"; + /** The sos home option */ + String FLAG_SOS_HOME = "-soshome"; + /** The project option */ + String FLAG_PROJECT = "-project"; + /** The file option */ + String FLAG_FILE = "-file"; + /** The verbose option */ + String FLAG_VERBOSE = "-verbose"; +} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSGet.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSGet.java new file mode 100644 index 00000000..cdbf92bc --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSGet.java @@ -0,0 +1,116 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.tools.ant.taskdefs.optional.sos; + +import org.apache.tools.ant.types.Commandline; + +/** + * Retrieves a read-only copy of the specified project or file + * from Visual SourceSafe via a SourceOffSite server. + * + * @ant.task name="sosget" category="scm" + */ +public class SOSGet extends SOS { + + /** + * The Filename to act upon. + * 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. Defaults to false + * + * @param recursive True for recursive operation. + */ + public void setRecursive(boolean recursive) { + super.setInternalRecursive(recursive); + } + + /** + * Set the version number to get - + * only works with SOSGet on a file. + * + * @param version The new version value + */ + public void setVersion(String version) { + super.setInternalVersion(version); + } + + /** + * 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> + * + * GetFile required parameters: -server -name -password -database -project -file<br> + * GetFile optional parameters: -workdir -revision -verbose -nocache -nocompression -soshome<br> + * + * GetProject required parameters: -server -name -password -database -project<br> + * GetProject optional parameters: -label -workdir -recursive -verbose -nocache + * -nocompression -soshome<br> + * + * @return Commandline the generated command to be executed + */ + protected Commandline buildCmdLine() { + commandLine = new Commandline(); + + // 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()); + } + } + + getRequiredAttributes(); + getOptionalAttributes(); + + return commandLine; + } +} diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSLabel.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSLabel.java new file mode 100644 index 00000000..dd6b13a2 --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/sos/SOSLabel.java @@ -0,0 +1,91 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.tools.ant.taskdefs.optional.sos; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.types.Commandline; + +/** + * Labels Visual SourceSafe files via a SourceOffSite server. + * + * @ant.task name="soslabel" category="scm" + */ +public class SOSLabel extends SOS { + + /** + * The version number to label. + * + * @param version The new version value + */ + public void setVersion(String version) { + super.setInternalVersion(version); + } + + /** + * The label to apply the the files in SourceSafe. + * + * @param label The new label value + * + * @ant.attribute group="required" + */ + public void setLabel(String label) { + super.setInternalLabel(label); + } + + /** + * The comment to apply to all files being labelled. + * + * @param comment The new comment value + */ + public void setComment(String comment) { + super.setInternalComment(comment); + } + + /** + * Build the command line <br> + * AddLabel required parameters: -server -name -password -database -project -label<br> + * AddLabel optional parameters: -verbose -comment<br> + * + * @return Commandline the generated command to be executed + */ + protected Commandline buildCmdLine() { + commandLine = new Commandline(); + + // add -command AddLabel to the commandline + commandLine.createArgument().setValue(SOSCmd.FLAG_COMMAND); + commandLine.createArgument().setValue(SOSCmd.COMMAND_LABEL); + + getRequiredAttributes(); + + // a label is required + if (getLabel() == null) { + throw new BuildException("label attribute must be set!", getLocation()); + } + commandLine.createArgument().setValue(SOSCmd.FLAG_LABEL); + commandLine.createArgument().setValue(getLabel()); + + // -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/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/sos/package.html b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/sos/package.html new file mode 100644 index 00000000..a0538c21 --- /dev/null +++ b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/sos/package.html @@ -0,0 +1,29 @@ +<html> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<body> + <p> + Ant tasks for working with a SourceOffSite source control system. + </p> + <p> + The <SOSGet> Retreives file(s) from a SOS database<br> + The <SOSCheckin> Commits and unlocks file(s) in a SOS database<br> + The <SOSCheckout> Retreives and lock file(s) in a SOS database<br> + The <SOSLabel> Label a SOS database<br> + </p> +</body> +</html> |