diff --git a/changes.xml b/changes.xml
index 9e55499b..def3d735 100644
--- a/changes.xml
+++ b/changes.xml
@@ -23,6 +23,15 @@
xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 https://maven.apache.org/plugins/maven-changes-plugin/xsd/changes-1.0.0.xsd">
+
+
+ Special handling for detecting ".cfg.json" file extensions.
+
+
+ Remove Guava dependency.
+
+
+
Increase SnakeYAML codepoint limit to 64MB (from default 3MB).
diff --git a/generator/pom.xml b/generator/pom.xml
index eab9a2f7..f11dacce 100644
--- a/generator/pom.xml
+++ b/generator/pom.xml
@@ -25,7 +25,7 @@
io.wcm.devops.conga
io.wcm.devops.conga.parent
- 1.16.4
+ 1.17.0
../parent/pom.xml
@@ -44,7 +44,7 @@
io.wcm.devops.conga
io.wcm.devops.conga.model
- 1.16.4
+ 1.17.0
compile
@@ -54,6 +54,12 @@
compile
+
+ com.github.ben-manes.caffeine
+ caffeine
+ compile
+
+
com.github.jknack
handlebars
diff --git a/generator/src/main/java/io/wcm/devops/conga/generator/ContextPropertiesBuilder.java b/generator/src/main/java/io/wcm/devops/conga/generator/ContextPropertiesBuilder.java
index a0a55c25..61d1fd75 100644
--- a/generator/src/main/java/io/wcm/devops/conga/generator/ContextPropertiesBuilder.java
+++ b/generator/src/main/java/io/wcm/devops/conga/generator/ContextPropertiesBuilder.java
@@ -32,6 +32,7 @@
import static io.wcm.devops.conga.generator.ContextProperties.TENANTS_BY_ROLE;
import static io.wcm.devops.conga.generator.ContextProperties.TENANT_ROLES;
import static io.wcm.devops.conga.generator.ContextProperties.VERSION;
+import static java.util.Map.entry;
import java.util.ArrayList;
import java.util.Collections;
@@ -39,8 +40,6 @@
import java.util.List;
import java.util.Map;
-import com.google.common.collect.ImmutableMap;
-
import io.wcm.devops.conga.generator.util.ObjectCloner;
import io.wcm.devops.conga.generator.util.VariableObjectTreeResolver;
import io.wcm.devops.conga.generator.util.VariableStringResolver;
@@ -55,20 +54,20 @@
*/
public final class ContextPropertiesBuilder {
- static final Map EMPTY_CONTEXT_VARIABLES = ImmutableMap.builder()
- .put(VERSION, "")
- .put(ENVIRONMENT, "")
- .put(NODES, Collections.emptyList())
- .put(NODES_BY_ROLE, Collections.emptyMap())
- .put(NODES_BY_ROLE_VARIANT, Collections.emptyMap())
- .put(TENANTS, Collections.emptyMap())
- .put(TENANTS_BY_ROLE, Collections.emptyMap())
- .put(ROLE, "")
- .put(ROLE_VARIANT, "")
- .put(NODE, "")
- .put(TENANT, "")
- .put(TENANT_ROLES, Collections.emptyList())
- .build();
+ static final Map EMPTY_CONTEXT_VARIABLES = Map.ofEntries(
+ entry(VERSION, ""),
+ entry(ENVIRONMENT, ""),
+ entry(NODES, Collections.emptyList()),
+ entry(NODES_BY_ROLE, Collections.emptyMap()),
+ entry(NODES_BY_ROLE_VARIANT, Collections.emptyMap()),
+ entry(TENANTS, Collections.emptyMap()),
+ entry(TENANTS_BY_ROLE, Collections.emptyMap()),
+ entry(ROLE, ""),
+ entry(ROLE_VARIANT, ""),
+ entry(NODE, ""),
+ entry(TENANT, ""),
+ entry(TENANT_ROLES, Collections.emptyList())
+ );
private ContextPropertiesBuilder() {
// static methods only
@@ -83,6 +82,7 @@ private ContextPropertiesBuilder() {
* @param variableStringResolver Variable string resolver
* @return Context variables map
*/
+ @SuppressWarnings("java:S3776") // ignore complexity
public static Map buildEnvironmentContextVariables(String environmentName,
Environment environment, String version,
VariableObjectTreeResolver variableObjectTreeResolver, VariableStringResolver variableStringResolver) {
diff --git a/generator/src/main/java/io/wcm/devops/conga/generator/EnvironmentGenerator.java b/generator/src/main/java/io/wcm/devops/conga/generator/EnvironmentGenerator.java
index 4f60920e..6b78a15e 100644
--- a/generator/src/main/java/io/wcm/devops/conga/generator/EnvironmentGenerator.java
+++ b/generator/src/main/java/io/wcm/devops/conga/generator/EnvironmentGenerator.java
@@ -22,6 +22,7 @@
import java.io.File;
import java.io.IOException;
import java.net.URL;
+import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -40,9 +41,6 @@
import com.github.jknack.handlebars.Handlebars;
import com.github.jknack.handlebars.Template;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.wcm.devops.conga.generator.export.NodeModelExport;
@@ -82,7 +80,7 @@
/**
* Generates file for one environment.
*/
-class EnvironmentGenerator {
+final class EnvironmentGenerator {
private final GeneratorOptions options;
private final String environmentName;
@@ -132,10 +130,10 @@ class EnvironmentGenerator {
ResourceLoader resourceLoader = new ResourceLoader(resourceClassLoader);
// prepare template and role directories
- List templateDirs = ImmutableList.of(
+ List templateDirs = List.of(
resourceLoader.getResourceCollection(ResourceLoader.FILE_PREFIX + options.getTemplateDir()),
resourceLoader.getResourceCollection(ResourceLoader.CLASSPATH_PREFIX + GeneratorOptions.CLASSPATH_TEMPLATES_DIR));
- List roleDirs = ImmutableList.of(
+ List roleDirs = List.of(
resourceLoader.getResourceCollection(ResourceLoader.FILE_PREFIX + options.getRoleDir()),
resourceLoader.getResourceCollection(ResourceLoader.CLASSPATH_PREFIX + GeneratorOptions.CLASSPATH_ROLES_DIR));
@@ -154,11 +152,11 @@ class EnvironmentGenerator {
this.handlebarsManager = new HandlebarsManager(templateDirs, this.pluginContextOptions);
this.defaultMultiplyPlugin = options.getPluginManager().get(NoneMultiply.NAME, MultiplyPlugin.class);
- this.environmentContextProperties = ImmutableMap.copyOf(
+ this.environmentContextProperties = Collections.unmodifiableMap(
ContextPropertiesBuilder.buildEnvironmentContextVariables(environmentName, this.environment, options.getVersion(),
variableObjectTreeResolver, variableStringResolver));
- this.dependencyVersions = options.getDependencyVersionBuilder() != null ? options.getDependencyVersionBuilder().apply(environment) : ImmutableList.of();
+ this.dependencyVersions = options.getDependencyVersionBuilder() != null ? options.getDependencyVersionBuilder().apply(environment) : List.of();
// prepare YAML representer
yamlRepresenter = new YamlRepresenter();
@@ -178,7 +176,7 @@ public void generate(String[] nodeNames) {
log.info("");
log.info("===== Environment '{}' =====", environmentName);
- Set nodeNamesIndex = ArrayUtils.isEmpty(nodeNames) ? Collections.emptySet() : ImmutableSet.copyOf(nodeNames);
+ Set nodeNamesIndex = ArrayUtils.isEmpty(nodeNames) ? Collections.emptySet() : Set.of(nodeNames);
for (Node node : environment.getNodes()) {
if (isSelectedNode(node, nodeNamesIndex)) {
generateNode(node);
@@ -241,8 +239,7 @@ private void generateNode(Node node) {
mergedConfig.putAll(ContextPropertiesBuilder.buildCurrentContextVariables(node, nodeRole));
// collect role and tenant information for export model
- ExportNodeRoleData exportNodeRoleData = exportModelGenerator.addRole(roleName, variants, mergedConfig,
- role.getSensitiveConfigParameters());
+ ExportNodeRoleData exportNodeRoleData = exportModelGenerator.addRole(roleName, variants, mergedConfig);
// generate files
List allFiles = new ArrayList<>();
@@ -321,6 +318,7 @@ private String getEscapingStrategy(RoleFile roleFile) {
.getName();
}
+ @SuppressWarnings("java:S107") // allow many parameters
private void multiplyFiles(Role role, RoleFile roleFile, Map config, File nodeDir, Template template,
String roleName, List roleVariantNames, String templateName, List generatedFiles) {
MultiplyPlugin multiplyPlugin = defaultMultiplyPlugin;
@@ -367,7 +365,10 @@ private void multiplyFiles(Role role, RoleFile roleFile, Map con
}
}
- @SuppressWarnings("PMD.PreserveStackTrace")
+ @SuppressWarnings({
+ "PMD.PreserveStackTrace",
+ "java:S107" // allow many parameters
+ })
@SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_BAD_PRACTICE")
private Collection generateFile(RoleFile roleFile, String dir,
String fileName, String url, String symlinkTarget,
@@ -386,7 +387,12 @@ private Collection generateFile(RoleFile roleFile, String
File file = new File(nodeDir, dir != null ? FilenameUtils.concat(dir, generatedFileName) : generatedFileName);
if (file.exists()) {
- file.delete();
+ try {
+ Files.delete(file.toPath());
+ }
+ catch (IOException ex) {
+ throw new GeneratorException("Unable to delete: " + FileUtil.getCanonicalPath(file), ex);
+ }
}
FileGenerator fileGenerator = new FileGenerator(options, environmentName,
diff --git a/generator/src/main/java/io/wcm/devops/conga/generator/FileGenerator.java b/generator/src/main/java/io/wcm/devops/conga/generator/FileGenerator.java
index e21aac75..09f233e3 100644
--- a/generator/src/main/java/io/wcm/devops/conga/generator/FileGenerator.java
+++ b/generator/src/main/java/io/wcm/devops/conga/generator/FileGenerator.java
@@ -42,7 +42,6 @@
import org.slf4j.Logger;
import com.github.jknack.handlebars.Template;
-import com.google.common.collect.ImmutableList;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.wcm.devops.conga.generator.plugins.fileheader.NoneFileHeader;
@@ -98,14 +97,13 @@ class FileGenerator {
static final String POSTPROCESSOR_KEY_FILE_HEADER = "postProcessor.fileHeader";
static final String POSTPROCESSOR_KEY_VALIDATORS = "postProcessor.validators";
- //CHECKSTYLE:OFF
+ @SuppressWarnings({ "java:S107", "checkstyle:ParameterNumberCheck" }) // allow many parameters
FileGenerator(GeneratorOptions options, String environmentName,
String roleName, List roleVariantNames, String templateName,
File nodeDir, File file, String url, String symlinkTarget,
RoleFile roleFile, Map config, Template template,
VariableMapResolver variableMapResolver, UrlFileManager urlFileManager, PluginContextOptions pluginContextOptions,
Collection dependencyVersions) {
- //CHECKSTYLE:ON
this.environmentName = environmentName;
this.roleName = roleName;
this.roleVariantNames = roleVariantNames;
@@ -207,6 +205,10 @@ private List formatFileHeaderCommentLines(List lines) {
* @return List of files that where generated directly or indirectly (by post processors).
*/
@SuppressFBWarnings({ "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", "RV_RETURN_VALUE_IGNORED_BAD_PRACTICE" })
+ @SuppressWarnings({
+ "java:S3776", // ignore complexity
+ "java:S2696" // static variable set by intention
+ })
public Collection generate() throws IOException {
File dir = file.getParentFile();
if (!dir.exists()) {
@@ -215,7 +217,9 @@ public Collection generate() throws IOException {
Collection postProcessedFiles;
if (template != null) {
- log.info("Generate file {}", getFilenameForLog(fileContext));
+ if (log.isInfoEnabled()) {
+ log.info("Generate file {}", getFilenameForLog(fileContext));
+ }
// generate with template
generateWithTemplate();
@@ -231,7 +235,9 @@ else if (StringUtils.isNotBlank(url)) {
// if copying from a local file try to create a symlink instead of coyping it
boolean symlinkCreated = false;
if (allowSymlinks && !symlinkCreationFailed && urlFileManager.isLocalFile(url) && !roleFile.isDeleteSource()) {
- log.info("Symlink file {} from {}", getFilenameForLog(fileContext), url);
+ if (log.isInfoEnabled()) {
+ log.info("Symlink file {} from {}", getFilenameForLog(fileContext), url);
+ }
if (createSymlinkToLocalFile()) {
symlinkCreated = true;
}
@@ -242,7 +248,9 @@ else if (StringUtils.isNotBlank(url)) {
// generate by downloading/copying from URL
if (!symlinkCreated) {
- log.info("Copy file {} from {}", getFilenameForLog(fileContext), url);
+ if (log.isInfoEnabled()) {
+ log.info("Copy file {} from {}", getFilenameForLog(fileContext), url);
+ }
copyFromUrlFile();
}
@@ -310,7 +318,7 @@ private boolean createSymlinkToLocalFile() throws IOException {
}
catch (IOException ex) {
// creates symbolic link failed - log warning and fallback to copying content
- log.warn("Unable to create symbolic link: " + ex.getMessage());
+ log.warn("Unable to create symbolic link: {}", ex.getMessage());
return false;
}
}
@@ -333,7 +341,7 @@ private void createSymlinkToSymlinkTarget() throws IOException {
}
catch (IOException ex) {
// creates symbolic link failed - create text file with link instead (similar to git)
- log.warn("Created link textfile instead of symbolic link: " + ex.getMessage());
+ log.warn("Created link textfile instead of symbolic link: {}", ex.getMessage());
FileUtils.write(linkPath.toFile(), relativizedPath.toString(), StandardCharsets.UTF_8);
}
}
@@ -387,7 +395,9 @@ private void applyFileHeader(FileContext fileItem, String pluginName) {
}
private void applyFileHeader(FileContext fileItem, FileHeaderPlugin plugin) {
- log.debug(" Add {} file header to file {}", plugin.getName(), getFilenameForLog(fileItem));
+ if (log.isDebugEnabled()) {
+ log.debug(" Add {} file header to file {}", plugin.getName(), getFilenameForLog(fileItem));
+ }
plugin.apply(fileItem, fileHeaderContext);
}
@@ -398,7 +408,9 @@ private void applyValidation(FileContext fileItem, List pluginNames) {
}
private void applyValidation(FileContext fileItem, ValidatorPlugin plugin) {
- log.info(" Validate {} for file {}", plugin.getName(), getFilenameForLog(fileItem));
+ if (log.isInfoEnabled()) {
+ log.info(" Validate {} for file {}", plugin.getName(), getFilenameForLog(fileItem));
+ }
plugin.apply(fileItem, validatorContext);
}
@@ -423,7 +435,7 @@ private Collection applyPostProcessor(FileContext fileItem
private void applyPostProcessor(Map consolidatedFiles, PostProcessorPlugin plugin) {
// process all files from given map
- ImmutableList.copyOf(consolidatedFiles.values()).stream()
+ List.copyOf(consolidatedFiles.values()).stream()
// do not apply post processor twice
.filter(fileItem -> !fileItem.getPostProcessors().contains(plugin.getName()))
.filter(fileItem -> plugin.accepts(fileItem.getFileContext(), postProcessorContext))
@@ -441,14 +453,14 @@ private void applyPostProcessor(Map consolidatedFi
});
// remove items that do no longer exist
- ImmutableList.copyOf(consolidatedFiles.values()).forEach(fileItem -> {
+ List.copyOf(consolidatedFiles.values()).forEach(fileItem -> {
if (!fileItem.getFileContext().getFile().exists()) {
consolidatedFiles.remove(fileItem.getFileContext().getCanonicalPath());
}
});
// apply post processor configured as implicit ALWAYS
- consolidatedFiles.values().forEach(fileItem -> {
+ consolidatedFiles.values().forEach(fileItem ->
pluginManager.getAll(PostProcessorPlugin.class).stream()
.filter(implicitPlugin -> implicitPlugin.accepts(fileItem.getFileContext(), postProcessorContext))
.filter(implicitPlugin -> implicitPlugin.implicitApply(fileItem.getFileContext(), postProcessorContext) == ImplicitApplyOptions.ALWAYS)
@@ -465,11 +477,11 @@ private void applyPostProcessor(Map consolidatedFi
}
generatedFileContext.postProcessor(implicitPlugin.getName());
});
- });
- });
+ })
+ );
// remove items that do no longer exist
- ImmutableList.copyOf(consolidatedFiles.values()).forEach(fileItem -> {
+ List.copyOf(consolidatedFiles.values()).forEach(fileItem -> {
if (!fileItem.getFileContext().getFile().exists()) {
consolidatedFiles.remove(fileItem.getFileContext().getCanonicalPath());
}
@@ -478,7 +490,9 @@ private void applyPostProcessor(Map consolidatedFi
}
private List applyPostProcessor(FileContext fileItem, PostProcessorPlugin plugin) {
- log.info(" Post-process {} for file {}", plugin.getName(), getFilenameForLog(fileItem));
+ if (log.isInfoEnabled()) {
+ log.info(" Post-process {} for file {}", plugin.getName(), getFilenameForLog(fileItem));
+ }
List processedFiles = plugin.apply(fileItem, postProcessorContext);
@@ -510,7 +524,7 @@ private List getPostProcessorValidators() {
return (List)validators;
}
else {
- return ImmutableList.of();
+ return List.of();
}
}
diff --git a/generator/src/main/java/io/wcm/devops/conga/generator/Generator.java b/generator/src/main/java/io/wcm/devops/conga/generator/Generator.java
index 138dfa94..03217b42 100644
--- a/generator/src/main/java/io/wcm/devops/conga/generator/Generator.java
+++ b/generator/src/main/java/io/wcm/devops/conga/generator/Generator.java
@@ -27,8 +27,6 @@
import org.apache.commons.io.FileUtils;
-import com.google.common.collect.ImmutableList;
-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.wcm.devops.conga.generator.util.FileUtil;
import io.wcm.devops.conga.model.environment.Environment;
@@ -54,7 +52,7 @@ public Generator(GeneratorOptions options) {
ClassLoader resourceClassLoader = ResourceLoaderUtil.buildClassLoader(options.getContainerClasspathUrls());
ResourceLoader resourceLoader = new ResourceLoader(resourceClassLoader);
- List environmentDirs = ImmutableList.of(
+ List environmentDirs = List.of(
resourceLoader.getResourceCollection(ResourceLoader.FILE_PREFIX + options.getEnvironmentDir()),
resourceLoader.getResourceCollection(ResourceLoader.CLASSPATH_PREFIX + GeneratorOptions.CLASSPATH_ENVIRONMENTS_DIR));
this.environments = ResourceLoaderUtil.readModels(environmentDirs, new EnvironmentReader());
@@ -74,6 +72,7 @@ public void generate(String[] environmentNames) {
* @param nodeNames Node names to generate. If none specified all nodes are generated.
*/
@SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_BAD_PRACTICE")
+ @SuppressWarnings("java:S3776") // ignore complexity
public void generate(String[] environmentNames, String[] nodeNames) {
Map selectedEnvironments = new HashMap<>();
if (environmentNames == null || environmentNames.length == 0) {
diff --git a/generator/src/main/java/io/wcm/devops/conga/generator/ResourceLoaderUtil.java b/generator/src/main/java/io/wcm/devops/conga/generator/ResourceLoaderUtil.java
index f27034da..abe01365 100644
--- a/generator/src/main/java/io/wcm/devops/conga/generator/ResourceLoaderUtil.java
+++ b/generator/src/main/java/io/wcm/devops/conga/generator/ResourceLoaderUtil.java
@@ -23,14 +23,13 @@
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.io.FilenameUtils;
-import com.google.common.collect.ImmutableMap;
-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.wcm.devops.conga.generator.spi.context.PluginContextOptions;
import io.wcm.devops.conga.generator.spi.context.UrlFilePluginContext;
@@ -79,7 +78,7 @@ public static List getEnvironmentClasspathUrls(List dependencyUrls,
List classpathUrls = new ArrayList<>();
for (String dependencyUrl : dependencyUrls) {
// resolver variables without config map - thus supporting only value providers with external values
- String resolvedDependencyUrl = variableStringResolver.resolveString(dependencyUrl, ImmutableMap.of());
+ String resolvedDependencyUrl = variableStringResolver.resolveString(dependencyUrl, Map.of());
try {
classpathUrls.addAll(urlFileManager.getFileUrlsWithDependencies(resolvedDependencyUrl));
}
@@ -114,7 +113,7 @@ public static Map readModels(List dirs, Model
}
}
}
- return ImmutableMap.copyOf(models);
+ return Collections.unmodifiableMap(models);
}
}
diff --git a/generator/src/main/java/io/wcm/devops/conga/generator/export/NodeModelExport.java b/generator/src/main/java/io/wcm/devops/conga/generator/export/NodeModelExport.java
index ae82efc4..6ec58493 100644
--- a/generator/src/main/java/io/wcm/devops/conga/generator/export/NodeModelExport.java
+++ b/generator/src/main/java/io/wcm/devops/conga/generator/export/NodeModelExport.java
@@ -71,6 +71,7 @@ public final class NodeModelExport {
* environment.
* @param yamlRepresenter YAML representer
*/
+ @SuppressWarnings("java:S107") // allow many parameters
public NodeModelExport(File nodeDir, Node node, Environment environment, ModelExport modelExport,
VariableStringResolver variableStringResolver, VariableMapResolver variableMapResolver,
Map containerVersionInfo, PluginContextOptions pluginContextOptions,
@@ -105,11 +106,9 @@ private boolean isActive() {
* @param role Role name
* @param roleVariants Role variant name
* @param config Merged configuration (unresolved)
- * @param sensitiveConfigParametersList List of configuration parameter names that contain sensitive data
* @return Node role data
*/
- public ExportNodeRoleData addRole(String role, List roleVariants, Map config,
- List sensitiveConfigParametersList) {
+ public ExportNodeRoleData addRole(String role, List roleVariants, Map config) {
if (!isActive()) {
return new ExportNodeRoleData();
}
diff --git a/generator/src/main/java/io/wcm/devops/conga/generator/handlebars/CharsetAwareTemplateSource.java b/generator/src/main/java/io/wcm/devops/conga/generator/handlebars/CharsetAwareTemplateSource.java
index 5c8404c4..550722b8 100644
--- a/generator/src/main/java/io/wcm/devops/conga/generator/handlebars/CharsetAwareTemplateSource.java
+++ b/generator/src/main/java/io/wcm/devops/conga/generator/handlebars/CharsetAwareTemplateSource.java
@@ -32,6 +32,7 @@
/**
* Charset-aware TemplateSource for handlebars.
*/
+@SuppressWarnings("java:S2160") // equals/hashCode is implemented in base class
class CharsetAwareTemplateSource extends AbstractTemplateSource {
private final Resource file;
diff --git a/generator/src/main/java/io/wcm/devops/conga/generator/handlebars/HandlebarsManager.java b/generator/src/main/java/io/wcm/devops/conga/generator/handlebars/HandlebarsManager.java
index 96b5855d..fa8a3f03 100644
--- a/generator/src/main/java/io/wcm/devops/conga/generator/handlebars/HandlebarsManager.java
+++ b/generator/src/main/java/io/wcm/devops/conga/generator/handlebars/HandlebarsManager.java
@@ -21,9 +21,10 @@
import java.io.IOException;
import java.util.List;
-import java.util.concurrent.ExecutionException;
-import com.github.jknack.handlebars.EscapingStrategy;
+import com.github.benmanes.caffeine.cache.CacheLoader;
+import com.github.benmanes.caffeine.cache.Caffeine;
+import com.github.benmanes.caffeine.cache.LoadingCache;
import com.github.jknack.handlebars.Handlebars;
import com.github.jknack.handlebars.Helper;
import com.github.jknack.handlebars.Options;
@@ -31,11 +32,7 @@
import com.github.jknack.handlebars.helper.ConditionalHelpers;
import com.github.jknack.handlebars.helper.StringHelpers;
import com.github.jknack.handlebars.io.TemplateLoader;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-import io.wcm.devops.conga.generator.GeneratorException;
import io.wcm.devops.conga.generator.spi.context.PluginContextOptions;
import io.wcm.devops.conga.generator.spi.handlebars.EscapingStrategyPlugin;
import io.wcm.devops.conga.generator.spi.handlebars.HelperPlugin;
@@ -55,7 +52,7 @@ public class HandlebarsManager {
private final HelperContext helperContext;
private final LoadingCache handlebarsCache =
- CacheBuilder.newBuilder().build(new CacheLoader() {
+ Caffeine.newBuilder().build(new CacheLoader() {
@SuppressWarnings("unchecked")
@Override
public Handlebars load(HandlebarsKey options) throws Exception {
@@ -63,12 +60,8 @@ public Handlebars load(HandlebarsKey options) throws Exception {
// setup handlebars
TemplateLoader templateLoader = new CharsetAwareTemplateLoader(templateDirs, options.getCharset());
EscapingStrategyPlugin escapingStrategy = pluginManager.get(options.getEscapingStrategy(), EscapingStrategyPlugin.class);
- Handlebars handlebars = new Handlebars(templateLoader).with(new EscapingStrategy() {
- @Override
- public CharSequence escape(CharSequence value) {
- return escapingStrategy.escape(value, escapingStrategyContext);
- }
- });
+ Handlebars handlebars = new Handlebars(templateLoader)
+ .with(value -> escapingStrategy.escape(value, escapingStrategyContext));
// register helpers provided by JKnack Handlebars implementation
handlebars.registerHelpers(StringHelpers.class);
@@ -108,12 +101,7 @@ public HandlebarsManager(List templateDirs, PluginContextOpt
*/
public Handlebars get(String escapingStrategy, String charset) {
HandlebarsKey key = new HandlebarsKey(escapingStrategy, charset);
- try {
- return handlebarsCache.get(key);
- }
- catch (ExecutionException ex) {
- throw new GeneratorException("Unable to get handlebars instance for " + key.toString(), ex);
- }
+ return handlebarsCache.get(key);
}
}
diff --git a/generator/src/main/java/io/wcm/devops/conga/generator/plugins/export/YamlNodeModelExport.java b/generator/src/main/java/io/wcm/devops/conga/generator/plugins/export/YamlNodeModelExport.java
index 28432392..edd3ab21 100644
--- a/generator/src/main/java/io/wcm/devops/conga/generator/plugins/export/YamlNodeModelExport.java
+++ b/generator/src/main/java/io/wcm/devops/conga/generator/plugins/export/YamlNodeModelExport.java
@@ -24,17 +24,16 @@
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.TreeMap;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.yaml.snakeyaml.Yaml;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSortedMap;
-
import io.wcm.devops.conga.generator.GeneratorException;
import io.wcm.devops.conga.generator.spi.export.NodeModelExportPlugin;
import io.wcm.devops.conga.generator.spi.export.context.ExportNodeRoleData;
@@ -74,7 +73,7 @@ public void export(NodeModelExportContext context) {
Map versionInfo = context.getContainerVersionInfo();
if (versionInfo != null) {
- modelMap.put("versionInfo", ImmutableSortedMap.copyOf(versionInfo));
+ modelMap.put("versionInfo", Collections.unmodifiableSortedMap(new TreeMap<>(versionInfo)));
}
// save YAML file
@@ -101,7 +100,7 @@ private void addRole(List