KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > idaremedia > antx > flowcontrol > call > StepLauncherInstallTask


1 /**
2  * $Id: StepLauncherInstallTask.java 180 2007-03-15 12:56:38Z ssmc $
3  * Copyright 2004 iDare Media, Inc. All rights reserved.
4  *
5  * Originally written by iDare Media, Inc. for release into the public domain. This
6  * library, source form and binary form, is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public License (LGPL) as published
8  * by the Free Software Foundation; either version 2.1 of the License, or (at your option)
9  * any later version.<p>
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13  * See the GNU LGPL for more details.<p>
14  *
15  * You should have received a copy of the GNU Lesser General Public License along with this
16  * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite
17  * 330, Boston, MA 02111-1307 USA. The GNU LGPL can be found online at
18  * http://www.fsf.org/copyleft/lesser.html<p>
19  *
20  * This product has been influenced by several projects within the open-source community.
21  * The JWare developers wish to acknowledge the open-source community's support. For more
22  * information regarding the open-source products used within JWare, please visit the
23  * JWare website.
24  *----------------------------------------------------------------------------------------*
25  * WEBSITE- http://www.jware.info EMAIL- inquiries@jware.info
26  *----------------------------------------------------------------------------------------*
27  **/

28
29 package com.idaremedia.antx.flowcontrol.call;
30
31 import java.util.Map JavaDoc;
32
33 import org.apache.tools.ant.Project;
34 import org.apache.tools.ant.Target;
35
36 import com.idaremedia.antx.AntX;
37 import com.idaremedia.antx.AssertableLibDefinition;
38 import com.idaremedia.antx.FixtureInitializer;
39 import com.idaremedia.antx.flowcontrol.FlowConstants;
40
41 /**
42  * Convenience task that dynamically installs the AntX {@linkplain StepLauncher step
43  * launcher} target.
44  * <p>
45  * <b>Example Usage:</b><pre>
46  * &lt;project name="&#8230;" ...&gt;
47  * &lt;<b>install-steprunner</b>/&gt;
48  * &#8230;
49  * &lt;/project&gt;
50  * </pre>
51  *
52  * @since JWare/AntX 0.4
53  * @author ssmc, &copy;2004 <a HREF="http://www.jware.info">iDare&nbsp;Media,&nbsp;Inc.</a>
54  * @version 0.5
55  * @.safety single
56  * @.group api,helper
57  * @see StepLauncher
58  **/

59
60 public final class StepLauncherInstallTask extends AssertableLibDefinition
61     implements FixtureInitializer
62 {
63     /**
64      * Initializes new installer task.
65      **/

66     public StepLauncherInstallTask()
67     {
68         super(AntX.flow+"steplauncher");
69     }
70
71
72
73     /**
74      * Installs the special AntX step launcher target is it
75      * doesn't already exist.
76      * @throws BuildException if unable to add target for any reason.
77      **/

78     public void execute()
79     {
80         verifyCanExecute_("execute");
81
82         Project P = getProject();
83         Map JavaDoc all = P.getTargets();
84         Target t = (Target)all.get(FlowConstants.DEFAULT_STEP_CALLER_SPECIAL_TARGETNAME);
85
86         if (t==null) {
87             t = new Target();
88             t.setProject(P);
89             t.setName(FlowConstants.DEFAULT_STEP_CALLER_SPECIAL_TARGETNAME);
90
91             StepLauncher runr = new StepLauncher();
92             runr.setProject(P);
93             runr.setTaskName("runsteps");
94             runr.setTaskType("runsteps");
95             runr.setLocation(getLocation());
96             runr.setOwningTarget(t);
97             runr.init();
98
99             t.addTask(runr);
100             P.addOrReplaceTarget(t);
101         }
102     }
103 }
104
105 /* end-of-StepLauncherInstallTask.java */
106
Popular Tags