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