I am trying to deploy my web-app to multiple servers running Tomcat using tomcat7-maven-plugin.
Here is part of my pom.xml document:
<profiles>
<profile>
<id>DevDeployment</id>
<activation>
<property>
<name>!production</name>
</property>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<executions>
<execution>
<id>localhost</id>
<configuration>
<source>1.8</source>
<target>1.8</target>
<url>http://127.0.01:8080/manager/text</url>
<server>TomcatServer</server>
<username>foo</username>
<password>boo</password>
</configuration>
</execution>
<execution>
<id>devserver</id>
<configuration>
<source>1.8</source>
<target>1.8</target>
<url>http://dev_server_ip:8080/manager/text</url>
<server>TomcatServer</server>
<username>foo</username>
<password>boo</password>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>ProductionDeployment</id>
<activation>
<property>
<name>production</name>
</property>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>production1</id>
<configuration>
<source>1.8</source>
<target>1.8</target>
<url>http://production1_ip:8080/manager/text</url>
<server>TomcatServer</server>
<username>foo</username>
<password>boo</password>
</configuration>
</execution>
<execution>
<id>production2</id>
<configuration>
<source>1.8</source>
<target>1.8</target>
<url>http://production2_ip:8080/manager/text</url>
<server>TomcatServer</server>
<username>foo</username>
<password>boo</password>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
What i am trying to achieve is to have two different maven profiles, and by running first it deploys application to 2 dev servers, and by activating other it deploys application to 2 production servers.
So when i run command:
mvn tomcat7:redeploy -Dproduction
it goes to production servers, and when i run
mvn tomcat7:redeploy
it goes to dev servers.
I have successfully made profiles, and by running those commands it chooses the right one and runs it.
The problem appears when i define multiple <executions> with different <configuration> tags, maven ignores those configuration and runs the default one.
It only works if i run mvn tomcat7:redeploy@localhost or mvn tomcat7:redeploy@devserver and target an execution directly by Id.
So obviously the goal is to have to run just 2 commands: mvn tomcat7:redeploy -Dproduction or mvn tomcat7:redeploy to deploy app to all servers either production or development.
Is it possible to achieve that with executions or there is some other way?