1   /*
2    * Copyright 2002,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  package org.apache.commons.jelly.ant.task;
17  
18  import org.apache.tools.ant.Task;
19  import org.apache.tools.ant.BuildException;
20  
21  /*
22  
23  <taskdef
24     name="nested"
25     classname="jellybug.NestedTask"
26  >
27     <classpath>
28        <pathelement path="somewhere"/>
29     </classpath>
30  </taskdef>
31  
32  <nested>
33     <ding/>
34     <dang/>
35     <dong/>
36     <hiphop/>
37     <wontstop/>
38     <tillyoudrop/>
39     <hipHop/>
40     <wontStop/>
41     <tillYouDrop/>
42  </nested>
43  
44  Ant:
45     [nested] a
46     [nested] b
47     [nested] c
48     [nested] d
49     [nested] e
50     [nested] f
51     [nested] g
52     [nested] h
53     [nested] i
54  
55  Maven/Jelly:
56  a
57  b
58  c
59  d
60  e
61  f
62  g
63  h
64  i
65  
66  */
67  
68  /***
69   * A sample Task to test out the Ant introspection logic
70   *
71   * @author Aslak Hellesøy (aslak.hellesoy@bekk.no)
72   * @version $Revision: 1.8 $
73   */
74  public class DummyTask extends Task {
75      private int i = 0;
76      private String[] messages = { "a", "b", "c", "d", "e", "f", "g", "h", "i" };
77      private boolean force;
78  
79      public void execute() throws BuildException {
80          if (!force) {
81              throw new BuildException("Should have set force to be true!");
82          }
83      }
84  
85      public Thingy createDing() {
86          System.out.println("createDing: " + messages[i++]);
87          return new Thingy();
88      }
89  
90      public void addDang(Thingy thingy) {
91          System.out.println("addDang: " + messages[i++]);
92      }
93  
94      public void addConfiguredDong(Thingy thingy) {
95          System.out.println("addConfiguredDong: " + messages[i++]);
96      }
97  
98      public Thingy createHipHop() {
99          System.out.println("createHipHop: " + messages[i++]);
100         return new Thingy();
101     }
102 
103     public void addWontStop(Thingy thingy) {
104         System.out.println("addWontStop: " + messages[i++]);
105     }
106 
107     public void addConfiguredTillYouDrop(Thingy thingy) {
108         System.out.println("addConfiguredTillYouDrop: " + messages[i++]);
109     }
110 
111     public boolean isForce() {
112         return force;
113     }
114 
115     public void setForce(boolean force) {
116         this.force = force;
117     }
118 
119     public static class Thingy {
120     }
121 }