KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > maven > script > ant > AntMojoWrapper


1 package org.apache.maven.script.ant;
2
3 import org.apache.maven.plugin.AbstractMojo;
4 import org.apache.maven.plugin.ContextEnabled;
5 import org.apache.maven.plugin.MojoExecutionException;
6 import org.codehaus.plexus.component.MapOrientedComponent;
7 import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
8 import org.codehaus.plexus.component.factory.ant.AntComponentExecutionException;
9 import org.codehaus.plexus.component.factory.ant.AntScriptInvoker;
10 import org.codehaus.plexus.component.repository.ComponentRequirement;
11
12 import java.util.Map JavaDoc;
13
14
15 public class AntMojoWrapper
16     extends AbstractMojo
17     implements ContextEnabled, MapOrientedComponent
18 {
19
20     private Map JavaDoc pluginContext;
21     private final AntScriptInvoker scriptInvoker;
22
23     public AntMojoWrapper( AntScriptInvoker scriptInvoker )
24     {
25         this.scriptInvoker = scriptInvoker;
26     }
27
28     public void execute()
29         throws MojoExecutionException
30     {
31         try
32         {
33             scriptInvoker.invoke();
34         }
35         catch ( AntComponentExecutionException e )
36         {
37             throw new MojoExecutionException( "Failed to execute: " + e.getMessage(), e );
38         }
39     }
40
41     public void setPluginContext( Map JavaDoc pluginContext )
42     {
43         this.pluginContext = pluginContext;
44     }
45
46     public Map JavaDoc getPluginContext()
47     {
48         return pluginContext;
49     }
50
51     public void addComponentRequirement( ComponentRequirement requirementDescriptor, Object JavaDoc requirementValue )
52         throws ComponentConfigurationException
53     {
54         scriptInvoker.addComponentRequirement( requirementDescriptor, requirementValue );
55     }
56
57     public void setComponentConfiguration( Map JavaDoc componentConfiguration )
58         throws ComponentConfigurationException
59     {
60         scriptInvoker.setComponentConfiguration( componentConfiguration );
61     }
62
63 }
64
Popular Tags