Asks the user a question on the console. This is what an interactive Maven plugin uses to prompt — the archetype plugin's "Define value for property…" comes from here.
Prompter handles the common cases: a plain question, a question with a default, a question restricted to
a list of allowed answers, and a password prompt. InputHandler and OutputHandler are the lower-level
pieces underneath.
Maintained, quietly. The API is small and settled; expect dependency updates rather than new features.
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-interactivity-api</artifactId>
</dependency>Check the badge above for the current version. Note the artifact is plexus-interactivity-api;
plexus-interactivity is the aggregator.
@Inject
Prompter prompter;
String name = prompter.prompt( "Project name" );
String scope = prompter.prompt( "Scope", List.of( "compile", "test" ), "compile" );
String secret = prompter.promptForPassword( "Password" );An empty answer returns the default. With a list of allowed answers, the prompt repeats after
"Invalid selection." until the answer is on the list, and it throws a PrompterException if input ends and
no default was given.
The default InputHandler reads a password like any other line, so the typed characters are echoed. To
mask them with *, add org.jline:jline-reader (an optional dependency of this artifact, so you declare
it yourself) and use the handler registered under the name jline, JLineInputHandler.
A plugin that prompts should check MavenSession.getRequest().isInteractiveMode() first, so it does not
hang a batch-mode build.
Java 8 or later. Building the project needs Maven 3.9.0 or later.
Conventions for contributors and agents are in AGENTS.md; see also CONTRIBUTING.md. In short:
mvn verify builds, and run mvn spotless:apply before pushing or CI will fail on formatting.
Please report security vulnerabilities privately — see SECURITY.md, not a public issue.