I'm developing App Engine application in Android Studio and testing it on my local machine (with local datastore). It's Java based app. Every time I re-run the server the local datastore is cleared. I've found several solutions for Python developers but it looks like there's no answer for Java.
Android Studio allows only to change:
- WAR Path
- VM Args
- Server Address
- Server Port
I've tried with VM args but these are for Java VM not for the app server obviously. Is there a way to persist local datastore across server restarts? It would be perfect If I could run this configuration directly from Android Studio.
Like Arjan says, you can use
-Ddatastore.backing_store
.If you use Android Studio 1.5, modify
build.gradle
. Onappengine
put the paramaterjvmFlags
. Example:After several hours of searching I've finally found how to use user defined file as a local storage. Unfortunately it doesn't work directly from Android Studio, servers must be run from the terminal.
Here are arguments for Java's dev-appserver:
You have to change
generated_dir
argument. To run dev server directly from the terminal there's a very nice command:I've changed the
generated_dir
argument to--generated_dir=$HOME/sandbox/
Please note you've to provide Android Studio path and App Engine SDK version. For my workstation it's
/opt/android-studio
andappengine-java-sdk-1.9.9
accordingly.The local datastore gets cleared because it is by default located in the application exploded war directory (which is deleted in its entirety on every build).
Instead of having to running the dev server manually from a terminal, you can actually just add a VM arg to the appengine run configuration to locate the datastore in another location:
(Solution found on: https://code.google.com/p/android/issues/detail?id=68225)