Example usage for org.apache.maven.plugin.descriptor Parameter getDescription

List of usage examples for org.apache.maven.plugin.descriptor Parameter getDescription

Introduction

In this page you can find the example usage for org.apache.maven.plugin.descriptor Parameter getDescription.

Prototype

public String getDescription() 

Source Link

Usage

From source file:org.eclipse.m2e.editor.xml.internal.mojo.DefaultMojoParameterMetadata.java

License:Open Source License

public List<MojoParameter> loadMojoParameters(PluginDescriptor desc, MojoDescriptor mojo,
        PlexusConfigHelper helper, IProgressMonitor monitor) throws CoreException {

    if (monitor.isCanceled()) {
        return Collections.emptyList();
    }//from w  w w .ja  v a2s . c o m
    Class<?> clazz;
    try {
        clazz = mojo.getImplementationClass();
        if (clazz == null) {
            clazz = desc.getClassRealm().loadClass(mojo.getImplementation());
        }
    } catch (ClassNotFoundException | TypeNotPresentException ex) {
        log.warn(ex.getMessage());
        return Collections.emptyList();
    }

    List<Parameter> ps = mojo.getParameters();
    Map<String, Type> properties = helper.getClassProperties(clazz);

    List<MojoParameter> parameters = new ArrayList<>();

    if (ps != null) {
        for (Parameter p : ps) {
            if (monitor.isCanceled()) {
                return Collections.emptyList();
            }
            if (!p.isEditable()) {
                continue;
            }

            Type type = properties.get(p.getName());
            if (type == null) {
                continue;
            }

            helper.addParameter(desc.getClassRealm(), clazz, type, p.getName(), p.getAlias(), parameters,
                    p.isRequired(), p.getExpression(), p.getDescription(), p.getDefaultValue(), monitor);
        }
    }

    return parameters;
}