01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: package org.apache.tools.ant.taskdefs.optional.sos;
19:
20: import org.apache.tools.ant.BuildException;
21: import org.apache.tools.ant.types.Commandline;
22:
23: /**
24: * Labels Visual SourceSafe files via a SourceOffSite server.
25: *
26: * @ant.task name="soslabel" category="scm"
27: */
28: public class SOSLabel extends SOS {
29:
30: /**
31: * The version number to label.
32: *
33: * @param version The new version value
34: */
35: public void setVersion(String version) {
36: super .setInternalVersion(version);
37: }
38:
39: /**
40: * The label to apply the the files in SourceSafe.
41: *
42: * @param label The new label value
43: *
44: * @ant.attribute group="required"
45: */
46: public void setLabel(String label) {
47: super .setInternalLabel(label);
48: }
49:
50: /**
51: * The comment to apply to all files being labelled.
52: *
53: * @param comment The new comment value
54: */
55: public void setComment(String comment) {
56: super .setInternalComment(comment);
57: }
58:
59: /**
60: * Build the command line <br>
61: * AddLabel required parameters: -server -name -password -database -project -label<br>
62: * AddLabel optional parameters: -verbose -comment<br>
63: *
64: * @return Commandline the generated command to be executed
65: */
66: protected Commandline buildCmdLine() {
67: commandLine = new Commandline();
68:
69: // add -command AddLabel to the commandline
70: commandLine.createArgument().setValue(SOSCmd.FLAG_COMMAND);
71: commandLine.createArgument().setValue(SOSCmd.COMMAND_LABEL);
72:
73: getRequiredAttributes();
74:
75: // a label is required
76: if (getLabel() == null) {
77: throw new BuildException("label attribute must be set!",
78: getLocation());
79: }
80: commandLine.createArgument().setValue(SOSCmd.FLAG_LABEL);
81: commandLine.createArgument().setValue(getLabel());
82:
83: // -verbose
84: commandLine.createArgument().setValue(getVerbose());
85: // Look for a comment
86: if (getComment() != null) {
87: commandLine.createArgument().setValue(SOSCmd.FLAG_COMMENT);
88: commandLine.createArgument().setValue(getComment());
89: }
90: return commandLine;
91: }
92: }
|