if (ApiProxy.getCurrentEnvironment() == null) {
System.out
.println("No production App Engine environment found - starting local development environment");
ApiProxyLocal proxy = factory.create(this);
ApiProxy.setDelegate(proxy);
// If we are in test mode we do not persist data to disk
if (ninjaProperties.isTest()) {
System.out
.println("In test mode - not saving Appengine data to disk");
proxy.setProperty(LocalDatastoreService.NO_STORAGE_PROPERTY,
Boolean.toString(true));
} else {
// write to disk:
/**
* Set the property in your profile. It should match the
* appengine's output dir. You can use both jetty:run and
* appengine:deverserver - and both use the same db.
*
*/
String appengineGeneratedDir = System
.getProperty("appengine.generated.dir");
// in tests we output stuff to target:
if (appengineGeneratedDir == null) {
appengineGeneratedDir = "target";
}
try {
Files.createParentDirs(new File(appengineGeneratedDir));
} catch (IOException e) {
// something strange happened. Can not create parent dirs...
e.printStackTrace();
}
System.out.println("Local datastore at: "
+ new File(appengineGeneratedDir + File.separator
+ "local_db.bin").getAbsolutePath());
proxy.setProperty(LocalDatastoreService.BACKING_STORE_PROPERTY,
new File(appengineGeneratedDir + File.separator
+ "local_db.bin").getAbsolutePath());
}