Package org.apache.maven.api.cli
Interface ParserRequest
Represents a request to parse Maven command-line arguments.
This interface encapsulates all the necessary information needed to parse
Maven commands and arguments into an
InvokerRequest
.- Since:
- 4.0.0
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionargs()
Returns the command-line arguments to be parsed.static ParserRequest.Builder
builder
(String command, String commandName, List<String> args, MessageBuilderFactory messageBuilderFactory) Creates a new Builder instance for constructing a ParserRequest.command()
Returns the Maven command to be executed.Returns the Maven command name (ie "Maven").cwd()
Returns the current working directory for the Maven execution.boolean
embedded()
Returnstrue
if this call happens in "embedded" mode, for example by another application that embeds Maven.logger()
Returns the logger to be used during the parsing process.lookup()
Per-requestLookup
for customization.Returns the Maven home directory.Returns the factory for creating message builders.static ParserRequest.Builder
mvn
(String[] args, MessageBuilderFactory messageBuilderFactory) Creates a new Builder instance for constructing a Maven ParserRequest.static ParserRequest.Builder
mvn
(List<String> args, MessageBuilderFactory messageBuilderFactory) Creates a new Builder instance for constructing a Maven ParserRequest.static ParserRequest.Builder
mvnenc
(String[] args, MessageBuilderFactory messageBuilderFactory) Creates a new Builder instance for constructing a Maven Encrypting Tool ParserRequest.static ParserRequest.Builder
mvnenc
(List<String> args, MessageBuilderFactory messageBuilderFactory) Creates a new Builder instance for constructing a Maven Encrypting Tool ParserRequest.static ParserRequest.Builder
mvnsh
(String[] args, MessageBuilderFactory messageBuilderFactory) Creates a new Builder instance for constructing a Maven Shell Tool ParserRequest.static ParserRequest.Builder
mvnsh
(List<String> args, MessageBuilderFactory messageBuilderFactory) Creates a new Builder instance for constructing a Maven Shell Tool ParserRequest.stdErr()
Returns the error stream to be used for the Maven execution.stdIn()
Returns the input stream to be used for the Maven execution.stdOut()
Returns the output stream to be used for the Maven execution.userHome()
Returns the user's home directory.
-
Method Details
-
command
Returns the Maven command to be executed. This command is used in some invokers (ie forked) but also to present help to user.- Returns:
- the command string
-
commandName
Returns the Maven command name (ie "Maven"). This string is used in some invokers to complete error messages.- Returns:
- the command (human) name
-
logger
Returns the logger to be used during the parsing process.- Returns:
- the logger instance
-
messageBuilderFactory
Returns the factory for creating message builders.- Returns:
- the message builder factory
-
args
Returns the command-line arguments to be parsed.- Returns:
- a list of argument strings
-
lookup
Per-requestLookup
for customization.- Returns:
- a lookup possibly with custom components
-
cwd
Returns the current working directory for the Maven execution. If not explicitly set, this value will be detected during parsing.- Returns:
- the current working directory path, or null if not set
-
mavenHome
Returns the Maven home directory. If not explicitly set, this value will be detected during parsing.- Returns:
- the Maven home directory path, or null if not set
-
userHome
Returns the user's home directory. If not explicitly set, this value will be detected during parsing.- Returns:
- the user's home directory path, or null if not set
-
stdIn
Returns the input stream to be used for the Maven execution. If not set,System.in
will be used by default.- Returns:
- the input stream, or null if not set
-
stdOut
Returns the output stream to be used for the Maven execution. If not set,System.out
will be used by default.- Returns:
- the output stream, or null if not set
-
stdErr
Returns the error stream to be used for the Maven execution. If not set,System.err
will be used by default.- Returns:
- the error stream, or null if not set
-
embedded
boolean embedded()Returnstrue
if this call happens in "embedded" mode, for example by another application that embeds Maven. When running in "embedded" mode, Maven will not try to grab system terminal and will use providedstdIn()
orInputStream.nullInputStream()
as standard in stream. -
mvn
@Nonnull static ParserRequest.Builder mvn(@Nonnull String[] args, @Nonnull MessageBuilderFactory messageBuilderFactory) Creates a new Builder instance for constructing a Maven ParserRequest.- Parameters:
args
- the command-line argumentsmessageBuilderFactory
- the factory for creating message builders- Returns:
- a new Builder instance
-
mvn
@Nonnull static ParserRequest.Builder mvn(@Nonnull List<String> args, @Nonnull MessageBuilderFactory messageBuilderFactory) Creates a new Builder instance for constructing a Maven ParserRequest.- Parameters:
args
- the command-line argumentsmessageBuilderFactory
- the factory for creating message builders- Returns:
- a new Builder instance
-
mvnenc
@Nonnull static ParserRequest.Builder mvnenc(@Nonnull String[] args, @Nonnull MessageBuilderFactory messageBuilderFactory) Creates a new Builder instance for constructing a Maven Encrypting Tool ParserRequest.- Parameters:
args
- the command-line argumentsmessageBuilderFactory
- the factory for creating message builders- Returns:
- a new Builder instance
-
mvnenc
@Nonnull static ParserRequest.Builder mvnenc(@Nonnull List<String> args, @Nonnull MessageBuilderFactory messageBuilderFactory) Creates a new Builder instance for constructing a Maven Encrypting Tool ParserRequest.- Parameters:
args
- the command-line argumentsmessageBuilderFactory
- the factory for creating message builders- Returns:
- a new Builder instance
-
mvnsh
@Nonnull static ParserRequest.Builder mvnsh(@Nonnull String[] args, @Nonnull MessageBuilderFactory messageBuilderFactory) Creates a new Builder instance for constructing a Maven Shell Tool ParserRequest.- Parameters:
args
- the command-line argumentsmessageBuilderFactory
- the factory for creating message builders- Returns:
- a new Builder instance
-
mvnsh
@Nonnull static ParserRequest.Builder mvnsh(@Nonnull List<String> args, @Nonnull MessageBuilderFactory messageBuilderFactory) Creates a new Builder instance for constructing a Maven Shell Tool ParserRequest.- Parameters:
args
- the command-line argumentsmessageBuilderFactory
- the factory for creating message builders- Returns:
- a new Builder instance
-
builder
@Nonnull static ParserRequest.Builder builder(@Nonnull String command, @Nonnull String commandName, @Nonnull List<String> args, @Nonnull MessageBuilderFactory messageBuilderFactory) Creates a new Builder instance for constructing a ParserRequest.- Parameters:
command
- the Maven command to be executedcommandName
- the Maven command Name to be executedargs
- the command-line argumentsmessageBuilderFactory
- the factory for creating message builders- Returns:
- a new Builder instance
-