| | |
| | | if (propertiesFile != null && propertiesFile.exists() && (forceReload || (propertiesFile.lastModified() > lastModified))) {
|
| | | FileInputStream is = null;
|
| | | try {
|
| | | logger.debug("loading {}", propertiesFile);
|
| | | Properties props = new Properties();
|
| | | is = new FileInputStream(propertiesFile);
|
| | | props.load(is);
|
| | |
| | | if (!StringUtils.isEmpty(include)) {
|
| | |
|
| | | // allow for multiples
|
| | | List<String> names = StringUtils.getStringsFromValue(include, " ");
|
| | | List<String> names = StringUtils.getStringsFromValue(include, ",");
|
| | | for (String name : names) {
|
| | |
|
| | | if (StringUtils.isEmpty(name)) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | // try co-located
|
| | | File file = new File(propertiesFile.getParentFile(), name.trim());
|
| | |
| | | file = new File(name.trim());
|
| | | }
|
| | |
|
| | | if (file.exists()) {
|
| | | // load properties
|
| | | try (FileInputStream iis = new FileInputStream(file)) {
|
| | | baseProperties.load(iis);
|
| | | }
|
| | |
|
| | | // read nested includes
|
| | | baseProperties = readIncludes(baseProperties);
|
| | |
|
| | | if (!file.exists()) {
|
| | | logger.warn("failed to locate {}", file);
|
| | | continue;
|
| | | }
|
| | |
|
| | | // load properties
|
| | | logger.debug("loading {}", file);
|
| | | try (FileInputStream iis = new FileInputStream(file)) {
|
| | | baseProperties.load(iis);
|
| | | }
|
| | |
|
| | | // read nested includes
|
| | | baseProperties = readIncludes(baseProperties);
|
| | |
|
| | | }
|
| | |
|
| | |
| | | String content = FileUtils.readContent(propertiesFile, "\n");
|
| | | for (String key : removals) {
|
| | | String regex = "(?m)^(" + regExEscape(key) + "\\s*+=\\s*+)"
|
| | | + "(?:[^\r\n\\\\]++|\\\\(?:\r?\n|\r|.))*+$";
|
| | | + "(?:[^\r\n\\\\]++|\\\\(?:\r?\n|\r|.))*+$";
|
| | | content = content.replaceAll(regex, "");
|
| | | }
|
| | | removals.clear();
|
| | |
| | | String content = FileUtils.readContent(propertiesFile, "\n");
|
| | | for (Map.Entry<String, String> setting:settings.entrySet()) {
|
| | | String regex = "(?m)^(" + regExEscape(setting.getKey()) + "\\s*+=\\s*+)"
|
| | | + "(?:[^\r\n\\\\]++|\\\\(?:\r?\n|\r|.))*+$";
|
| | | + "(?:[^\r\n\\\\]++|\\\\(?:\r?\n|\r|.))*+$";
|
| | | String oldContent = content;
|
| | | content = content.replaceAll(regex, setting.getKey() + " = " + setting.getValue());
|
| | | if (content.equals(oldContent)) {
|