Is there a way to determine if GWT code is running in development mode?

3.7k views Asked by At

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.

2

There are 2 answers

4
Dean Povey On BEST ANSWER

GWT >= 2.1.0

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

GWT < 2.1.0

boolean isDevelopmentMode() {
    return !GWT.isScript() && GWT.isClient();
}
0
Marco M. On
boolean isProductionMode() {
  return GWT.isScript();
}

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

// e.g. JUnit tests
boolean isPlainJVM() {
  return !GWT.isClient();
}