From f98d8fca020b6959e2ef73eca8ddf8a01620ac85 Mon Sep 17 00:00:00 2001 From: Christian Beikov Date: Sun, 28 Aug 2022 12:56:43 +0200 Subject: [PATCH] [#763] Allow overriding jbake.properties through maven plugin --- .../src/main/java/org/jbake/maven/GenerateMojo.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/jbake-maven-plugin/src/main/java/org/jbake/maven/GenerateMojo.java b/jbake-maven-plugin/src/main/java/org/jbake/maven/GenerateMojo.java index fcb70cc9..90a6c204 100644 --- a/jbake-maven-plugin/src/main/java/org/jbake/maven/GenerateMojo.java +++ b/jbake-maven-plugin/src/main/java/org/jbake/maven/GenerateMojo.java @@ -16,6 +16,7 @@ * limitations under the License. */ +import org.apache.commons.configuration2.MapConfiguration; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -30,6 +31,7 @@ import org.jbake.app.configuration.JBakeConfigurationFactory; import java.io.File; +import java.util.Map; /** * Runs jbake on a folder @@ -66,6 +68,12 @@ public class GenerateMojo extends AbstractMojo { @Parameter(property = "jbake.isClearCache", defaultValue = "false", required = true) protected boolean isClearCache; + /** + * Properties that are passed to JBake which override the jbake.properties. + */ + @Parameter + protected Map properties; + public final void execute() throws MojoExecutionException { executeInternal(); } @@ -91,7 +99,10 @@ protected void reRender() throws MojoExecutionException { protected JBakeConfiguration createConfiguration() throws JBakeException { DefaultJBakeConfiguration jBakeConfiguration = new JBakeConfigurationFactory().createDefaultJbakeConfiguration(inputDirectory, outputDirectory, isClearCache); - jBakeConfiguration.addConfiguration(this.project.getProperties()); + jBakeConfiguration.getCompositeConfiguration().addConfigurationFirst(new MapConfiguration(project.getProperties())); + if (properties != null) { + jBakeConfiguration.getCompositeConfiguration().addConfigurationFirst(new MapConfiguration(properties)); + } return jBakeConfiguration; }