1. /*
  2. * Copyright 2000-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. * Perform Get commands from Microsoft Visual SourceSafe.
  23. *
  24. * @ant.task name="vssget" category="scm"
  25. * @ant.attribute.group name="vdl" description="Only one of version, date or label"
  26. */
  27. public class MSVSSGET extends MSVSS {
  28. /**
  29. * Builds a command line to execute ss.
  30. * @return The constructed commandline.
  31. */
  32. Commandline buildCmdLine() {
  33. Commandline commandLine = new Commandline();
  34. // build the command line from what we got the format is
  35. // ss Get VSS items [-G] [-H] [-I-] [-N] [-O] [-R] [-V] [-W] [-Y] [-?]
  36. // as specified in the SS.EXE help
  37. commandLine.setExecutable(getSSCommand());
  38. commandLine.createArgument().setValue(COMMAND_GET);
  39. if (getVsspath() == null) {
  40. throw new BuildException("vsspath attribute must be set!", getLocation());
  41. }
  42. commandLine.createArgument().setValue(getVsspath());
  43. // -GL
  44. commandLine.createArgument().setValue(getLocalpath());
  45. // -I- or -I-Y or -I-N
  46. commandLine.createArgument().setValue(getAutoresponse());
  47. // -O-
  48. commandLine.createArgument().setValue(getQuiet());
  49. // -R
  50. commandLine.createArgument().setValue(getRecursive());
  51. // -V
  52. commandLine.createArgument().setValue(getVersionDateLabel());
  53. // -W
  54. commandLine.createArgument().setValue(getWritable());
  55. // -Y
  56. commandLine.createArgument().setValue(getLogin());
  57. // -G
  58. commandLine.createArgument().setValue(getFileTimeStamp());
  59. // -GWS or -GWR
  60. commandLine.createArgument().setValue(getWritableFiles());
  61. return commandLine;
  62. }
  63. /**
  64. * Override the project working directory.
  65. *
  66. * @param localPath The path on disk.
  67. */
  68. public void setLocalpath(Path localPath) {
  69. super.setInternalLocalPath(localPath.toString());
  70. }
  71. /**
  72. * Get files recursively. Defaults to false.
  73. *
  74. * @param recursive The boolean value for recursive.
  75. */
  76. public final void setRecursive(boolean recursive) {
  77. super.setInternalRecursive(recursive);
  78. }
  79. /**
  80. * Enable quiet mode. Defaults to false.
  81. *
  82. * @param quiet The boolean value for quiet.
  83. */
  84. public final void setQuiet (boolean quiet) {
  85. super.setInternalQuiet(quiet);
  86. }
  87. /**
  88. * Unset the READ-ONLY flag on files retrieved from 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. * Version to get.
  97. *
  98. * @param version The version to get.
  99. *
  100. * @ant.attribute group="vdl"
  101. */
  102. public void setVersion(String version) {
  103. super.setInternalVersion(version);
  104. }
  105. /**
  106. * Date to get.
  107. *
  108. * @param date The date to get.
  109. *
  110. * @ant.attribute group="vdl"
  111. */
  112. public void setDate(String date) {
  113. super.setInternalDate(date);
  114. }
  115. /**
  116. * Label to get.
  117. *
  118. * @param label The label to get.
  119. *
  120. * @ant.attribute group="vdl"
  121. */
  122. public void setLabel(String label) {
  123. super.setInternalLabel(label);
  124. }
  125. /**
  126. * Autoresponce behaviour. Valid options are Y and N.
  127. *
  128. * @param response The auto response value.
  129. */
  130. public void setAutoresponse(String response) {
  131. super.setInternalAutoResponse(response);
  132. }
  133. /**
  134. * Date and time stamp given to the local copy. Defaults to <code>current</code>.
  135. *
  136. * @param timestamp The file time stamping behaviour.
  137. */
  138. public void setFileTimeStamp(CurrentModUpdated timestamp) {
  139. super.setInternalFileTimeStamp(timestamp);
  140. }
  141. /**
  142. * Action taken when local files are writable. Defaults to <code>fail</code>.
  143. * <p>
  144. * Due to ss.exe returning with an exit code of '100' for both errors and when
  145. * a file has been skipped, <code>failonerror</code> is set to false when using
  146. * the <code>skip</code> option.
  147. *
  148. * @param files
  149. */
  150. public void setWritableFiles(WritableFiles files) {
  151. super.setInternalWritableFiles(files);
  152. }
  153. }