Nital
Nital

Reputation: 6084

Deploying a webapp on two Tomcat servers on different machines with different OS

I would like deploy my webapp both on Windows Tomcat 7 and Unix Tomcat 7 one after another or at the same time, if possible. Currently, I am able to successfully deploy my webapp on Windows Tomcat using tomcat-maven-plugin and calling mvn tomcat7:redeploy. But the limitation is that I have to change my pom so that it points to Unix Tomcat if I want to deploy the webapp on Unix which is very painful. Any ideas on how this can be accomplished ? Please guide.

pom.xml

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
        <url>http://localhost:8080/manager/text</url>
        <server>win-tomcat</server>
        <path>/${project.artifactId}</path>
    </configuration>
</plugin>

.m2/settings.xml

<settings>
    <servers>
        <server>
            <id>unix-tomcat</id>
            <username>manager</username>
            <password>manager</password>
        </server>
        <server>
            <id>win-tomcat</id>
            <username>manager</username>
            <password>manager</password>
        </server>
    </servers>
</settings>

Upvotes: 1

Views: 110

Answers (2)

Marcel St&#246;r
Marcel St&#246;r

Reputation: 23535

If you don't want to resort to profiles but deploy to both in one go you can define two <execution>s like so:

<plugin>
  <groupId>org.apache.tomcat.maven</groupId>
  <artifactId>tomcat7-maven-plugin</artifactId>
  <version>2.2</version>
  <executions>
    <execution>
      <id>deploy-windows</id>
      <configuration>
        <url>http://localhost:8080/manager/text</url>
        <server>win-tomcat</server>
        <path>/${project.artifactId}</path>
      </configuration>
    </execution>
    <execution>
      <id>deploy-unix</id>
      <configuration>
        <url>http://unix:8080/manager/text</url>
        <server>unix-tomcat</server>
        <path>/${project.artifactId}</path>
      </configuration>
    </execution>
  </executions>
</plugin>

Upvotes: 0

Jigar Joshi
Jigar Joshi

Reputation: 240898

You can do it with creating two separate build profiles one for each machine and execute build against both profile one after another

Upvotes: 2

Related Questions