1. /*
  2. * Copyright 2001-2004 The Apache Software Foundation
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. *
  16. */
  17. package org.apache.tools.ant.taskdefs.optional.vss;
  18. import org.apache.tools.ant.BuildException;
  19. import org.apache.tools.ant.types.Commandline;
  20. /**
  21. * Performs Label commands to Microsoft Visual SourceSafe.
  22. *
  23. * @ant.task name="vsslabel" category="scm"
  24. */
  25. public class MSVSSLABEL extends MSVSS {
  26. /**
  27. * Builds a command line to execute ss.
  28. * @return The constructed commandline.
  29. */
  30. Commandline buildCmdLine() {
  31. Commandline commandLine = new Commandline();
  32. // first off, make sure that we've got a command and a vssdir and a label ...
  33. if (getVsspath() == null) {
  34. throw new BuildException("vsspath attribute must be set!", getLocation());
  35. }
  36. String label = getLabel();
  37. if (label.equals("")) {
  38. String msg = "label attribute must be set!";
  39. throw new BuildException(msg, getLocation());
  40. }
  41. // build the command line from what we got the format is
  42. // ss Label VSS items [-C] [-H] [-I-] [-Llabel] [-N] [-O] [-V] [-Y] [-?]
  43. // as specified in the SS.EXE help
  44. commandLine.setExecutable(getSSCommand());
  45. commandLine.createArgument().setValue(COMMAND_LABEL);
  46. // VSS items
  47. commandLine.createArgument().setValue(getVsspath());
  48. // -C
  49. commandLine.createArgument().setValue(getComment());
  50. // -I- or -I-Y or -I-N
  51. commandLine.createArgument().setValue(getAutoresponse());
  52. // -L Specify the new label on the command line (instead of being prompted)
  53. commandLine.createArgument().setValue(label);
  54. // -V Label an existing file or project version
  55. commandLine.createArgument().setValue(getVersion());
  56. // -Y
  57. commandLine.createArgument().setValue(getLogin());
  58. return commandLine;
  59. }
  60. /**
  61. * Label to apply in SourceSafe.
  62. *
  63. * @param label The label to apply.
  64. *
  65. * @ant.attribute group="required"
  66. */
  67. public void setLabel(String label) {
  68. super.setInternalLabel(label);
  69. }
  70. /**
  71. * Version to label.
  72. *
  73. * @param version The version to label.
  74. */
  75. public void setVersion(String version) {
  76. super.setInternalVersion(version);
  77. }
  78. /**
  79. * Comment to apply to files labeled in SourceSafe.
  80. *
  81. * @param comment The comment to apply in SourceSafe
  82. */
  83. public void setComment(String comment) {
  84. super.setInternalComment(comment);
  85. }
  86. /**
  87. * Autoresponce behaviour. Valid options are Y and N.
  88. *
  89. * @param response The auto response value.
  90. */
  91. public void setAutoresponse(String response) {
  92. super.setInternalAutoResponse(response);
  93. }
  94. }