Skip to content

Commit f98d8fc

Browse files
committedAug 28, 2022
[jbake-org#763] Allow overriding jbake.properties through maven plugin
1 parent 2e5a20b commit f98d8fc

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed
 

‎jbake-maven-plugin/src/main/java/org/jbake/maven/GenerateMojo.java

+12-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* limitations under the License.
1717
*/
1818

19+
import org.apache.commons.configuration2.MapConfiguration;
1920
import org.apache.maven.plugin.AbstractMojo;
2021
import org.apache.maven.plugin.MojoExecutionException;
2122
import org.apache.maven.plugin.MojoFailureException;
@@ -30,6 +31,7 @@
3031
import org.jbake.app.configuration.JBakeConfigurationFactory;
3132

3233
import java.io.File;
34+
import java.util.Map;
3335

3436
/**
3537
* Runs jbake on a folder
@@ -66,6 +68,12 @@ public class GenerateMojo extends AbstractMojo {
6668
@Parameter(property = "jbake.isClearCache", defaultValue = "false", required = true)
6769
protected boolean isClearCache;
6870

71+
/**
72+
* Properties that are passed to JBake which override the jbake.properties.
73+
*/
74+
@Parameter
75+
protected Map<String, String> properties;
76+
6977
public final void execute() throws MojoExecutionException {
7078
executeInternal();
7179
}
@@ -91,7 +99,10 @@ protected void reRender() throws MojoExecutionException {
9199

92100
protected JBakeConfiguration createConfiguration() throws JBakeException {
93101
DefaultJBakeConfiguration jBakeConfiguration = new JBakeConfigurationFactory().createDefaultJbakeConfiguration(inputDirectory, outputDirectory, isClearCache);
94-
jBakeConfiguration.addConfiguration(this.project.getProperties());
102+
jBakeConfiguration.getCompositeConfiguration().addConfigurationFirst(new MapConfiguration(project.getProperties()));
103+
if (properties != null) {
104+
jBakeConfiguration.getCompositeConfiguration().addConfigurationFirst(new MapConfiguration(properties));
105+
}
95106
return jBakeConfiguration;
96107
}
97108

0 commit comments

Comments
 (0)
Please sign in to comment.