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. import org.apache.tools.ant.types.Path;
  21. /**
  22. * Performs CheckOut commands to Microsoft Visual SourceSafe.
  23. *
  24. *
  25. * @ant.task name="vsscheckout" category="scm"
  26. * @ant.attribute.group name="vdl" description="Only one of version, date or label"
  27. */
  28. public class MSVSSCHECKOUT extends MSVSS {
  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 vssdir ...
  36. if (getVsspath() == null) {
  37. String msg = "vsspath 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 Checkout VSS items [-G] [-C] [-H] [-I-] [-N] [-O] [-R] [-V] [-Y] [-?]
  42. // as specified in the SS.EXE help
  43. commandLine.setExecutable(getSSCommand());
  44. commandLine.createArgument().setValue(COMMAND_CHECKOUT);
  45. // VSS items
  46. commandLine.createArgument().setValue(getVsspath());
  47. // -GL
  48. commandLine.createArgument().setValue(getLocalpath());
  49. // -I- or -I-Y or -I-N
  50. commandLine.createArgument().setValue(getAutoresponse());
  51. // -R
  52. commandLine.createArgument().setValue(getRecursive());
  53. // -V
  54. commandLine.createArgument().setValue(getVersionDateLabel());
  55. // -Y
  56. commandLine.createArgument().setValue(getLogin());
  57. // -G
  58. commandLine.createArgument().setValue(getFileTimeStamp());
  59. // -GWS or -GWR
  60. commandLine.createArgument().setValue(getWritableFiles());
  61. // -G-
  62. commandLine.createArgument().setValue(getGetLocalCopy());
  63. return commandLine;
  64. }
  65. /**
  66. * Override the project working directory.
  67. *
  68. * @param localPath The path on disk.
  69. */
  70. public void setLocalpath(Path localPath) {
  71. super.setInternalLocalPath(localPath.toString());
  72. }
  73. /**
  74. * Check-out files recursively. Defaults to false.
  75. *
  76. * @param recursive The boolean value for recursive.
  77. */
  78. public void setRecursive(boolean recursive) {
  79. super.setInternalRecursive(recursive);
  80. }
  81. /**
  82. * Version to check-out.
  83. *
  84. * @param version The version to check-out.
  85. *
  86. * @ant.attribute group="vdl"
  87. */
  88. public void setVersion(String version) {
  89. super.setInternalVersion(version);
  90. }
  91. /**
  92. * Date to check-out.
  93. *
  94. * @param date The date to check-out.
  95. *
  96. * @ant.attribute group="vdl"
  97. */
  98. public void setDate(String date) {
  99. super.setInternalDate(date);
  100. }
  101. /**
  102. * Label to check-out.
  103. *
  104. * @param label The label to check-out.
  105. *
  106. * @ant.attribute group="vdl"
  107. */
  108. public void setLabel(String label) {
  109. super.setInternalLabel(label);
  110. }
  111. /**
  112. * Autoresponce behaviour. Valid options are Y and N.
  113. *
  114. * @param response The auto response value.
  115. */
  116. public void setAutoresponse(String response) {
  117. super.setInternalAutoResponse(response);
  118. }
  119. /**
  120. * Date and time stamp given to the local copy. Defaults to <code>current</code>.
  121. *
  122. * @param timestamp The file time stamping behaviour.
  123. */
  124. public void setFileTimeStamp(CurrentModUpdated timestamp) {
  125. super.setInternalFileTimeStamp(timestamp);
  126. }
  127. /**
  128. * Action taken when local files are writable. Defaults to <code>fail</code>.
  129. * <p>
  130. * Due to ss.exe returning with an exit code of '100' for both errors and when
  131. * a file has been skipped, <code>failonerror</code> is set to false when using
  132. * the <code>skip</code> option.
  133. * </p>
  134. *
  135. * @param files The writable files behaviour
  136. */
  137. public void setWritableFiles(WritableFiles files) {
  138. super.setInternalWritableFiles(files);
  139. }
  140. /**
  141. * Retrieve a local copy during a checkout. Defaults to true.
  142. *
  143. * @param get The get local copy behaviour
  144. */
  145. public void setGetLocalCopy(boolean get) {
  146. super.setInternalGetLocalCopy(get);
  147. }
  148. }