views:

50

answers:

3

I have just started to use Apache Maven. Now I would like to make Maven to be able to make production and development enviroment deploys with one click. I'm using Eclipse (Springsource version) and I have Maven plugin installed. My server has tomcat and only thing needed for deployment is to overwrite old war with new one and server has SSH access.

+1  A: 

Try the Maven Cargo Plugin. This handles various versions of Tomcat, among other app servers. It can start and stop the server before/after deploying. It should also be able to deploy remotely, although I can't testify it with Tomcat.

Péter Török
A: 

If what you need is a file replacement over SSH, I would recommend antrun plugin for the task.

For other deployments, take a look at the great cargo plugin.

bashflyng
A: 

Both the Tomcat Maven Plugin and the Maven2 Cargo Plugin support remote Tomcat deployments (assuming the manager application is available).

For the Tomcat Maven Plugin, see the Usage page, the configuration is pretty simple.

For the Maven2 Cargo Plugin, here is a sample configuration (for a remote container):

<build>
  <plugins>
    <plugin>
      <groupId>org.codehaus.cargo</groupId>
      <artifactId>cargo-maven2-plugin</artifactId>
      <version>1.0.1-sr-1</version>
      <configuration>
        <wait>true</wait>
        <container>
          <containerId>tomcat6x</containerId>
          <type>remote</type>
        </container>
        <configuration>
          <type>runtime</type> 
          <properties>
            <cargo.tomcat.manager.url>[https://yourhost/manager]&lt;/cargo.tomcat.manager.url&gt;
            <cargo.remote.username>[username]</cargo.remote.username>
            <cargo.remote.password>[password]</cargo.remote.password>
          </properties>
        </configuration>
        <deployer>
          <type>remote</type>
          <deployables>
            <deployable>
              <groupId>[war group id]</groupId>
              <artifactId>[war artifact id]</artifactId>
              <type>war</type>
              <properties>
                <context>[optional root context]</context>
              </properties>
              <pingURL>[optional url to ping to know if deployable is done or not]</pingURL>
              <pingTimeout>[optional timeout to ping (default 20000 milliseconds)]</pingTimeout>
            </deployable>
          </deployables>
        </deployer>
      </configuration>
    </plugin>
  </plugins>
</build>

And type mvn cargo:deploy.

Cargo is more powerful (because container agnostic) but also more complicated. For simple needs, I find that the Maven Tomcat Plugin is, well, simpler.

Pascal Thivent