Search code examples
mavenmaven-plugin

How to run the maven plugin via cmd in the root directory without running this plugin in all modules?


We have a plugin that needs to be run via cmd, for example:

mvn com.test.plugins:some-plugin:2.1.0:generate

There is a root pom.xml, which has 3 modules

<modules>
    <module>first</module>
    <module>second</module>
    <module>third</module>
</modules>

And when the plugin is launched in this way from the root directory, the plugin is launched 4 times, in each module. I know that if you were writing the plugin configuration in pom.xml

<build><plugins><plugin>

we can use the tag

<inherited>false</inherited>

How can I do this through the console? Or maybe we can add something to the Mojo class of the plugin?


Solution

  • Use the -N (or --non-recursive) command line parameter:

    mvn -N com.test.plugins:some-plugin:2.1.0:generate