We recently converted our app engine project into modules as per the structure below. The problem with this new dev workflow is that we have to rebuild the EAR on every change and relaunch the app engine local dev server. This makes us loose 30s to a minute every time we make a change to the code and want to test it.
/commons
-pom.xml
/model
-pom.xml
/webapp //app engine module
-pom.xml
/apis //app engine module
-pom.xml
/ear
-pom.xml
pom.xml //main (parent) project pom
In our previous workflow, with the monolithic app, we could use app engine's hot reload functionality, where modifying code in an IDE (e.g. eclipse) would be picked up automatically.
What do you guys recommend as the best maven config and/or dev workflow in this case? Ideally, a change in any of the modules would not require a full rebuild of the project.
I am using a similar structure with a small difference. The top level directory has war and ear and then they contain their specific pom.xml. I use Eclipse for debugging, and I am able to hot deploy "most of the time" and I am not using Eclipse plugin, which (I understand) is what you want.
.
|-- pom.xml
|-- README.md
|-- my-ear
| |-- devpid
| |-- pom.xml
| `-- src
| `-- main
| `-- application
| `-- META-INF
`-- my-war
|-- build
| `-- classes
| |-- main
| | |-- java
| | `-- webapp
| `-- test
| `-- java
|-- pom.xml
`-- src
|-- main
| |-- java
| | `-- com
| `-- webapp
| |-- css
| |-- favicon.ico
| |-- index.html
| |-- js
| |-- test.html
| `-- WEB-INF
`-- test
`-- java
In maven ear/pom.xml, add xArgs to appengine plugin for running in debug mode.
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${appengine.target.version}</version>
<configuration>
<jvmFlags>
<jvmFlag>-Xdebug</jvmFlag>
<jvmFlag>-Xrunjdwp:transport=dt_socket,address=1044,server=y,suspend=n</jvmFlag>
</jvmFlags>
<disableUpdateCheck>true</disableUpdateCheck>
</configuration>
</plugin>
Notice the suspend=n.
mvn appengine:devserver > ~/.logs/.appengine.devserver.logs & echo $! > devpid
Let's call this Terminal 1. tail -f ~/.logs/.appengine.devserver.logs | sed 's/INFO/^[[0;34m&^[[0m/g;s/ERROR/^[[0;31m&^[[0m/g;s/WARN\|WARNING/^[[0;35m&^[[0m/g;s/SEVERE\|FATAL/^[[0;31;47m&^[[0m/g'
The above is a difficult to type command. Every instance of ^[ is actually Ctrl+V Esc - it is worth the effort of typing it once. But this is of course subjective and up to you. In Eclipse, create a Debug Profile for your project under Remote Java Application - select the war project and socket attach options. This step is available on the internet at many places, here is an image nevertheless
Open another terminal, Terminal 2 in the war directory and keep it open in order to run mvn compile install
when you need to.
mvn compile install
from Terminal 2. Devserver will autodetect.mvn compile install
from outside. My reason for giving list of windows (Eclipse, Terminal 1 and Terminal 2) is just to show that Alt+Tab is actually faster than Shift+F7 from within eclipse. It is subjective and of course up to you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With