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

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

Introduction

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

Prototype

public boolean isEditable() 

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   ww w .  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;
}