1 package hudson.maven; 2 3 import org.apache.maven.plugin.MojoExecution; 4 import org.codehaus.plexus.configuration.PlexusConfiguration; 5 import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; 6 import org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup; 7 import org.codehaus.plexus.component.configurator.converters.lookup.DefaultConverterLookup; 8 import org.codehaus.plexus.component.configurator.converters.ConfigurationConverter; 9 import org.codehaus.plexus.component.configurator.ComponentConfigurationException; 10 11 import java.io.File ; 12 13 25 public final class MojoInfo { 26 29 public final MojoExecution mojoExecution; 30 31 34 public final PluginName pluginName; 35 36 41 public final PlexusConfiguration configuration; 42 43 47 public final ExpressionEvaluator expressionEvaluator; 48 49 53 private final ConverterLookup converterLookup = new DefaultConverterLookup(); 54 55 public MojoInfo(MojoExecution mojoExecution, PlexusConfiguration configuration, ExpressionEvaluator expressionEvaluator) { 56 this.mojoExecution = mojoExecution; 57 this.configuration = configuration; 58 this.expressionEvaluator = expressionEvaluator; 59 this.pluginName = new PluginName(mojoExecution.getMojoDescriptor().getPluginDescriptor()); 60 } 61 62 66 public String getGoal() { 67 return mojoExecution.getMojoDescriptor().getGoal(); 68 } 69 70 89 public <T> T getConfigurationValue(String configName, Class <T> type) throws ComponentConfigurationException { 90 PlexusConfiguration child = configuration.getChild(configName); 91 if(child==null) return null; 93 ConfigurationConverter converter = converterLookup.lookupConverterForType(type); 94 return type.cast(converter.fromConfiguration(converterLookup,child,type, 95 Object .class, 98 mojoExecution.getMojoDescriptor().getPluginDescriptor().getClassRealm().getClassLoader(), 99 expressionEvaluator)); 100 } 101 } 102 | Popular Tags |