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.perforce;
  18. import org.apache.tools.ant.BuildException;
  19. /** Checkout files for deletion.
  20. *
  21. * Example Usage:<br>
  22. * <p4delete change="${p4.change}" view="//depot/project/foo.txt" /><br>
  23. *
  24. * Simple re-write of P4Edit changing 'edit' to 'delete'.<br>
  25. *
  26. * @todo What to do if file is already open in one of our changelists perhaps
  27. * (See also {@link P4Edit P4Edit})?<br>
  28. *
  29. *
  30. * @ant.task category="scm"
  31. */
  32. public class P4Delete extends P4Base {
  33. /**
  34. * number of the change list to work on
  35. */
  36. public String change = null;
  37. /**
  38. * An existing changelist number for the deletion; optional
  39. * but strongly recommended.
  40. * @param change the number of a change list
  41. */
  42. public void setChange(String change) {
  43. this.change = change;
  44. }
  45. /**
  46. * executes the p4 delete task
  47. * @throws BuildException if there is no view specified
  48. */
  49. public void execute() throws BuildException {
  50. if (change != null) {
  51. P4CmdOpts = "-c " + change;
  52. }
  53. if (P4View == null) {
  54. throw new BuildException("No view specified to delete");
  55. }
  56. execP4Command("-s delete " + P4CmdOpts + " " + P4View, new SimpleP4OutputHandler(this));
  57. }
  58. }