Save 400$ and run/debug local App Engine w/ IntelliJ Community

If you read the official docs from cloud.google.com about how you can run and debug an App Engine Standard Application Locally you got…

https://cloud.google.com/tools/intellij/docs/deploy-local

… so I must to pay 400$/year to run/debug locally!?

No way sir!

TL;DR

You can debug a local Maven App Engine Standard Application with one click treating it as a remote Java application.

1. Create a run configuration for starting the local development server

open the run/debug configurations of IntelliJ
create a new Maven run/debug configuration
use the devserver_start goal

It’s mandatory use the appengine:devserver_start goal because it is non blocking, as stated

https://cloud.google.com/appengine/docs/standard/java/tools/maven

apply and close.

2. Add JVM remote debug flags to pom.xml

Thanks to Stack Overflow

you need to add

<jvmFlags>
<jvmFlag>-Xdebug</jvmFlag>
<jvmFlag>-agentlib:jdwp=transport=dt_socket,address=5005,server=y,suspend=n</jvmFlag>
</jvmFlags>

to your pom.xml inside the configuration section of the appengine-maven-plugin

as you can see the port used is the 5005, you can use any port you prefer, I leave the default one.

3. Create a remote debug configuration

open the run/debug configurations of IntelliJ
create a new remote configuration

Apply and don’t close the window ;)

4. Chain both configurations

Here come your one click savings!

In the bottom part of the remote configuration you can add a run/debug configuration that will be execute before!

Now apply and close.

5. Debug the remote configuration

As you will see this run first the Maven goal appengine:devserver_start and when the process is detached it run the remote debug configuration.

So in the IntelliJ “Run” console you have the devserver_start logs and in the “Debug” console you have awesome Java debug tools.

… profit!