Skip to content

Commit

Permalink
[jbake-org#763] Allow overriding jbake.properties through maven plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
beikov committed Aug 28, 2022
1 parent 2e5a20b commit f98d8fc
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -30,6 +31,7 @@
import org.jbake.app.configuration.JBakeConfigurationFactory;

import java.io.File;
import java.util.Map;

/**
* Runs jbake on a folder
Expand Down Expand Up @@ -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<String, String> properties;

public final void execute() throws MojoExecutionException {
executeInternal();
}
Expand All @@ -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;
}

Expand Down

0 comments on commit f98d8fc

Please sign in to comment.