tomcat6web-deploymentmaven-1

Deploying a war to tomcat server with maven 1.1


does anyone know a way to configure a maven goal to deploy to a tomcat server after a build is run? I know that this is possible using the maven-tomcat-plugin but it looks as though as this only works for Maven 2 whereas I'm using Maven 1.1

I'm currently trying to set up Hudson so this would be part of my continuous intergration phase which I hope will run like this:

  1. Build all necessary components
  2. Build war and deploy to (local) server
  3. Run selenium tests

Any help with this would be much appreciated.

Thanks.


Solution

  • I've figured out that best way to do this - its actually pretty easy to write a maven goal to transfer the war. The goal could be written as follows:

    <goal name="deployWar" prereqs="buildWar">
    
        <echo message="+---------------------------------------------------+" />
        <echo message="installing war file to server" />
        <echo message="+---------------------------------------------------+" />
    
        <j:set var="deploy.dir" value="${server}/webapps" />
    
        <copy file="${maven.build.dir}/${pom.artifactId}.war"
            todir="${deploy.dir}" overwrite="true" />
    </goal>
    

    The server variable can be determined in your project.properties file. Also be sure to specify that a pre-requisite to build the WAR before you try to deploy it. Hope this helps someone!