Package io.github.rajendarreddyj.tomcat
Class DebugMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
io.github.rajendarreddyj.tomcat.AbstractTomcatMojo
io.github.rajendarreddyj.tomcat.DebugMojo
- All Implemented Interfaces:
ContextEnabled,Mojo
@Mojo(name="debug",
defaultPhase=PRE_INTEGRATION_TEST,
requiresDependencyResolution=RUNTIME,
threadSafe=true)
public class DebugMojo
extends AbstractTomcatMojo
Runs Apache Tomcat in debug mode with JDWP agent enabled.
This goal starts Tomcat with Java debugging enabled, allowing IDEs (VS Code, IntelliJ, Eclipse) to attach and debug the running application. The goal blocks until the process is terminated (Ctrl+C).
Usage
mvn tomcat:debug
IDE Connection
Connect your IDE debugger to localhost:{debugPort} (default: 5005)
VS Code
Add to launch.json:
{
"type": "java",
"name": "Attach to Tomcat",
"request": "attach",
"hostName": "localhost",
"port": 5005
}
IntelliJ IDEA
Run → Edit Configurations → Add → Remote JVM Debug → Port: 5005
Eclipse
Run → Debug Configurations → Remote Java Application → Port: 5005
Configuration Example
<plugin>
<groupId>io.github.rajendarreddyj</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<httpPort>8080</httpPort>
<debugPort>5005</debugPort>
<debugSuspend>false</debugSuspend>
<contextPath>/myapp</contextPath>
</configuration>
</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
-
DebugMojo
public DebugMojo()
-
-
Method Details
-
execute
Executes the debug goal.This method performs the following steps:
- Validates Java version compatibility with the configured Tomcat version
- Validates that the HTTP port is available
- Validates that the debug port is available
- Builds server configuration with JDWP debug options
- Deploys the webapp to Tomcat's webapps directory
- Starts the hot deploy watcher if auto-publish is enabled
- Prints debug connection instructions
- Starts Tomcat in foreground mode and blocks until shutdown
- Throws:
MojoExecutionException- if an error occurs during executionMojoFailureException- if execution fails due to invalid configuration
-