Friday, September 30, 2016

Re: Using Constants based on Environment

Ideally your build tool should put your environment into prod or dev mode and the GWT app shouldn't know/care about it. With Maven / Gradle / Ant you can use "resource filtering" to rewrite resources like property files while being copied to the output folder. 

In that case you would have
key = ${key}
key = devValue
key = prodValue

and the build tool will replace ${key} with the value of one of the other two files before GWT will pick up

Otherwise you might try (no idea if it works):

interface Config extends Constants {...}
interface DevConfig extends Config {...} -> create a file
interface ProdConfig extends Config {...} -> create a file

and in Java code

Config config;
if ("dev".equals(System.getProperty("env")) {
  config = GWT.create(DevConfig.class);
} else if ("prod".equals(......)) {

Can't remember, but System.getProperty() might require GWT 2.8.

-- J.

You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment