KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xdoclet > modules > maven > MavenpluginSubTask


1 /*
2  * Copyright (c) 2001, 2002 The XDoclet team
3  * All rights reserved.
4  */

5 package xdoclet.modules.maven;
6
7
8 import java.util.ArrayList JavaDoc;
9 import java.util.Arrays JavaDoc;
10 import java.util.Iterator JavaDoc;
11 import java.util.List JavaDoc;
12
13 import xdoclet.XDocletException;
14 import xdoclet.modules.doc.AntdocSubTask;
15 import xdoclet.template.TemplateEngine;
16 import xdoclet.template.TemplateException;
17 import xjavadoc.XJavaDoc;
18
19 /**
20  * Generates xdoclet Maven plugin.
21  *
22  * @author Ara Abrahamian
23  * @created 21 September 2002
24  * @version $Revision: 1.4 $
25  * @ant.element display-name="Maven plugin" name="mavenplugin" parent="xdoclet.DocletTask"
26  */

27 public class MavenpluginSubTask extends AntdocSubTask
28 {
29     private static String JavaDoc MAVENPLUGIN_TEMPLATE_FILE = "resources/mavenplugin.xdt";
30
31     public String JavaDoc getDestinationFile()
32     {
33         //return "{0}.xml";
34
return "plugin.jelly";
35     }
36
37     public void init(XJavaDoc xJavaDoc) throws XDocletException
38     {
39         super.init(xJavaDoc);
40
41         setTemplateURL(getClass().getResource(MAVENPLUGIN_TEMPLATE_FILE));
42
43         setDestinationFile("plugin.jelly");
44     }
45
46     protected void startProcessForAll() throws XDocletException
47     {
48         MavenpluginTagsHandler mavenPluginTagsHandler = null;
49
50         try {
51             mavenPluginTagsHandler = (MavenpluginTagsHandler) TemplateEngine.getEngineInstance().getTagHandlerFor("Mavenplugin");
52         }
53         catch (TemplateException e) {
54             throw new XDocletException(e.getMessage());
55         }
56
57         mavenPluginTagsHandler.setTasks(getTasks());
58
59         super.startProcessForAll();
60     }
61
62     private List JavaDoc getTasks()
63     {
64         List JavaDoc tasks = new ArrayList JavaDoc();
65
66         List JavaDoc to_iter = Arrays.asList(classToAntElementMap.values().toArray());
67
68         for (Iterator JavaDoc i = to_iter.iterator(); i.hasNext(); ) {
69             Element element = (Element) i.next();
70
71             if (element.getXClass().isA("xdoclet.DocletTask"))
72                 tasks.add(element);
73         }
74
75         return tasks;
76     }
77 }
78
Popular Tags