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 ; 13 14 15 public class AntMojoWrapper 16 extends AbstractMojo 17 implements ContextEnabled, MapOrientedComponent 18 { 19 20 private Map 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 pluginContext ) 42 { 43 this.pluginContext = pluginContext; 44 } 45 46 public Map getPluginContext() 47 { 48 return pluginContext; 49 } 50 51 public void addComponentRequirement( ComponentRequirement requirementDescriptor, Object requirementValue ) 52 throws ComponentConfigurationException 53 { 54 scriptInvoker.addComponentRequirement( requirementDescriptor, requirementValue ); 55 } 56 57 public void setComponentConfiguration( Map componentConfiguration ) 58 throws ComponentConfigurationException 59 { 60 scriptInvoker.setComponentConfiguration( componentConfiguration ); 61 } 62 63 } 64 | Popular Tags |