diff --git a/docs/common-server-parameters.md b/docs/common-server-parameters.md index 1e49199fd..e1638944a 100644 --- a/docs/common-server-parameters.md +++ b/docs/common-server-parameters.md @@ -121,8 +121,9 @@ Starting with the 3.1 release of the liberty-maven-plugin, support is added to s | liberty.var.{var} | `` | liberty-plugin-variable-config.xml | The server configuration file is generated in the configDropins/overrides folder of the target server. | | liberty.defaultVar.{var} | `` | 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. diff --git a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/StartDebugMojoSupport.java b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/StartDebugMojoSupport.java index 3bddc71ca..706a8143e 100644 --- a/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/StartDebugMojoSupport.java +++ b/liberty-maven-plugin/src/main/java/io/openliberty/tools/maven/server/StartDebugMojoSupport.java @@ -554,19 +554,17 @@ private Map mergeSpecialPropsFromInstallServerEnvIfAbsent(Map mergedProps = new HashMap(); - // Clone to avoid side effects - for (String key : envProps.keySet()) { - mergedProps.put(key, envProps.get(key)); - } - + Map mergedProps = new HashMap(envProps); + // From install (target) dir File serverEnv = new File(serverDirectory, "server.env"); Map 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;