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

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

Introduction

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

Prototype

public boolean isRequired() 

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 www . j  a va  2  s .  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;
}