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: import org.apache.tools.ant.types.Path;
024:
025: /**
026: * Performs CheckOut commands to Microsoft Visual SourceSafe.
027: *
028: * @ant.task name="vsscheckout" category="scm"
029: * @ant.attribute.group name="vdl" description="Only one of version, date or label"
030: */
031: public class MSVSSCHECKOUT extends MSVSS {
032:
033: /**
034: * Builds a command line to execute ss.
035: * @return The constructed commandline.
036: */
037: protected Commandline buildCmdLine() {
038: Commandline commandLine = new Commandline();
039:
040: // first off, make sure that we've got a command and a vssdir ...
041: if (getVsspath() == null) {
042: String msg = "vsspath attribute must be set!";
043: throw new BuildException(msg, getLocation());
044: }
045:
046: // build the command line from what we got the format is
047: // ss Checkout VSS items [-G] [-C] [-H] [-I-] [-N] [-O] [-R] [-V] [-Y] [-?]
048: // as specified in the SS.EXE help
049: commandLine.setExecutable(getSSCommand());
050: commandLine.createArgument().setValue(COMMAND_CHECKOUT);
051:
052: // VSS items
053: commandLine.createArgument().setValue(getVsspath());
054: // -GL
055: commandLine.createArgument().setValue(getLocalpath());
056: // -I- or -I-Y or -I-N
057: commandLine.createArgument().setValue(getAutoresponse());
058: // -R
059: commandLine.createArgument().setValue(getRecursive());
060: // -V
061: commandLine.createArgument().setValue(getVersionDateLabel());
062: // -Y
063: commandLine.createArgument().setValue(getLogin());
064: // -G
065: commandLine.createArgument().setValue(getFileTimeStamp());
066: // -GWS or -GWR
067: commandLine.createArgument().setValue(getWritableFiles());
068: // -G-
069: commandLine.createArgument().setValue(getGetLocalCopy());
070:
071: return commandLine;
072: }
073:
074: /**
075: * Override the project working directory.
076: *
077: * @param localPath The path on disk.
078: */
079: public void setLocalpath(Path localPath) {
080: super .setInternalLocalPath(localPath.toString());
081: }
082:
083: /**
084: * Check-out files recursively. Defaults to false.
085: *
086: * @param recursive The boolean value for recursive.
087: */
088: public void setRecursive(boolean recursive) {
089: super .setInternalRecursive(recursive);
090: }
091:
092: /**
093: * Version to check-out.
094: *
095: * @param version The version to check-out.
096: *
097: * @ant.attribute group="vdl"
098: */
099: public void setVersion(String version) {
100: super .setInternalVersion(version);
101: }
102:
103: /**
104: * Date to check-out.
105: *
106: * @param date The date to check-out.
107: *
108: * @ant.attribute group="vdl"
109: */
110: public void setDate(String date) {
111: super .setInternalDate(date);
112: }
113:
114: /**
115: * Label to check-out.
116: *
117: * @param label The label to check-out.
118: *
119: * @ant.attribute group="vdl"
120: */
121: public void setLabel(String label) {
122: super .setInternalLabel(label);
123: }
124:
125: /**
126: * Autoresponce behaviour. Valid options are Y and N.
127: *
128: * @param response The auto response value.
129: */
130: public void setAutoresponse(String response) {
131: super .setInternalAutoResponse(response);
132: }
133:
134: /**
135: * Date and time stamp given to the local copy. Defaults to <code>current</code>.
136: *
137: * @param timestamp The file time stamping behaviour.
138: */
139: public void setFileTimeStamp(CurrentModUpdated timestamp) {
140: super .setInternalFileTimeStamp(timestamp);
141: }
142:
143: /**
144: * Action taken when local files are writable. Defaults to <code>fail</code>.
145: * <p>
146: * Due to ss.exe returning with an exit code of '100' for both errors and when
147: * a file has been skipped, <code>failonerror</code> is set to false when using
148: * the <code>skip</code> option.
149: * </p>
150: *
151: * @param files The writable files behaviour
152: */
153: public void setWritableFiles(WritableFiles files) {
154: super .setInternalWritableFiles(files);
155: }
156:
157: /**
158: * Retrieve a local copy during a checkout. Defaults to true.
159: *
160: * @param get The get local copy behaviour
161: */
162: public void setGetLocalCopy(boolean get) {
163: super.setInternalGetLocalCopy(get);
164: }
165: }
|