001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: */
018:
019: package org.apache.tools.ant.taskdefs.optional.vss;
020:
021: import org.apache.tools.ant.BuildException;
022: import org.apache.tools.ant.types.Commandline;
023:
024: /**
025: * Performs Label commands to Microsoft Visual SourceSafe.
026: *
027: * @ant.task name="vsslabel" category="scm"
028: */
029: public class MSVSSLABEL extends MSVSS {
030:
031: /**
032: * Builds a command line to execute ss.
033: * @return The constructed commandline.
034: */
035: Commandline buildCmdLine() {
036: Commandline commandLine = new Commandline();
037:
038: // first off, make sure that we've got a command and a vssdir and a label ...
039: if (getVsspath() == null) {
040: throw new BuildException("vsspath attribute must be set!",
041: getLocation());
042: }
043:
044: String label = getLabel();
045: if (label.equals("")) {
046: String msg = "label attribute must be set!";
047: throw new BuildException(msg, getLocation());
048: }
049:
050: // build the command line from what we got the format is
051: // ss Label VSS items [-C] [-H] [-I-] [-Llabel] [-N] [-O] [-V] [-Y] [-?]
052: // as specified in the SS.EXE help
053: commandLine.setExecutable(getSSCommand());
054: commandLine.createArgument().setValue(COMMAND_LABEL);
055:
056: // VSS items
057: commandLine.createArgument().setValue(getVsspath());
058: // -C
059: commandLine.createArgument().setValue(getComment());
060: // -I- or -I-Y or -I-N
061: commandLine.createArgument().setValue(getAutoresponse());
062: // -L Specify the new label on the command line (instead of being prompted)
063: commandLine.createArgument().setValue(label);
064: // -V Label an existing file or project version
065: commandLine.createArgument().setValue(getVersion());
066: // -Y
067: commandLine.createArgument().setValue(getLogin());
068:
069: return commandLine;
070: }
071:
072: /**
073: * Label to apply in SourceSafe.
074: *
075: * @param label The label to apply.
076: *
077: * @ant.attribute group="required"
078: */
079: public void setLabel(String label) {
080: super .setInternalLabel(label);
081: }
082:
083: /**
084: * Version to label.
085: *
086: * @param version The version to label.
087: */
088: public void setVersion(String version) {
089: super .setInternalVersion(version);
090: }
091:
092: /**
093: * Comment to apply to files labeled in SourceSafe.
094: *
095: * @param comment The comment to apply in SourceSafe
096: */
097: public void setComment(String comment) {
098: super .setInternalComment(comment);
099: }
100:
101: /**
102: * Autoresponce behaviour. Valid options are Y and N.
103: *
104: * @param response The auto response value.
105: */
106: public void setAutoresponse(String response) {
107: super.setInternalAutoResponse(response);
108: }
109: }
|