0

If I declared a plugin under <pluginManagement> element and I also want to use it in the same POM, my understanding is that I have to declare it under <plugins> element just under <build> element, according to explanations in https://maven.apache.org/pom.html#Plugin_Management and What is pluginManagement in Maven's pom.xml?.

But I found I don't need to declare it under <plugins> element just under <build> element to use that plugin when execute mvn tomcat7:run in spring-security-oauth sample project. The plugin is tomcat7-maven-plugin.

So I'm curious why it works without declaring it here.

niaomingjian
  • 3,472
  • 8
  • 43
  • 78

1 Answers1

0

If you call the plugin explicitly on the command line, as you did, you don't need any declaration at all.

For example, you can call mvn dependency:list without ever declaring the maven dependency plugin.

The thing you are talking about is including plugins into the lifecycle.

So if you want to call mvn clean verify and expect the plugin to run in a certain phase, you need to declare it in <plugins> (unless, of course, it is one of the standard plugins of the lifecycle like compile:compile).

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142