private void describeMojoParameters()

in src/main/java/org/apache/maven/plugins/help/DescribeMojo.java [557:636]


    private void describeMojoParameters(MojoDescriptor md, StringBuilder buffer)
            throws MojoFailureException, MojoExecutionException {
        List<Parameter> params = md.getParameters();

        if (params == null || params.isEmpty()) {
            append(buffer, "This mojo doesn't use any parameters.", 1);
            return;
        }

        params = params.stream()
                .sorted((p1, p2) -> p1.getName().compareToIgnoreCase(p2.getName()))
                .collect(Collectors.toList());

        append(buffer, "Available parameters:", 1);

        // indent 2
        for (Parameter parameter : params) {
            if (!parameter.isEditable()) {
                continue;
            }

            buffer.append(LS);

            // DGF wouldn't it be nice if this worked?
            String defaultVal = parameter.getDefaultValue();
            if (defaultVal == null) {
                // defaultVal is ALWAYS null, this is a bug in PluginDescriptorBuilder (cf. MNG-4941)
                defaultVal =
                        md.getMojoConfiguration().getChild(parameter.getName()).getAttribute("default-value", null);
            }

            if (defaultVal != null && !defaultVal.isEmpty()) {
                defaultVal = " (Default: " + MessageUtils.buffer().strong(defaultVal) + ")";
            } else {
                defaultVal = "";
            }
            append(buffer, MessageUtils.buffer().strong(parameter.getName()) + defaultVal, 2);

            String alias = parameter.getAlias();
            if (!(alias == null || alias.isEmpty())) {
                append(buffer, "Alias", alias, 3);
            }

            if (parameter.isRequired()) {
                append(buffer, "Required", "true", 3);
            }

            String expression = parameter.getExpression();
            if (expression == null || expression.isEmpty()) {
                // expression is ALWAYS null, this is a bug in PluginDescriptorBuilder (cf. MNG-4941).
                // Fixed with Maven-3.0.1
                expression =
                        md.getMojoConfiguration().getChild(parameter.getName()).getValue(null);
            }
            if (expression != null && !expression.isEmpty()) {
                Matcher matcher = EXPRESSION.matcher(expression);
                if (matcher.matches()) {
                    append(buffer, "User property", matcher.group(1), 3);
                } else {
                    append(buffer, "Expression", expression, 3);
                }
            }

            append(buffer, toDescription(parameter.getDescription()), 3);

            String deprecation = parameter.getDeprecated();
            if (deprecation != null && deprecation.length() <= 0) {
                deprecation = NO_REASON;
            }

            if (deprecation != null && !deprecation.isEmpty()) {
                append(
                        buffer,
                        MessageUtils.buffer()
                                .warning("Deprecated. " + deprecation)
                                .build(),
                        3);
            }
        }
    }