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;
  18. import java.util.Enumeration;
  19. import java.util.Vector;
  20. import org.apache.tools.ant.BuildException;
  21. import org.apache.tools.ant.Task;
  22. import org.apache.tools.ant.TaskContainer;
  23. /**
  24. * Sequential is a container task - it can contain other Ant tasks. The nested
  25. * tasks are simply executed in sequence. Sequential's primary use is to support
  26. * the sequential execution of a subset of tasks within the {@link Parallel Parallel Task}
  27. * <p>
  28. * The sequential task has no attributes and does not support any nested
  29. * elements apart from Ant tasks. Any valid Ant task may be embedded within the
  30. * sequential task.</p>
  31. * @since Ant 1.4
  32. * @ant.task category="control"
  33. */
  34. public class Sequential extends Task
  35. implements TaskContainer {
  36. /** Optional Vector holding the nested tasks */
  37. private Vector nestedTasks = new Vector();
  38. /**
  39. * Add a nested task to Sequential.
  40. * <p>
  41. * @param nestedTask Nested task to execute Sequential
  42. * <p>
  43. */
  44. public void addTask(Task nestedTask) {
  45. nestedTasks.addElement(nestedTask);
  46. }
  47. /**
  48. * Execute all nestedTasks.
  49. *
  50. * @throws BuildException if one of the nested tasks fails.
  51. */
  52. public void execute() throws BuildException {
  53. for (Enumeration e = nestedTasks.elements(); e.hasMoreElements();) {
  54. Task nestedTask = (Task) e.nextElement();
  55. nestedTask.perform();
  56. }
  57. }
  58. }