protected static void addParameterUsageInfo()

in maven-core/src/main/java/org/apache/maven/plugin/PluginConfigurationException.java [84:174]


    protected static void addParameterUsageInfo( String expression, StringBuffer messageBuffer )
    {
        StringBuffer expressionMessageBuffer = new StringBuffer();

        Matcher exprMatcher = Pattern.compile( "\\$\\{(.+)\\}" ).matcher( expression );

        boolean unmodifiableElementsFound = false;
        boolean activeElementsFound = false;

        int elementCount = 0;

        while ( exprMatcher.find() )
        {
            elementCount++;

            activeElementsFound = true;

            String subExpression = exprMatcher.group( 1 );

            StringTokenizer expressionParts = new StringTokenizer( subExpression, "." );

            String firstPart = expressionParts.nextToken();

            Map expressions = null;
            try
            {
                expressions = ExpressionDocumenter.load();
            }
            catch ( ExpressionDocumentationException e )
            {
                expressionMessageBuffer.append( "\n\nERROR!! Failed to load expression documentation!" );

                StringWriter sWriter = new StringWriter();
                PrintWriter pWriter = new PrintWriter( sWriter );

                e.printStackTrace( pWriter );

                expressionMessageBuffer.append( "\n\nException:\n\n" ).append( sWriter.toString() );
            }

            if ( expressions != null )
            {
                Expression expr = (Expression) expressions.get( subExpression );

                if ( expr != null )
                {
                    if ( !expr.isEditable() )
                    {
                        unmodifiableElementsFound = true;
                    }
                    else
                    {
                        addParameterConfigDocumentation( firstPart, exprMatcher.group( 0 ), subExpression,
                                                         expressionMessageBuffer, expressions );
                    }
                }
                else if ( UNMODIFIABLE_EXPRESSIONS.contains( subExpression ) )
                {
                    unmodifiableElementsFound = true;
                }
                else
                {
                    expressionMessageBuffer.append( "on the command line, specify: \'-D" ).append( subExpression )
                        .append( "=VALUE\'" );
                }
            }
        }

        if ( activeElementsFound )
        {
            messageBuffer.append( expressionMessageBuffer );
        }
        else
        {
            messageBuffer.append(
                "    (found static expression: \'" + expression + "\' which may act as a default value).\n" );
        }

        if ( unmodifiableElementsFound )
        {
            if ( elementCount > 1 )
            {
                messageBuffer.append( "    " );
            }

            messageBuffer
                .append( "NOTE: One or more purely derived expression elements were detected in \'" + expression
                    + "\'.\n    If you continue to get this error after any other expression elements are specified correctly,"
                    + "\n    please report this issue to the Maven development team.\n" );
        }
    }