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 Add commands to Microsoft Visual SourceSafe.
027: *
028: * @ant.task name="vssadd" category="scm"
029: */
030: public class MSVSSADD extends MSVSS {
031:
032: private String localPath = null;
033:
034: /**
035: * Builds a command line to execute ss.
036: * @return The constructed commandline.
037: */
038: protected Commandline buildCmdLine() {
039: Commandline commandLine = new Commandline();
040:
041: // first off, make sure that we've got a command and a localPath ...
042: if (getLocalpath() == null) {
043: String msg = "localPath attribute must be set!";
044: throw new BuildException(msg, getLocation());
045: }
046:
047: // build the command line from what we got the format is
048: // ss Add VSS items [-B] [-C] [-D-] [-H] [-I-] [-K] [-N] [-O] [-R] [-W] [-Y] [-?]
049: // as specified in the SS.EXE help
050: commandLine.setExecutable(getSSCommand());
051: commandLine.createArgument().setValue(COMMAND_ADD);
052:
053: // VSS items
054: commandLine.createArgument().setValue(getLocalpath());
055: // -I- or -I-Y or -I-N
056: commandLine.createArgument().setValue(getAutoresponse());
057: // -R
058: commandLine.createArgument().setValue(getRecursive());
059: // -W
060: commandLine.createArgument().setValue(getWritable());
061: // -Y
062: commandLine.createArgument().setValue(getLogin());
063: // -C
064: commandLine.createArgument().setValue(getComment());
065:
066: return commandLine;
067: }
068:
069: /**
070: * Returns the local path without the flag.; required
071: * @todo See why this returns the local path without the flag.
072: * @return The local path value.
073: */
074: protected String getLocalpath() {
075: return localPath;
076: }
077:
078: /**
079: * Add files recursively. Defaults to false.
080: *
081: * @param recursive The boolean value for recursive.
082: */
083: public void setRecursive(boolean recursive) {
084: super .setInternalRecursive(recursive);
085: }
086:
087: /**
088: * Unset the READ-ONLY flag on local copies of files added to VSS. Defaults to false.
089: *
090: * @param writable The boolean value for writable.
091: */
092: public final void setWritable(boolean writable) {
093: super .setInternalWritable(writable);
094: }
095:
096: /**
097: * Autoresponce behaviour. Valid options are Y and N.
098: *
099: * @param response The auto response value.
100: */
101: public void setAutoresponse(String response) {
102: super .setInternalAutoResponse(response);
103: }
104:
105: /**
106: * Comment to apply to files added to SourceSafe.
107: *
108: * @param comment The comment to apply in SourceSafe
109: */
110: public void setComment(String comment) {
111: super .setInternalComment(comment);
112: }
113:
114: /**
115: * Override the project working directory.
116: *
117: * @param localPath The path on disk.
118: */
119: public void setLocalpath(Path localPath) {
120: this.localPath = localPath.toString();
121: }
122: }
|