Package io.github.rajendarreddyj.tomcat
Class StartMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
io.github.rajendarreddyj.tomcat.AbstractTomcatMojo
io.github.rajendarreddyj.tomcat.StartMojo
- All Implemented Interfaces:
ContextEnabled,Mojo
@Mojo(name="start",
defaultPhase=PRE_INTEGRATION_TEST,
requiresDependencyResolution=RUNTIME,
threadSafe=true)
public class StartMojo
extends AbstractTomcatMojo
Starts Apache Tomcat in background mode with the project's webapp deployed.
This goal starts Tomcat as a background process and immediately returns
control
to the Maven build. The process ID is stored in a file within CATALINA_BASE
for
later use by the StopMojo goal.
This is useful for integration testing scenarios where Tomcat needs to be started before tests run and stopped after tests complete.
Usage
mvn tomcat:start
Integration Test Example
<plugin>
<groupId>io.github.rajendarreddyj</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<executions>
<execution>
<id>start-tomcat</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-tomcat</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
- Since:
- 1.0.0
- Author:
- rajendarreddyj
- See Also:
-
Field Summary
Fields inherited from class io.github.rajendarreddyj.tomcat.AbstractTomcatMojo
autopublishEnabled, autopublishInactivityLimit, catalinaBase, catalinaHome, classpathAdditions, contextPath, debugHost, debugPort, debugSuspend, deploymentOutputName, environmentVariables, httpHost, httpPort, javaHome, project, shutdownTimeout, skip, startupTimeout, tomcatCacheDir, tomcatVersion, vmOptions, warSourceDirectory -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class io.github.rajendarreddyj.tomcat.AbstractTomcatMojo
buildDeployableConfiguration, buildJdwpAgentArg, buildServerConfiguration, detectInstalledVersion, downloadTomcat, resolveCatalinaHome, validateDebugPortAvailable, validateJavaVersion, validatePortAvailable, validateTomcatInstallationMethods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Constructor Details
-
StartMojo
public StartMojo()
-
-
Method Details
-
execute
Executes the start goal.This method performs the following steps:
- Validates Java version compatibility with the configured Tomcat version
- Validates that the configured HTTP port is available
- Builds server and deployment configurations
- Deploys the webapp to Tomcat's webapps directory
- Starts Tomcat in background mode
- Stores the process ID for the stop goal to use
- Throws:
MojoExecutionException- if an error occurs during executionMojoFailureException- if execution fails due to invalid configuration
-