Class RunMojo

All Implemented Interfaces:
ContextEnabled, Mojo

@Mojo(name="run", defaultPhase=PRE_INTEGRATION_TEST, requiresDependencyResolution=RUNTIME, threadSafe=true) public class RunMojo extends AbstractTomcatMojo
Runs Apache Tomcat in foreground mode with the project's webapp deployed.

This goal starts Tomcat and blocks until the process is terminated (Ctrl+C). The webapp is deployed to Tomcat's webapps directory before startup. If auto-publish is enabled, file changes in the source directory will trigger automatic redeployment.

Usage

mvn tomcat:run

Configuration Example


 <plugin>
     <groupId>io.github.rajendarreddyj</groupId>
     <artifactId>tomcat-maven-plugin</artifactId>
     <configuration>
         <httpPort>8080</httpPort>
         <contextPath>/myapp</contextPath>
         <autopublishEnabled>true</autopublishEnabled>
     </configuration>
 </plugin>
 
Since:
1.0.0
Author:
rajendarreddyj
See Also:
  • Constructor Details

    • RunMojo

      public RunMojo()
  • Method Details

    • execute

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

      This method performs the following steps:

      1. Validates Java version compatibility with the configured Tomcat version
      2. Validates that the configured HTTP port is available
      3. Builds server and deployment configurations
      4. Deploys the webapp to Tomcat's webapps directory
      5. Starts the hot deploy watcher if auto-publish is enabled
      6. Starts Tomcat in foreground mode and blocks until shutdown
      Throws:
      MojoExecutionException - if an error occurs during execution
      MojoFailureException - if execution fails due to invalid configuration