I have a Maven project that has 3 modules. These are built by the parent pom.xml
I now have a requirement that I need to run one plugin from inside one of the sub modules' pom.xml
files based on the profile selected.
How can I specify that this plugin should only run when a certain profile is used in build?
Please read the documentation on build profiles here: http://maven.apache.org/guides/introduction/introduction-to-profiles.html
You basically need to define a profile in your sub-module's POM and include that plugin in the profile's plugin
section. Using the plugin's execution
tag, you can define which build phase the plugin should run in.
See here for an example: Using maven profiles to control build execution