Skip to content

Commit

Permalink
Address code review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Scott Kurz <[email protected]>
  • Loading branch information
scottkurz committed Feb 25, 2021
1 parent b089857 commit 443b0f4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
5 changes: 3 additions & 2 deletions docs/common-server-parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@ Starting with the 3.1 release of the liberty-maven-plugin, support is added to s
| liberty.var.{var} | `<variable name="var" value="value">` | liberty-plugin-variable-config.xml | The server configuration file is generated in the configDropins/overrides folder of the target server. |
| liberty.defaultVar.{var} | `<variable name="var" defaultValue="value">` | liberty-plugin-variable-config.xml | The server configuration file is generated in the configDropins/overrides folder of the target server. |

If Liberty configuration is specified with Maven properties, the above indicated files are created in the target Liberty server. By default there is no merging behavior for the Maven properties with files located in the `configDirectory` or the specific configuration file parameters such as `bootstrapPropertiesFile`, `jvmOptionsFile` and `serverEnvFile`. However, the `liberty.env.{var}` Maven properties can be merged with other configured `server.env` files by setting the `mergeServerEnv` parameter to `true`. As a special case when `mergeServerEnv` is `false`, an existing "keystore_password" property in the default generated `server.env` file in the target server will be merged in if there is no
serverEnvFile` configured nor `server.env` file located in the `configDirectory`, and the "keystore_password" env var is not defined as a Maven property.
If Liberty configuration is specified with Maven properties, the above indicated files are created in the target Liberty server. By default there is no merging behavior for the Maven properties with files located in the `configDirectory` or the specific configuration file parameters such as `bootstrapPropertiesFile`, `jvmOptionsFile` and `serverEnvFile`. However, the `liberty.env.{var}` Maven properties can be merged with other configured `server.env` files by setting the `mergeServerEnv` parameter to `true`.

As a special case when `mergeServerEnv` is `false`, an existing `keystore_password` property in the default generated `server.env` file in the target server will be merged in if there is no `serverEnvFile` configured nor `server.env` file located in the `configDirectory`, and the `keystore_password` env var is not defined as a Maven property.

Note that properties specified with `-D` on the command line are also analyzed for the property name formats listed above and take precedence over Maven properties specified in the pom.xml.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -554,19 +554,17 @@ private Map<String, String> mergeSpecialPropsFromInstallServerEnvIfAbsent(Map<St

String[] specialProps = { "keystore_password" };

Map<String, String> mergedProps = new HashMap<String,String>();

// Clone to avoid side effects
for (String key : envProps.keySet()) {
mergedProps.put(key, envProps.get(key));
}

Map<String, String> mergedProps = new HashMap<String,String>(envProps);

// From install (target) dir
File serverEnv = new File(serverDirectory, "server.env");
Map<String, String> serverEnvProps = convertServerEnvToProperties(serverEnv);

for (String propertyName : specialProps) {
mergedProps.putIfAbsent(propertyName, serverEnvProps.get(propertyName));
if (serverEnvProps.containsKey(propertyName)) {
mergedProps.putIfAbsent(propertyName,serverEnvProps.get(propertyName));
}
}

return mergedProps;
Expand Down

0 comments on commit 443b0f4

Please sign in to comment.