Question

I'm working on a GWT application and would like to branch some logic based on whether the code is running in development mode or is live in production.

For example, when the code needs to make an AJAX call we would like to set the URL depending on mode.

Was it helpful?

Solution

GWT >= 2.1.0

boolean isDevelopmentMode() {
    return !GWT.isProdMode() && GWT.isClient();
}

GWT < 2.1.0

boolean isDevelopmentMode() {
    return !GWT.isScript() && GWT.isClient();
}

OTHER TIPS

boolean isProductionMode() {
  return GWT.isScript();
}

boolean isDevelopmentMode() {
  return !GWT.isScript() && GWT.isClient();
}

// e.g. JUnit tests
boolean isPlainJVM() {
  return !GWT.isClient();
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top