Class DeployMojo

All Implemented Interfaces:
ContextEnabled, Mojo

@Mojo(name="deploy", requiresDependencyResolution=RUNTIME, threadSafe=true) public class DeployMojo extends AbstractTomcatMojo
Deploys or redeploys the webapp to a running Tomcat instance.

This goal copies the exploded WAR directory to Tomcat's webapps directory. If a deployment already exists at the target location, it is removed before the new deployment is copied. This provides a quick way to update a running application without restarting Tomcat.

Note: Tomcat must be configured for automatic deployment (autoDeploy="true" in Host element) for the changes to take effect immediately. Otherwise, a Tomcat restart may be required.

Usage

mvn tomcat:deploy

Configuration Example


 <plugin>
     <groupId>io.github.rajendarreddyj</groupId>
     <artifactId>tomcat-maven-plugin</artifactId>
     <configuration>
         <contextPath>/myapp</contextPath>
         <warSourceDirectory>${project.build.directory}/${project.build.finalName}</warSourceDirectory>
     </configuration>
 </plugin>
 
Since:
1.0.0
Author:
rajendarreddyj
See Also:
  • Constructor Details

    • DeployMojo

      public DeployMojo()
  • Method Details

    • execute

      public void execute() throws MojoExecutionException, MojoFailureException
      Executes the deploy goal.

      This method performs the following steps:

      1. Builds server and deployment configurations
      2. Removes any existing deployment at the target location
      3. Copies the exploded WAR to Tomcat's webapps directory
      Throws:
      MojoExecutionException - if an error occurs during deployment
      MojoFailureException - if deployment fails due to invalid configuration