tags:

views:

2418

answers:

6

Is there anything I can add to pom.xml that will copy the generated war file from the target directory to my webapps directory?

+4  A: 

Youn can use http://cargo.codehaus.org/Deploying+to+a+running+container and configure it accordingly.

Deploying to one is easy! :) Deploying to two is hard. :( (unless you run the deploy command twice) http://stackoverflow.com/questions/732275/maven-deploy-to-multiple-tomcat-servers
altCognito
+2  A: 

You could also have a look at the jetty plugin. Just type "mvn jetty:run-war" and jetty should run your war-file.

Edit: Jetty is a light weight servlet container suitable for development and testing. It's also lightning fast to start.

Bent André Solheim
I don't want to run the war file. I want it placed in tomcat's webapps directory rather than having to do it manually.
Lisa
+1  A: 

Not ideal, but if you have a really strange app server setup, you could always use an antrun task set to execute when the packaging is run

<build>
    ....
    <plugins>
       <plugin>
          <artifactId>maven-antrun-plugin</artifactId>
          <executions>
            <execution>
              <phase>package</phase>
              <configuration>
                <tasks>
         <!-- Ant copy tasks go here -->
                </tasks>
              </configuration>
              <goals>
                <goal>run</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
     </plugins>
  </build>
sal
A: 

Alternatively, you could have tomcat look in your target directory and deploy directly from there.

In your context.xml or server.xml's Context element:

<Context path="" docBase="/path/to/target/exploded">
...
</Context>

Then you can use the war:exploded goal to create your exploded war.

Clay
Can you give more information on how this is setup. I've done this in the past but google is having trouble locating example configurations.
Drew
+1  A: 

I used the Maven WAR Plugin: http://maven.apache.org/plugins/maven-war-plugin/usage.html

Lisa
A: 

You can also do this with the dependency plugin

Brian Fox