Issue
When I write a Mojo, how can I determine whether I am currently in Batch Mode (i.e. the -B
parameter was given on command line)?
Solution
The simplest way would be to put this:
@Parameter(defaultValue = "${session}", required = true, readonly = true)
private MavenSession session;
If you have defined that in your mojo definition you can within your execute method going like this:
if (session.getRequest().isInteractiveMode()) {
//..
} else {
//..
}
This will give you the information about using --batch-mode.
Answered By - khmarbaise
Answer Checked By - Candace Johnson (JavaFixing Volunteer)