KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > taskdefs > optional > vss > MSVSSADD


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */

18
19 package org.apache.tools.ant.taskdefs.optional.vss;
20
21 import org.apache.tools.ant.BuildException;
22 import org.apache.tools.ant.types.Commandline;
23 import org.apache.tools.ant.types.Path;
24
25 /**
26  * Performs Add commands to Microsoft Visual SourceSafe.
27  *
28  * @ant.task name="vssadd" category="scm"
29  */

30 public class MSVSSADD extends MSVSS {
31
32     private String JavaDoc localPath = null;
33
34     /**
35      * Builds a command line to execute ss.
36      * @return The constructed commandline.
37      */

38     protected Commandline buildCmdLine() {
39         Commandline commandLine = new Commandline();
40
41         // first off, make sure that we've got a command and a localPath ...
42
if (getLocalpath() == null) {
43             String JavaDoc msg = "localPath attribute must be set!";
44             throw new BuildException(msg, getLocation());
45         }
46
47         // build the command line from what we got the format is
48
// ss Add VSS items [-B] [-C] [-D-] [-H] [-I-] [-K] [-N] [-O] [-R] [-W] [-Y] [-?]
49
// as specified in the SS.EXE help
50
commandLine.setExecutable(getSSCommand());
51         commandLine.createArgument().setValue(COMMAND_ADD);
52
53         // VSS items
54
commandLine.createArgument().setValue(getLocalpath());
55         // -I- or -I-Y or -I-N
56
commandLine.createArgument().setValue(getAutoresponse());
57         // -R
58
commandLine.createArgument().setValue(getRecursive());
59         // -W
60
commandLine.createArgument().setValue(getWritable());
61         // -Y
62
commandLine.createArgument().setValue(getLogin());
63         // -C
64
commandLine.createArgument().setValue(getComment());
65
66         return commandLine;
67     }
68
69     /**
70      * Returns the local path without the flag.; required
71      * @todo See why this returns the local path without the flag.
72      * @return The local path value.
73      */

74     protected String JavaDoc getLocalpath() {
75         return localPath;
76     }
77
78     /**
79      * Add files recursively. Defaults to false.
80      *
81      * @param recursive The boolean value for recursive.
82      */

83     public void setRecursive(boolean recursive) {
84         super.setInternalRecursive(recursive);
85     }
86
87     /**
88      * Unset the READ-ONLY flag on local copies of files added to VSS. Defaults to false.
89      *
90      * @param writable The boolean value for writable.
91      */

92     public final void setWritable(boolean writable) {
93         super.setInternalWritable(writable);
94     }
95
96     /**
97      * Autoresponce behaviour. Valid options are Y and N.
98      *
99      * @param response The auto response value.
100      */

101     public void setAutoresponse(String JavaDoc 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 JavaDoc 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 }
123
Popular Tags