Skip to content

Commit

Permalink
Fix for GRAILS-8269 (Environment setting doesn't get used for running…
Browse files Browse the repository at this point in the history
… commands in Grails 2.0 interactive mode)
  • Loading branch information
lhotari committed Nov 7, 2011
1 parent fad2008 commit 0266f00
Showing 1 changed file with 7 additions and 2 deletions.
Expand Up @@ -58,7 +58,8 @@ public String getEnvironment() {
env = lookupEnvironmentForCommand();
}
else {
env = environment != null ? environment : Environment.DEVELOPMENT.getName();
String fallbackEnv = System.getProperty(Environment.KEY) != null ? System.getProperty(Environment.KEY) : Environment.DEVELOPMENT.getName();
env = environment != null ? environment : fallbackEnv;
}

System.setProperty(Environment.KEY, env);
Expand All @@ -68,8 +69,9 @@ public String getEnvironment() {
}

public String lookupEnvironmentForCommand() {
String fallbackEnv = System.getProperty(Environment.KEY) != null ? System.getProperty(Environment.KEY) : Environment.DEVELOPMENT.getName();
String env = CommandLineParser.DEFAULT_ENVS.get(commandName);
return env == null ? Environment.DEVELOPMENT.getName() : env;
return env == null ? fallbackEnv : env;
}

public boolean isEnvironmentSet() {
Expand Down Expand Up @@ -150,6 +152,9 @@ public Map<String, Object> getUndeclaredOptions() {
}

public void addSystemProperty(String name, String value) {
if(Environment.KEY.equals(name)) {
setEnvironment(value);
}
systemProperties.put(name, value);
}

Expand Down

0 comments on commit 0266f00

Please sign in to comment.