diff --git a/changes.xml b/changes.xml
index 99f02907..40033110 100644
--- a/changes.xml
+++ b/changes.xml
@@ -23,6 +23,12 @@
xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 https://maven.apache.org/plugins/maven-changes-plugin/xsd/changes-1.0.0.xsd">
+
+
+ Add new custom Handlebars expressions 'disallowProperty' which allows to block property names no longer supported.
+
+
+
Switch to Java 11 as minimum version.
diff --git a/generator/pom.xml b/generator/pom.xml
index cae41791..ff0581c4 100644
--- a/generator/pom.xml
+++ b/generator/pom.xml
@@ -25,7 +25,7 @@
io.wcm.devops.conga
io.wcm.devops.conga.parent
- 1.15.0
+ 1.16.0
../parent/pom.xml
@@ -44,7 +44,7 @@
io.wcm.devops.conga
io.wcm.devops.conga.model
- 1.15.0
+ 1.16.0
compile
diff --git a/generator/src/main/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/DisallowPropertyHelper.java b/generator/src/main/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/DisallowPropertyHelper.java
new file mode 100644
index 00000000..dac50d4e
--- /dev/null
+++ b/generator/src/main/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/DisallowPropertyHelper.java
@@ -0,0 +1,71 @@
+/*
+ * #%L
+ * wcm.io
+ * %%
+ * Copyright (C) 2023 wcm.io
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+package io.wcm.devops.conga.generator.plugins.handlebars.helper;
+
+import java.io.IOException;
+
+import org.apache.commons.lang3.StringUtils;
+
+import com.github.jknack.handlebars.Options;
+
+import io.wcm.devops.conga.generator.spi.handlebars.HelperPlugin;
+import io.wcm.devops.conga.generator.spi.handlebars.context.HelperContext;
+
+/**
+ * Handlebars helper that ensures a given property is not set/present.
+ * If it is, an exception is thrown with the property name.
+ * Optionally, a second parameter can be provided with a custom error message.
+ */
+public final class DisallowPropertyHelper implements HelperPlugin {
+
+ /**
+ * Plugin/Helper name
+ */
+ public static final String NAME = "disallowProperty";
+
+ @Override
+ public String getName() {
+ return NAME;
+ }
+
+ @Override
+ public Object apply(Object context, Options options, HelperContext pluginContext) throws IOException {
+ if (isPropertyPresent(context, options)) {
+ String errorMessage = "Disallowed property is set: " + context;
+ if (options.params.length > 0 && options.params[0] != null) {
+ errorMessage = options.params[0].toString();
+ }
+ throw new IOException(errorMessage);
+ }
+ return null;
+ }
+
+ private boolean isPropertyPresent(Object propertyNameExpression, Options options) {
+ if (propertyNameExpression == null) {
+ return false;
+ }
+ String propertyName = propertyNameExpression.toString();
+ if (StringUtils.isBlank(propertyName)) {
+ return false;
+ }
+ return options.get(propertyName) != null;
+ }
+
+}
diff --git a/generator/src/main/resources/META-INF/services/io.wcm.devops.conga.generator.spi.handlebars.HelperPlugin b/generator/src/main/resources/META-INF/services/io.wcm.devops.conga.generator.spi.handlebars.HelperPlugin
index b34857bd..60302648 100644
--- a/generator/src/main/resources/META-INF/services/io.wcm.devops.conga.generator.spi.handlebars.HelperPlugin
+++ b/generator/src/main/resources/META-INF/services/io.wcm.devops.conga.generator.spi.handlebars.HelperPlugin
@@ -1,4 +1,5 @@
io.wcm.devops.conga.generator.plugins.handlebars.helper.ContainsHelper
+io.wcm.devops.conga.generator.plugins.handlebars.helper.DisallowPropertyHelper
io.wcm.devops.conga.generator.plugins.handlebars.helper.EachIfHelper
io.wcm.devops.conga.generator.plugins.handlebars.helper.EachIfEqualsHelper
io.wcm.devops.conga.generator.plugins.handlebars.helper.EnsurePropertiesHelper
diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/DisallowPropertyHelperTest.java b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/DisallowPropertyHelperTest.java
new file mode 100644
index 00000000..65dd299f
--- /dev/null
+++ b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/DisallowPropertyHelperTest.java
@@ -0,0 +1,79 @@
+/*
+ * #%L
+ * wcm.io
+ * %%
+ * Copyright (C) 2023 wcm.io
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+package io.wcm.devops.conga.generator.plugins.handlebars.helper;
+
+import static io.wcm.devops.conga.generator.plugins.handlebars.helper.TestUtils.assertHelper;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import java.io.IOException;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import io.wcm.devops.conga.generator.spi.handlebars.HelperPlugin;
+import io.wcm.devops.conga.generator.util.PluginManagerImpl;
+
+class DisallowPropertyHelperTest {
+
+ private HelperPlugin helper;
+
+ @SuppressWarnings("unchecked")
+ @BeforeEach
+ void setUp() {
+ helper = new PluginManagerImpl().get(DisallowPropertyHelper.NAME, HelperPlugin.class);
+ }
+
+ @Test
+ void testSetCase1() throws Exception {
+ assertThrows(IOException.class, () -> {
+ assertHelper(null, helper, "p1", new MockOptions()
+ .withProperty("p1", "v1"));
+ });
+ }
+
+ @Test
+ void testSetCase2() throws Exception {
+ IOException ex = assertThrows(IOException.class, () -> {
+ assertHelper(null, helper, "p1", new MockOptions("Custom Error Message")
+ .withProperty("p1", "v1")
+ .withProperty("p2", "v2")
+ .withProperty("p3", "v3"));
+ });
+ assertEquals("Custom Error Message", ex.getMessage());
+ }
+
+ @Test
+ void testNotSetCase1() throws Exception {
+ assertHelper(null, helper, "p1", new MockOptions());
+ }
+
+ @Test
+ void testNotSetCase2() throws Exception {
+ assertHelper(null, helper, "p1", new MockOptions("Custom Error Message"));
+ }
+
+ @Test
+ void testNotSetCase3() throws Exception {
+ assertHelper(null, helper, "p1", new MockOptions("Custom Error Message")
+ .withProperty("p2", "v1"));
+ }
+
+}
diff --git a/model/pom.xml b/model/pom.xml
index 6ba97725..9460d91d 100644
--- a/model/pom.xml
+++ b/model/pom.xml
@@ -25,7 +25,7 @@
io.wcm.devops.conga
io.wcm.devops.conga.parent
- 1.15.0
+ 1.16.0
../parent/pom.xml
@@ -40,7 +40,7 @@
io.wcm.devops.conga
io.wcm.devops.conga.resource
- 1.15.0
+ 1.16.0
compile
diff --git a/parent/pom.xml b/parent/pom.xml
index 54dc8bf2..d834ec39 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -31,7 +31,7 @@
io.wcm.devops.conga
io.wcm.devops.conga.parent
- 1.15.0
+ 1.16.0
pom
CONGA
@@ -75,7 +75,7 @@
com.google.guava
guava
- 31.1-jre
+ 32.1.1-jre
@@ -87,7 +87,7 @@
commons-io
commons-io
- 2.11.0
+ 2.13.0
@@ -116,7 +116,7 @@
org.springframework
spring-core
- 5.3.26
+ 5.3.28
diff --git a/pom.xml b/pom.xml
index c964c4ee..dc5613ce 100644
--- a/pom.xml
+++ b/pom.xml
@@ -25,13 +25,13 @@
io.wcm.devops.conga
io.wcm.devops.conga.parent
- 1.15.0
+ 1.16.0
parent/pom.xml
io.wcm.devops.conga
io.wcm.devops.conga.root
- 1.15.0
+ 1.16.0
pom
CONGA
diff --git a/resource/pom.xml b/resource/pom.xml
index 31bb5726..9ce5bb6d 100644
--- a/resource/pom.xml
+++ b/resource/pom.xml
@@ -25,7 +25,7 @@
io.wcm.devops.conga
io.wcm.devops.conga.parent
- 1.15.0
+ 1.16.0
../parent/pom.xml
diff --git a/src/site/markdown/handlebars-helpers.md.vm b/src/site/markdown/handlebars-helpers.md.vm
index d3795320..d8d839f4 100644
--- a/src/site/markdown/handlebars-helpers.md.vm
+++ b/src/site/markdown/handlebars-helpers.md.vm
@@ -88,6 +88,15 @@ Ensure that all properties with the given names are set. Build fails if this is
```
+${symbol_pound}${symbol_pound}${symbol_pound} disallowProperty
+
+Ensure that the given property is *not* set/present. It fails with an error message, if it is present. Optionally, a custom error message can be defined via a second parameter.
+
+```
+{{ensureProperties "group1.prop1" "Property 'group1.prop1' is deprecated, please use 'XYZ' instead."}}
+```
+
+
[handlebars-quickstart]: handlebars-quickstart.html
[extensibility]: extensibility.html
diff --git a/tooling/conga-cli/pom.xml b/tooling/conga-cli/pom.xml
index 525e36bd..367bb7ff 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.15.0
+ 1.16.0
../../parent/pom.xml
@@ -40,7 +40,7 @@
io.wcm.devops.conga
io.wcm.devops.conga.generator
- 1.15.0
+ 1.16.0
compile
diff --git a/tooling/conga-maven-plugin/pom.xml b/tooling/conga-maven-plugin/pom.xml
index 252bc9c8..980b07dc 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.15.0
+ 1.16.0
../../parent/pom.xml
@@ -40,7 +40,7 @@
tooling/conga-maven-plugin
- 3.8.1
+ 3.9.0
invoker.mavenOpts
@@ -56,7 +56,7 @@
io.wcm.devops.conga
io.wcm.devops.conga.generator
- 1.15.0
+ 1.16.0
compile