You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Sequential.java 2.5 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. */
  18. package org.apache.tools.ant.taskdefs;
  19. import java.util.Iterator;
  20. import java.util.Vector;
  21. import org.apache.tools.ant.BuildException;
  22. import org.apache.tools.ant.Task;
  23. import org.apache.tools.ant.TaskContainer;
  24. import org.apache.tools.ant.property.LocalProperties;
  25. /**
  26. * Sequential is a container task - it can contain other Ant tasks. The nested
  27. * tasks are simply executed in sequence. Sequential's primary use is to support
  28. * the sequential execution of a subset of tasks within the {@link Parallel Parallel Task}
  29. * <p>
  30. * The sequential task has no attributes and does not support any nested
  31. * elements apart from Ant tasks. Any valid Ant task may be embedded within the
  32. * sequential task.</p>
  33. *
  34. * @since Ant 1.4
  35. * @ant.task category="control"
  36. */
  37. public class Sequential extends Task implements TaskContainer {
  38. /** Optional Vector holding the nested tasks */
  39. private Vector nestedTasks = new Vector();
  40. /**
  41. * Add a nested task to Sequential.
  42. * <p>
  43. * @param nestedTask Nested task to execute Sequential
  44. * <p>
  45. */
  46. public void addTask(Task nestedTask) {
  47. nestedTasks.addElement(nestedTask);
  48. }
  49. /**
  50. * Execute all nestedTasks.
  51. *
  52. * @throws BuildException if one of the nested tasks fails.
  53. */
  54. public void execute() throws BuildException {
  55. LocalProperties localProperties
  56. = LocalProperties.get(getProject());
  57. localProperties.enterScope();
  58. try {
  59. for (Iterator i = nestedTasks.iterator(); i.hasNext();) {
  60. Task nestedTask = (Task) i.next();
  61. nestedTask.perform();
  62. }
  63. } finally {
  64. localProperties.exitScope();
  65. }
  66. }
  67. }