diff --git a/changes.xml b/changes.xml index 8701e033..c908812c 100644 --- a/changes.xml +++ b/changes.xml @@ -23,10 +23,13 @@ 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. + diff --git a/generator/pom.xml b/generator/pom.xml index bfc58eea..39211504 100644 --- a/generator/pom.xml +++ b/generator/pom.xml @@ -25,7 +25,7 @@ io.wcm.devops.conga io.wcm.devops.conga.parent - 1.16.5-SNAPSHOT + 1.17.0-SNAPSHOT ../parent/pom.xml @@ -44,7 +44,7 @@ io.wcm.devops.conga io.wcm.devops.conga.model - 1.16.5-SNAPSHOT + 1.17.0-SNAPSHOT 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..df0bf929 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 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 3e5784b4..46eb4c0b 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 @@ -40,9 +40,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; @@ -132,10 +129,10 @@ final 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,7 +151,7 @@ final 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)); @@ -178,7 +175,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); 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 e77cfe85..89473afd 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; @@ -423,7 +422,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,7 +440,7 @@ 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()); } @@ -469,7 +468,7 @@ 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()); } 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..59d5d420 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()); 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 635a12e7..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; @@ -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/handlebars/HandlebarsManager.java b/generator/src/main/java/io/wcm/devops/conga/generator/handlebars/HandlebarsManager.java index 96b5855d..cecdc308 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,8 +21,10 @@ import java.io.IOException; import java.util.List; -import java.util.concurrent.ExecutionException; +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.EscapingStrategy; import com.github.jknack.handlebars.Handlebars; import com.github.jknack.handlebars.Helper; @@ -31,11 +33,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 +53,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 { @@ -108,12 +106,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> modelList, ExportNodeRoleData rol Map itemMap = new LinkedHashMap<>(); itemMap.put("path", cleanupFileName(item.getFileContext().getCanonicalPath(), nodeDirPath)); if (!item.getPostProcessors().isEmpty()) { - itemMap.put("postProcessors", ImmutableList.copyOf(item.getPostProcessors())); + itemMap.put("postProcessors", List.copyOf(item.getPostProcessors())); } Map modelOptions = item.getFileContext().getModelOptions(); if (modelOptions != null) { diff --git a/generator/src/main/java/io/wcm/devops/conga/generator/plugins/fileheader/AbstractFileHeader.java b/generator/src/main/java/io/wcm/devops/conga/generator/plugins/fileheader/AbstractFileHeader.java index 95a01b08..81bcaf8c 100644 --- a/generator/src/main/java/io/wcm/devops/conga/generator/plugins/fileheader/AbstractFileHeader.java +++ b/generator/src/main/java/io/wcm/devops/conga/generator/plugins/fileheader/AbstractFileHeader.java @@ -21,6 +21,7 @@ import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; @@ -28,8 +29,6 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; -import com.google.common.collect.ImmutableList; - import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import io.wcm.devops.conga.generator.GeneratorException; import io.wcm.devops.conga.generator.spi.FileHeaderPlugin; @@ -120,7 +119,7 @@ protected final FileHeaderContext extractFileHeaderBetweenBlockStartEnd(FileCont int posBlockEnd = content.indexOf(getCommentBlockEnd()); if (posBlockStart == insertPosition && posBlockEnd > 0) { String fileHeader = content.substring(posBlockStart + getCommentBlockStart().length(), posBlockEnd); - List lines = ImmutableList.copyOf(StringUtils.split(fileHeader, getLineBreak())); + List lines = Arrays.asList(StringUtils.split(fileHeader, getLineBreak())); return new FileHeaderContext().commentLines(lines); } } diff --git a/generator/src/main/java/io/wcm/devops/conga/generator/plugins/fileheader/XmlFileHeader.java b/generator/src/main/java/io/wcm/devops/conga/generator/plugins/fileheader/XmlFileHeader.java index 3d0c9731..aa8a5ec2 100644 --- a/generator/src/main/java/io/wcm/devops/conga/generator/plugins/fileheader/XmlFileHeader.java +++ b/generator/src/main/java/io/wcm/devops/conga/generator/plugins/fileheader/XmlFileHeader.java @@ -21,6 +21,7 @@ import java.io.IOException; import java.nio.file.Files; +import java.util.Arrays; import java.util.List; import javax.xml.XMLConstants; @@ -40,8 +41,6 @@ import org.w3c.dom.Node; import org.xml.sax.SAXException; -import com.google.common.collect.ImmutableList; - import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import io.wcm.devops.conga.generator.GeneratorException; import io.wcm.devops.conga.generator.spi.FileHeaderPlugin; @@ -121,7 +120,7 @@ public FileHeaderContext extract(FileContext file) { Node firstNode = doc.getChildNodes().item(0); if (firstNode instanceof Comment) { String comment = StringUtils.trim(((Comment)firstNode).getTextContent()); - List lines = ImmutableList.copyOf(StringUtils.split(comment, "\n")); + List lines = Arrays.asList(StringUtils.split(comment, "\n")); return new FileHeaderContext().commentLines(lines); } } diff --git a/generator/src/main/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/AbstractEachIfHelper.java b/generator/src/main/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/AbstractEachIfHelper.java index e8fc8531..d7d23528 100644 --- a/generator/src/main/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/AbstractEachIfHelper.java +++ b/generator/src/main/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/AbstractEachIfHelper.java @@ -21,6 +21,7 @@ import java.io.IOException; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Objects; @@ -34,7 +35,6 @@ import com.github.jknack.handlebars.Helper; import com.github.jknack.handlebars.Options; import com.github.jknack.handlebars.helper.EachHelper; -import com.google.common.collect.ImmutableList; import io.wcm.devops.conga.generator.spi.handlebars.HelperPlugin; import io.wcm.devops.conga.generator.spi.handlebars.context.HelperContext; @@ -67,7 +67,7 @@ public final Object apply(Object context, Options options, HelperContext pluginC } } else { - return apply(ImmutableList.of(context), options, pluginContext); + return apply(List.of(context), options, pluginContext); } } return delegate.apply(context, options); diff --git a/generator/src/main/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/EachIfEqualsHelper.java b/generator/src/main/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/EachIfEqualsHelper.java index 276b06f1..920b5ea2 100644 --- a/generator/src/main/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/EachIfEqualsHelper.java +++ b/generator/src/main/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/EachIfEqualsHelper.java @@ -19,7 +19,7 @@ */ package io.wcm.devops.conga.generator.plugins.handlebars.helper; -import com.google.common.base.Objects; +import java.util.Objects; /** * Handlebars helper that extends the each helper by iterating only on list items that have a specified property set to @@ -41,7 +41,7 @@ public EachIfEqualsHelper() { if (expectedValue == null) { return false; } - return Objects.equal(value, expectedValue); + return Objects.equals(value, expectedValue); }); } diff --git a/generator/src/main/java/io/wcm/devops/conga/generator/plugins/multiply/NoneMultiply.java b/generator/src/main/java/io/wcm/devops/conga/generator/plugins/multiply/NoneMultiply.java index ab89e002..485bfc71 100644 --- a/generator/src/main/java/io/wcm/devops/conga/generator/plugins/multiply/NoneMultiply.java +++ b/generator/src/main/java/io/wcm/devops/conga/generator/plugins/multiply/NoneMultiply.java @@ -22,8 +22,6 @@ import java.util.List; import java.util.Map; -import com.google.common.collect.ImmutableList; - import io.wcm.devops.conga.generator.spi.MultiplyPlugin; import io.wcm.devops.conga.generator.spi.context.MultiplyContext; @@ -44,7 +42,7 @@ public String getName() { @Override public List> multiply(MultiplyContext context) { - return ImmutableList.of(context.getConfig()); + return List.of(context.getConfig()); } } diff --git a/generator/src/main/java/io/wcm/devops/conga/generator/spi/UrlFilePlugin.java b/generator/src/main/java/io/wcm/devops/conga/generator/spi/UrlFilePlugin.java index 5f8f0ed3..d2f480d4 100644 --- a/generator/src/main/java/io/wcm/devops/conga/generator/spi/UrlFilePlugin.java +++ b/generator/src/main/java/io/wcm/devops/conga/generator/spi/UrlFilePlugin.java @@ -25,8 +25,6 @@ import java.net.URL; import java.util.List; -import com.google.common.collect.ImmutableList; - import io.wcm.devops.conga.generator.spi.context.UrlFilePluginContext; /** @@ -80,7 +78,7 @@ default URL getFileUrl(String url, UrlFilePluginContext context) throws IOExcept * @throws IOException If the access to the file failed */ default List getFileUrlsWithDependencies(String url, UrlFilePluginContext context) throws IOException { - return ImmutableList.of(getFileUrl(url, context)); + return List.of(getFileUrl(url, context)); } /** diff --git a/generator/src/main/java/io/wcm/devops/conga/generator/util/PluginManagerImpl.java b/generator/src/main/java/io/wcm/devops/conga/generator/util/PluginManagerImpl.java index ef987fac..8bbcefcc 100644 --- a/generator/src/main/java/io/wcm/devops/conga/generator/util/PluginManagerImpl.java +++ b/generator/src/main/java/io/wcm/devops/conga/generator/util/PluginManagerImpl.java @@ -23,12 +23,10 @@ import java.util.ServiceLoader; import java.util.SortedMap; import java.util.TreeMap; -import java.util.concurrent.ExecutionException; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.ImmutableList; +import com.github.benmanes.caffeine.cache.CacheLoader; +import com.github.benmanes.caffeine.cache.Caffeine; +import com.github.benmanes.caffeine.cache.LoadingCache; import io.wcm.devops.conga.generator.GeneratorException; import io.wcm.devops.conga.generator.spi.Plugin; @@ -39,7 +37,7 @@ public final class PluginManagerImpl implements PluginManager { private final LoadingCache, SortedMap> pluginCache = - CacheBuilder.newBuilder().build(new CacheLoader, SortedMap>() { + Caffeine.newBuilder().build(new CacheLoader, SortedMap>() { @Override public SortedMap load(Class pluginClass) throws Exception { ServiceLoader loadedPlugins = ServiceLoader.load(pluginClass); @@ -66,16 +64,11 @@ public SortedMap load(Class pluginClass) throws Exceptio @Override @SuppressWarnings("unchecked") public T get(String name, Class pluginClass) throws GeneratorException { - try { - Plugin plugin = pluginCache.get((Class)pluginClass).get(name); - if (plugin == null) { - throw new GeneratorException(pluginClass.getSimpleName() + " not found: '" + name + "'"); - } - return (T)plugin; - } - catch (ExecutionException ex) { - throw new GeneratorException("Untable to build plugin cache for " + pluginClass.getName(), ex); + Plugin plugin = pluginCache.get((Class)pluginClass).get(name); + if (plugin == null) { + throw new GeneratorException(pluginClass.getSimpleName() + " not found: '" + name + "'"); } + return (T)plugin; } /** @@ -88,12 +81,7 @@ public T get(String name, Class pluginClass) throws Genera @Override @SuppressWarnings("unchecked") public List getAll(Class pluginClass) throws GeneratorException { - try { - return (List)ImmutableList.copyOf(pluginCache.get((Class)pluginClass).values()); - } - catch (ExecutionException ex) { - throw new GeneratorException("Untable to build plugin cache for " + pluginClass.getName(), ex); - } + return (List)List.copyOf(pluginCache.get((Class)pluginClass).values()); } } diff --git a/generator/src/main/java/io/wcm/devops/conga/generator/util/RoleUtil.java b/generator/src/main/java/io/wcm/devops/conga/generator/util/RoleUtil.java index ea3418c2..e103fd10 100644 --- a/generator/src/main/java/io/wcm/devops/conga/generator/util/RoleUtil.java +++ b/generator/src/main/java/io/wcm/devops/conga/generator/util/RoleUtil.java @@ -28,8 +28,6 @@ import org.apache.commons.lang3.StringUtils; -import com.google.common.collect.ImmutableList; - import io.wcm.devops.conga.generator.GeneratorException; import io.wcm.devops.conga.model.role.Role; import io.wcm.devops.conga.model.role.RoleFile; @@ -159,8 +157,8 @@ private static void mergeRoleConfig(Role role, Role superRole) { Set sensitiveConfigParameters = new HashSet<>(); sensitiveConfigParameters.addAll(role.getSensitiveConfigParameters()); sensitiveConfigParameters.addAll(superRole.getSensitiveConfigParameters()); - role.setSensitiveConfigParameters(ImmutableList.copyOf(sensitiveConfigParameters)); - superRole.setSensitiveConfigParameters(ImmutableList.copyOf(sensitiveConfigParameters)); + role.setSensitiveConfigParameters(List.copyOf(sensitiveConfigParameters)); + superRole.setSensitiveConfigParameters(List.copyOf(sensitiveConfigParameters)); } /** @@ -170,7 +168,7 @@ private static void mergeRoleConfig(Role role, Role superRole) { * @param resolvedRoles Resolved roles */ private static void removeFileDuplicates(Map resolvedRoles) { - List roles = ImmutableList.copyOf(resolvedRoles.values()); + List roles = List.copyOf(resolvedRoles.values()); // super roles are first, sub roles last. // got from last to first, collect all generated file definitions and remove duplicates diff --git a/generator/src/main/java/io/wcm/devops/conga/generator/util/VariableMapResolver.java b/generator/src/main/java/io/wcm/devops/conga/generator/util/VariableMapResolver.java index 67c362af..a73b8fdb 100644 --- a/generator/src/main/java/io/wcm/devops/conga/generator/util/VariableMapResolver.java +++ b/generator/src/main/java/io/wcm/devops/conga/generator/util/VariableMapResolver.java @@ -28,8 +28,6 @@ import java.util.Map; import java.util.regex.Matcher; -import com.google.common.collect.ImmutableList; - import io.wcm.devops.conga.generator.spi.context.ValueProviderGlobalContext; /** @@ -206,7 +204,7 @@ private List replaceIterate(Map map, Map } if (!(listObject instanceof List)) { // allow to iterate over single values as well - listObject = ImmutableList.of(listObject); + listObject = List.of(listObject); } Map variablesClone = new LinkedHashMap<>(ObjectCloner.deepClone(variables)); List result = new ArrayList<>(); diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/util/JexlResolverTest.java b/generator/src/test/java/io/wcm/devops/conga/generator/util/JexlResolverTest.java index e0c5aaa1..04df3496 100644 --- a/generator/src/test/java/io/wcm/devops/conga/generator/util/JexlResolverTest.java +++ b/generator/src/test/java/io/wcm/devops/conga/generator/util/JexlResolverTest.java @@ -19,6 +19,7 @@ */ package io.wcm.devops.conga.generator.util; +import static java.util.Map.entry; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -27,8 +28,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import com.google.common.collect.ImmutableMap; - import io.wcm.devops.conga.generator.GeneratorException; import io.wcm.devops.conga.generator.spi.context.PluginContextOptions; import io.wcm.devops.conga.generator.spi.context.ValueProviderGlobalContext; @@ -53,22 +52,22 @@ void setUp() { object1 = Map.of("var3", "value3", "object2", object2, "nested1var1", "${nested1.nested1var1}", "nested2var1", "${nested1.nested2.nested2var1}"); - variables = ImmutableMap.builder() - .put("var1", "value1") - .put("var2", 123) - .put("object1", object1) - .put("refVar1", "${var1}") - .put("refVar2", "${var2}") - .put("refCombined", "${object1.var3}|${var1}") - .put("jexlExpr", "${object1.var3 + ';' + var1}") - .put("nested1", Map.of( + variables = Map.ofEntries( + entry("var1", "value1"), + entry("var2", 123), + entry("object1", object1), + entry("refVar1", "${var1}"), + entry("refVar2", "${var2}"), + entry("refCombined", "${object1.var3}|${var1}"), + entry("jexlExpr", "${object1.var3 + ';' + var1}"), + entry("nested1", Map.of( "nested1var1", "nested1-value1", "nested1JexlExpr", "${object1.var3 + ';' + var1}", "nested2", Map.of( "nested2var1", "nested2-value1", - "nested2JexlExpr", "${object1.var3 + ';' + var1}"))) - .put("array1", new String[] { "v1", "v2", "v3" }) - .build(); + "nested2JexlExpr", "${object1.var3 + ';' + var1}"))), + entry("array1", new String[] { "v1", "v2", "v3" }) + ); } @Test diff --git a/model/pom.xml b/model/pom.xml index 4a6b450a..2e548cf8 100644 --- a/model/pom.xml +++ b/model/pom.xml @@ -25,7 +25,7 @@ io.wcm.devops.conga io.wcm.devops.conga.parent - 1.16.5-SNAPSHOT + 1.17.0-SNAPSHOT ../parent/pom.xml @@ -40,7 +40,7 @@ io.wcm.devops.conga io.wcm.devops.conga.resource - 1.16.5-SNAPSHOT + 1.17.0-SNAPSHOT compile @@ -68,12 +68,6 @@ compile - - com.google.guava - guava - compile - - diff --git a/parent/pom.xml b/parent/pom.xml index d0b7fb69..52cb481f 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -31,7 +31,7 @@ io.wcm.devops.conga io.wcm.devops.conga.parent - 1.16.5-SNAPSHOT + 1.17.0-SNAPSHOT pom CONGA @@ -72,12 +72,6 @@ 1.11.0 - - com.google.guava - guava - 33.0.0-jre - - commons-beanutils commons-beanutils @@ -96,6 +90,12 @@ 1.6.0 + + com.github.ben-manes.caffeine + caffeine + 3.1.8 + + com.github.jknack handlebars diff --git a/pom.xml b/pom.xml index 3c783a54..cb61fba3 100644 --- a/pom.xml +++ b/pom.xml @@ -25,13 +25,13 @@ io.wcm.devops.conga io.wcm.devops.conga.parent - 1.16.5-SNAPSHOT + 1.17.0-SNAPSHOT parent/pom.xml io.wcm.devops.conga io.wcm.devops.conga.root - 1.16.5-SNAPSHOT + 1.17.0-SNAPSHOT pom CONGA diff --git a/resource/pom.xml b/resource/pom.xml index d9310acb..897edd08 100644 --- a/resource/pom.xml +++ b/resource/pom.xml @@ -25,7 +25,7 @@ io.wcm.devops.conga io.wcm.devops.conga.parent - 1.16.5-SNAPSHOT + 1.17.0-SNAPSHOT ../parent/pom.xml @@ -49,12 +49,6 @@ compile - - com.google.guava - guava - compile - - org.springframework spring-core diff --git a/resource/src/main/java/io/wcm/devops/conga/resource/AbstractClasspathResourceImpl.java b/resource/src/main/java/io/wcm/devops/conga/resource/AbstractClasspathResourceImpl.java index 9a090788..4038fbb8 100644 --- a/resource/src/main/java/io/wcm/devops/conga/resource/AbstractClasspathResourceImpl.java +++ b/resource/src/main/java/io/wcm/devops/conga/resource/AbstractClasspathResourceImpl.java @@ -52,7 +52,7 @@ protected static String convertPath(String path) { } @Override - public int compareTo(Resource o) { + public int compareTo(ResourceInfo o) { return getName().compareTo(o.getName()); } diff --git a/resource/src/main/java/io/wcm/devops/conga/resource/AbstractFileResourceInfoImpl.java b/resource/src/main/java/io/wcm/devops/conga/resource/AbstractFileResourceInfoImpl.java index 06b3ba88..566236c4 100644 --- a/resource/src/main/java/io/wcm/devops/conga/resource/AbstractFileResourceInfoImpl.java +++ b/resource/src/main/java/io/wcm/devops/conga/resource/AbstractFileResourceInfoImpl.java @@ -63,7 +63,7 @@ public final String getCanonicalPath() { } @Override - public int compareTo(Resource o) { + public int compareTo(ResourceInfo o) { return getName().compareTo(o.getName()); } diff --git a/resource/src/main/java/io/wcm/devops/conga/resource/ClasspathResourceCollectionImpl.java b/resource/src/main/java/io/wcm/devops/conga/resource/ClasspathResourceCollectionImpl.java index 0c954301..a46abd6f 100644 --- a/resource/src/main/java/io/wcm/devops/conga/resource/ClasspathResourceCollectionImpl.java +++ b/resource/src/main/java/io/wcm/devops/conga/resource/ClasspathResourceCollectionImpl.java @@ -25,13 +25,12 @@ import java.util.ArrayList; import java.util.List; import java.util.SortedSet; +import java.util.TreeSet; import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; import org.springframework.core.io.support.PathMatchingResourcePatternResolver; -import com.google.common.collect.ImmutableSortedSet; - final class ClasspathResourceCollectionImpl extends AbstractClasspathResourceImpl implements ResourceCollection { private final List fileUrls = new ArrayList<>(); @@ -83,16 +82,16 @@ public ResourceCollection getResourceCollection(String childPath) { @Override public SortedSet getResources() { - return ImmutableSortedSet.copyOf(fileUrls.stream() + return fileUrls.stream() .map(url -> new ClasspathResourceImpl(url, resourceLoader)) - .collect(Collectors.toList())); + .collect(Collectors.toCollection(TreeSet::new)); } @Override public SortedSet getResourceCollections() { - return ImmutableSortedSet.copyOf(folderPaths.stream() + return folderPaths.stream() .map(folderPath -> new ClasspathResourceCollectionImpl(folderPath, resourceLoader)) - .collect(Collectors.toList())); + .collect(Collectors.toCollection(TreeSet::new)); } } diff --git a/resource/src/main/java/io/wcm/devops/conga/resource/FileResourceCollectionImpl.java b/resource/src/main/java/io/wcm/devops/conga/resource/FileResourceCollectionImpl.java index d9fc6852..9a5a10ff 100644 --- a/resource/src/main/java/io/wcm/devops/conga/resource/FileResourceCollectionImpl.java +++ b/resource/src/main/java/io/wcm/devops/conga/resource/FileResourceCollectionImpl.java @@ -21,11 +21,11 @@ import java.io.File; import java.util.Arrays; +import java.util.Collections; import java.util.SortedSet; +import java.util.TreeSet; import java.util.stream.Collectors; -import com.google.common.collect.ImmutableSortedSet; - class FileResourceCollectionImpl extends FileResourceImpl implements ResourceCollection { private final ResourceLoader resourceLoader; @@ -60,23 +60,23 @@ public ResourceCollection getResourceCollection(String path) { @Override public SortedSet getResources() { if (!exists()) { - return ImmutableSortedSet.of(); + return Collections.emptySortedSet(); } - return ImmutableSortedSet.copyOf(Arrays.stream(file.listFiles()) - .filter(child -> child.isFile()) - .map(child -> new FileResourceImpl(child)) - .collect(Collectors.toList())); + return Arrays.stream(file.listFiles()) + .filter(File::isFile) + .map(FileResourceImpl::new) + .collect(Collectors.toCollection(TreeSet::new)); } @Override public SortedSet getResourceCollections() { if (!exists()) { - return ImmutableSortedSet.of(); + return Collections.emptySortedSet(); } - return ImmutableSortedSet.copyOf(Arrays.stream(file.listFiles()) - .filter(child -> child.isDirectory()) + return Arrays.stream(file.listFiles()) + .filter(File::isDirectory) .map(child -> new FileResourceCollectionImpl(child, resourceLoader)) - .collect(Collectors.toList())); + .collect(Collectors.toCollection(TreeSet::new)); } } diff --git a/resource/src/main/java/io/wcm/devops/conga/resource/ResourceInfo.java b/resource/src/main/java/io/wcm/devops/conga/resource/ResourceInfo.java index a158f6d0..172df0af 100644 --- a/resource/src/main/java/io/wcm/devops/conga/resource/ResourceInfo.java +++ b/resource/src/main/java/io/wcm/devops/conga/resource/ResourceInfo.java @@ -22,7 +22,7 @@ /** * Abstraction for resource information. */ -public interface ResourceInfo extends Comparable { +public interface ResourceInfo extends Comparable { /** * @return true if resource exists diff --git a/resource/src/main/java/io/wcm/devops/conga/resource/ResourceLoader.java b/resource/src/main/java/io/wcm/devops/conga/resource/ResourceLoader.java index 77970bcb..88f7bbf9 100644 --- a/resource/src/main/java/io/wcm/devops/conga/resource/ResourceLoader.java +++ b/resource/src/main/java/io/wcm/devops/conga/resource/ResourceLoader.java @@ -23,8 +23,6 @@ import org.apache.commons.lang3.StringUtils; -import com.google.common.collect.ImmutableList; - /** * Resource loader to read resource and resource collections from filesystem or classpath. */ @@ -125,12 +123,12 @@ private List getSupportedResourceTypes(String path) { // check for explicit path specification for (ResourceType resourceType : ResourceType.values()) { if (StringUtils.startsWith(path, resourceType.getPrefix())) { - return ImmutableList.of(resourceType); + return List.of(resourceType); } } // otherwise check all resource types in order of definition in enum - return ImmutableList.copyOf(ResourceType.values()); + return List.of(ResourceType.values()); } ClassLoader getClassLoader() { diff --git a/tooling/conga-cli/pom.xml b/tooling/conga-cli/pom.xml index dcecf4c3..72095007 100644 --- a/tooling/conga-cli/pom.xml +++ b/tooling/conga-cli/pom.xml @@ -25,7 +25,7 @@ io.wcm.devops.conga io.wcm.devops.conga.parent - 1.16.5-SNAPSHOT + 1.17.0-SNAPSHOT ../../parent/pom.xml @@ -40,7 +40,7 @@ io.wcm.devops.conga io.wcm.devops.conga.generator - 1.16.5-SNAPSHOT + 1.17.0-SNAPSHOT compile diff --git a/tooling/conga-maven-plugin/pom.xml b/tooling/conga-maven-plugin/pom.xml index 1777ed3b..bc3e75c6 100644 --- a/tooling/conga-maven-plugin/pom.xml +++ b/tooling/conga-maven-plugin/pom.xml @@ -25,7 +25,7 @@ io.wcm.devops.conga io.wcm.devops.conga.parent - 1.16.5-SNAPSHOT + 1.17.0-SNAPSHOT ../../parent/pom.xml @@ -56,7 +56,7 @@ io.wcm.devops.conga io.wcm.devops.conga.generator - 1.16.5-SNAPSHOT + 1.17.0-SNAPSHOT compile diff --git a/tooling/conga-maven-plugin/src/main/java/io/wcm/devops/conga/tooling/maven/plugin/AbstractCongaMojo.java b/tooling/conga-maven-plugin/src/main/java/io/wcm/devops/conga/tooling/maven/plugin/AbstractCongaMojo.java index 92e66a45..d8662854 100644 --- a/tooling/conga-maven-plugin/src/main/java/io/wcm/devops/conga/tooling/maven/plugin/AbstractCongaMojo.java +++ b/tooling/conga-maven-plugin/src/main/java/io/wcm/devops/conga/tooling/maven/plugin/AbstractCongaMojo.java @@ -30,6 +30,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.SortedSet; @@ -53,8 +54,6 @@ import org.codehaus.plexus.archiver.jar.JarArchiver; import org.codehaus.plexus.archiver.jar.ManifestException; -import com.google.common.collect.ImmutableList; - import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import io.wcm.devops.conga.generator.export.ModelExport; import io.wcm.devops.conga.resource.Resource; @@ -200,7 +199,7 @@ protected ModelExport getModelExport() { String[] nodeExportPlugins = StringUtils.split(this.modelExportNode, ","); if (nodeExportPlugins != null) { - modelExport.setNode(ImmutableList.copyOf(nodeExportPlugins)); + modelExport.setNode(Arrays.asList(nodeExportPlugins)); } return modelExport; diff --git a/tooling/conga-maven-plugin/src/main/java/io/wcm/devops/conga/tooling/maven/plugin/PackageMojo.java b/tooling/conga-maven-plugin/src/main/java/io/wcm/devops/conga/tooling/maven/plugin/PackageMojo.java index 767ba926..c8b4e26d 100644 --- a/tooling/conga-maven-plugin/src/main/java/io/wcm/devops/conga/tooling/maven/plugin/PackageMojo.java +++ b/tooling/conga-maven-plugin/src/main/java/io/wcm/devops/conga/tooling/maven/plugin/PackageMojo.java @@ -43,8 +43,6 @@ import org.codehaus.plexus.archiver.ArchiverException; import org.codehaus.plexus.archiver.zip.ZipArchiver; -import com.google.common.collect.ImmutableSet; - import io.wcm.devops.conga.generator.util.FileUtil; /** @@ -83,7 +81,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { private void buildGeneratedConfigurationAttachments() throws MojoExecutionException, MojoFailureException { Set selectedEnvironments; if (environments != null && environments.length > 0) { - selectedEnvironments = ImmutableSet.copyOf(environments); + selectedEnvironments = Set.copyOf(Arrays.asList(environments)); } else { selectedEnvironments = null; diff --git a/tooling/conga-maven-plugin/src/main/java/io/wcm/devops/conga/tooling/maven/plugin/ValidateMojo.java b/tooling/conga-maven-plugin/src/main/java/io/wcm/devops/conga/tooling/maven/plugin/ValidateMojo.java index d89262f5..6b99aaa3 100644 --- a/tooling/conga-maven-plugin/src/main/java/io/wcm/devops/conga/tooling/maven/plugin/ValidateMojo.java +++ b/tooling/conga-maven-plugin/src/main/java/io/wcm/devops/conga/tooling/maven/plugin/ValidateMojo.java @@ -49,8 +49,6 @@ import org.sonatype.plexus.build.incremental.BuildContext; import org.springframework.core.io.support.PathMatchingResourcePatternResolver; -import com.google.common.collect.ImmutableList; - import io.wcm.devops.conga.generator.GeneratorException; import io.wcm.devops.conga.generator.GeneratorOptions; import io.wcm.devops.conga.generator.UrlFileManager; @@ -153,7 +151,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { .logger(new MavenSlf4jLogFacade(getLog())); // validate that all templates can be compiled - HandlebarsManager handlebarsManager = new HandlebarsManager(ImmutableList.of(templateDir), pluginContextOptions); + HandlebarsManager handlebarsManager = new HandlebarsManager(List.of(templateDir), pluginContextOptions); validateFiles(templateDir, templateDir, new TemplateValidator(templateDir, handlebarsManager)); // validate that roles reference existing templates