I have a strange behavior when I user tomcat-plugin, in my parent project I declare the plugin configuration in the pluginmanagement.
I have 3 child war project, two of them declare the plugin and one did not declare the plugin.
For an unknown reason the plugin is execute in the first project but I don't understand why.
Here is a sample of my parent project.
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<groupId>my.groupID</groupId>
<artifactId>parent</artifactId>
<packaging>pom</packaging>
<version>1.0.0</version>
<name>parent</name>
<build>
...
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<server>local</server>
<update>true</update>
<charset>UTF-8</charset>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Here is the sample of the child1 (the plugin isn't declare):
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>parentProject</artifactId>
<groupId>my.groupID</groupId>
<version>1.0.0</version>
</parent>
<groupId>my.groupID</groupId>
<artifactId>child1</artifactId>
<packaging>war</packaging>
<build>
...
</build>
</project>
Here is the sample of the child2 (the plugin is declare)
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>parentProject</artifactId>
<groupId>my.groupID</groupId>
<version>1.0.0</version>
</parent>
<groupId>my.groupID</groupId>
<artifactId>child2</artifactId>
<packaging>war</packaging>
<properties>
<urlTomcat>http://localhost:8080/</urlTomcat>
<pathApp>child2</pathApp>
</properties>
<profiles>
<profile>
<id>deploy-child2</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<url>${urlTomcat}manager/text</url>
<path>/${pathApp}</path>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>my.groupID</groupId>
<artifactId>child1</artifactId>
<type>war</type>
</dependency>
</dependencies>
<build>
...
</build>
</project>
Here is the sample of the child3 (the plugin is declare)
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>parentProject</artifactId>
<groupId>my.groupID</groupId>
<version>1.0.0</version>
</parent>
<groupId>my.groupID</groupId>
<artifactId>child3</artifactId>
<packaging>war</packaging>
<properties>
<urlTomcat>http://localhost:8080/</urlTomcat>
<pathApp>child3</pathApp>
</properties>
<profiles>
<profile>
<id>deploy-child3</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<url>${urlTomcat}manager/text</url>
<path>/${pathApp}</path>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>my.groupID</groupId>
<artifactId>child1</artifactId>
<type>war</type>
</dependency>
</dependencies>
<build>
...
</build>
</project>
When I ran this command :
mvn tomcat7:deploy -Pdeploy-child2 or mvn tomcat7:deploy -Pdeploy-child3
My problem is that maven try to deploy the child1 project and I don't want it. I expect that the child1 will be build but not deploy because it doesn't declare the plugin.