Defining a maven plugin on a submodule in a multi-module maven project can give us a 'No plugin found' error. Especially if we have a multi-module project and we want to apply a maven plugin in only one specific module this error occur pretty often. Let's say we have a multi-module root pom which looks like this.

 4.0.0

  com.jdriven.blog
  maven-plugin-multimodule
  0.1-SNAPSHOT
  pom

  module1 
    module2 

Instinctively we add the plugin (tomcat7 for example) to this specific module module2, like this.

 4.0.0

  maven-plugin-multimodule-module2
  war

  com.jdriven.blog
    maven-plugin-multimodule
    0.1-SNAPSHOT
    ../ 

  org.apache.tomcat.maven
        tomcat7-maven-plugin
        2.2 

When we run the command mvn tomcat7:help on the multi-module root pom we get the following error:

[ERROR] No plugin found for prefix 'tomcat7' in the current project
and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo]
available from the repositories

The solution is very simple: We specify the plugin in the pluginManagement section of our multi-module root pom.

 4.0.0

  com.jdriven.blog
  maven-plugin-multimodule
  0.1-SNAPSHOT
  pom

  module1 
    module2 

  org.apache.tomcat.maven
          tomcat7-maven-plugin
          2.2 

And in our specific module module2 we clear the version of the plugin, since it is already defined in the multi-module root pom (the parent).

 4.0.0

  maven-plugin-multimodule-module2
  war

  com.jdriven.blog
    maven-plugin-multimodule
    0.1-SNAPSHOT
    ../ 

  org.apache.tomcat.maven
        tomcat7-maven-plugin 

Now when can run the command mvn tomcat7:help and get no error. We are ready to configure the plugin on our submodule.

shadow-left