本文整理汇总了Java中org.apache.maven.plugin.descriptor.MojoDescriptor.getParameters方法的典型用法代码示例。如果您正苦于以下问题:Java MojoDescriptor.getParameters方法的具体用法?Java MojoDescriptor.getParameters怎么用?Java MojoDescriptor.getParameters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.plugin.descriptor.MojoDescriptor
的用法示例。
在下文中一共展示了MojoDescriptor.getParameters方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ValidatingConfigurationListener
import org.apache.maven.plugin.descriptor.MojoDescriptor; //导入方法依赖的package包/类
public ValidatingConfigurationListener( Object mojo, MojoDescriptor mojoDescriptor, ConfigurationListener delegate )
{
this.mojo = mojo;
this.delegate = delegate;
this.missingParameters = new HashMap<String, Parameter>();
if ( mojoDescriptor.getParameters() != null )
{
for ( Parameter param : mojoDescriptor.getParameters() )
{
if ( param.isRequired() )
{
missingParameters.put( param.getName(), param );
}
}
}
}
示例2: extractEligibleConfigurationForGoal
import org.apache.maven.plugin.descriptor.MojoDescriptor; //导入方法依赖的package包/类
/**
* Extracts the subset of the given configuration containing only the values accepted by the plugin/goal. The
* configuration is modified in-place. The the extraction fail the configuration stays unchanged.
*
* @param mojo the Wisdom mojo
* @param plugin the plugin object
* @param goal the goal / mojo
* @param configuration the global configuration
*/
public static void extractEligibleConfigurationForGoal(AbstractWisdomMojo mojo,
Plugin plugin, String goal, Xpp3Dom configuration) {
try {
MojoDescriptor descriptor = mojo.pluginManager.getMojoDescriptor(plugin, goal,
mojo.remoteRepos, mojo.repoSession);
final List<Parameter> parameters = descriptor.getParameters();
Xpp3Dom[] children = configuration.getChildren();
if (children != null) {
for (int i = children.length - 1; i >= 0; i--) {
Xpp3Dom child = children[i];
if (!contains(parameters, child.getName())) {
configuration.removeChild(i);
}
}
}
} catch (Exception e) {
mojo.getLog().warn("Cannot extract the eligible configuration for goal " + goal + " from the " +
"configuration");
mojo.getLog().debug(e);
// The configuration is not changed.
}
}
示例3: validateParameters
import org.apache.maven.plugin.descriptor.MojoDescriptor; //导入方法依赖的package包/类
private void validateParameters( MojoDescriptor mojoDescriptor, PlexusConfiguration configuration,
ExpressionEvaluator expressionEvaluator )
throws ComponentConfigurationException, PluginParameterException
{
if ( mojoDescriptor.getParameters() == null )
{
return;
}
List<Parameter> invalidParameters = new ArrayList<Parameter>();
for ( Parameter parameter : mojoDescriptor.getParameters() )
{
if ( !parameter.isRequired() )
{
continue;
}
Object value = null;
PlexusConfiguration config = configuration.getChild( parameter.getName(), false );
if ( config != null )
{
String expression = config.getValue( null );
try
{
value = expressionEvaluator.evaluate( expression );
if ( value == null )
{
value = config.getAttribute( "default-value", null );
}
}
catch ( ExpressionEvaluationException e )
{
String msg =
"Error evaluating the expression '" + expression + "' for configuration value '"
+ configuration.getName() + "'";
throw new ComponentConfigurationException( configuration, msg, e );
}
}
if ( value == null && ( config == null || config.getChildCount() <= 0 ) )
{
invalidParameters.add( parameter );
}
}
if ( !invalidParameters.isEmpty() )
{
throw new PluginParameterException( mojoDescriptor, invalidParameters );
}
}