Search code examples
mavenmaven-plugin

Is there a way to access Maven cmd line options from within Mojo?


Running the following command mvn -U clean install is there a way to check -U from within my custom Mojo?

I checked available items in AbstractMojo.getPluginContext() but didn't find anything for command line.


Solution

  • Technically it is possible get the information via the MavenSession:

    @Parameter(defaultValue = "${session}", readonly = true)
    private MavenSession session;
    
    
    public void execute() {
      ...
      if (session.getRequest().isNoSnapshotUpdates()) {
       ...
      }
    }
    

    But I would ask why do you need such information within a plugin?