public void execute()

in src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java [167:204]


    public void execute() throws MojoExecutionException, MojoFailureException {
        if (expression == null && !settings.isInteractiveMode()) {

            getLog().error("Maven is configured to NOT interact with the user for input. "
                    + "This Mojo requires that 'interactiveMode' in your settings file is flag to 'true'.");
            return;
        }

        validateParameters();

        if (artifact != null && !artifact.isEmpty()) {
            project = getMavenProject(artifact);
        }

        if (expression == null) {
            if (output != null) {
                getLog().warn("When prompting for input, the result will be written to the console, "
                        + "ignoring 'output'.");
            }
            while (true) {
                getLog().info("Enter the Maven expression i.e. ${project.groupId} or 0 to exit?:");

                try {
                    String userExpression = inputHandler.readLine();
                    if (userExpression == null
                            || userExpression.toLowerCase(Locale.ENGLISH).equals("0")) {
                        break;
                    }

                    handleResponse(userExpression, null);
                } catch (IOException e) {
                    throw new MojoExecutionException("Unable to read from standard input.", e);
                }
            }
        } else {
            handleResponse("${" + expression + "}", output);
        }
    }