1. /*
  2. * Copyright 2002-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. import org.apache.tools.ant.types.Path;
  21. /**
  22. * Performs Add commands to Microsoft Visual SourceSafe.
  23. *
  24. *
  25. * @ant.task name="vssadd" category="scm"
  26. */
  27. public class MSVSSADD extends MSVSS {
  28. private String m_LocalPath = null;
  29. /**
  30. * Builds a command line to execute ss.
  31. * @return The constructed commandline.
  32. */
  33. protected Commandline buildCmdLine() {
  34. Commandline commandLine = new Commandline();
  35. // first off, make sure that we've got a command and a localPath ...
  36. if (getLocalpath() == null) {
  37. String msg = "localPath attribute must be set!";
  38. throw new BuildException(msg, getLocation());
  39. }
  40. // build the command line from what we got the format is
  41. // ss Add VSS items [-B] [-C] [-D-] [-H] [-I-] [-K] [-N] [-O] [-R] [-W] [-Y] [-?]
  42. // as specified in the SS.EXE help
  43. commandLine.setExecutable(getSSCommand());
  44. commandLine.createArgument().setValue(COMMAND_ADD);
  45. // VSS items
  46. commandLine.createArgument().setValue(getLocalpath());
  47. // -I- or -I-Y or -I-N
  48. commandLine.createArgument().setValue(getAutoresponse());
  49. // -R
  50. commandLine.createArgument().setValue(getRecursive());
  51. // -W
  52. commandLine.createArgument().setValue(getWritable());
  53. // -Y
  54. commandLine.createArgument().setValue(getLogin());
  55. // -C
  56. commandLine.createArgument().setValue(getComment());
  57. return commandLine;
  58. }
  59. /**
  60. * Returns the local path without the flag.; required
  61. * @todo See why this returns the local path without the flag.
  62. * @return The local path value.
  63. */
  64. protected String getLocalpath() {
  65. return m_LocalPath;
  66. }
  67. /**
  68. * Add files recursively. Defaults to false.
  69. *
  70. * @param recursive The boolean value for recursive.
  71. */
  72. public void setRecursive(boolean recursive) {
  73. super.setInternalRecursive(recursive);
  74. }
  75. /**
  76. * Unset the READ-ONLY flag on local copies of files added to VSS. Defaults to false.
  77. *
  78. * @param writable The boolean value for writable.
  79. */
  80. public final void setWritable(boolean writable) {
  81. super.setInternalWritable(writable);
  82. }
  83. /**
  84. * Autoresponce behaviour. Valid options are Y and N.
  85. *
  86. * @param response The auto response value.
  87. */
  88. public void setAutoresponse(String response) {
  89. super.setInternalAutoResponse(response);
  90. }
  91. /**
  92. * Comment to apply to files added to SourceSafe.
  93. *
  94. * @param comment The comment to apply in SourceSafe
  95. */
  96. public void setComment(String comment) {
  97. super.setInternalComment(comment);
  98. }
  99. /**
  100. * Override the project working directory.
  101. *
  102. * @param localPath The path on disk.
  103. */
  104. public void setLocalpath(Path localPath) {
  105. m_LocalPath = localPath.toString();
  106. }
  107. }