I have a maven project composed of several submodules.
Let's call the submodules shared
and webapp
. The project is normally built from the parent POM, which resides in the parent directory. So the directory layout looks like:
myproject/pom.xml
myproject/shared/pom.xml
myproject/webapp/pom.xml
I have a specific plugin that I want to be executable from the command line in the top-level directory. I do not want it to run by default in any phase. So usually I want to run mvn clean install
, and the plugin should not execute at all in this case. But also I want to be able to say mvn clean install com.mycompany:myplugin:goal
and the execution should run in this case, but the execution should only run once for the webapp
submodule. The execution should not run either for the parent POM or for the shared
submodule when I specify this on the command line.
The problem I have is that if I define the execution in the parent POM, it runs repeatedly for every submodule. If I define the execution in the webapp
POM, it is not accessible through a command line invocation of Maven.
I want to do this in a single Maven comand and that single command must also be able to build & run phases for all submodules -- not just the webapp
submodule -- hence the -pl
command line option does not work for this case?
Is such a thing possible? If it's impossible, I'll accept an answer stating that.