diff --git a/core/src/main/java/com/cosium/code/format/InstallHooksMojo.java b/core/src/main/java/com/cosium/code/format/InstallHooksMojo.java index 4de474f..b723eb8 100644 --- a/core/src/main/java/com/cosium/code/format/InstallHooksMojo.java +++ b/core/src/main/java/com/cosium/code/format/InstallHooksMojo.java @@ -65,6 +65,13 @@ public class InstallHooksMojo extends AbstractMavenGitCodeFormatMojo { @Parameter(property = "gcf.propertiesToAdd") private String[] propertiesToAdd; + /** + * The list of preliminary Maven goals to invoke before invoking the main + * git-code-format:on-pre-commit goal from the pre-commit script. + */ + @Parameter(property = "gcf.preliminaryGoals") + private String[] preliminaryGoals; + @Parameter(property = "gcf.debug", defaultValue = "false") private boolean debug; @@ -124,6 +131,7 @@ private void writePluginHooks(Path hooksDirectory) throws IOException { StandardCharsets.UTF_8.toString(), mavenEnvironment.getMavenExecutable(debug).toAbsolutePath(), pomFile().toAbsolutePath(), + preliminaryMavenGoalsToInvoke(), mavenCliArguments()); getLog().debug("Written plugin pre commit hook file"); } @@ -141,6 +149,10 @@ private void configureHookBaseScripts(Path hooksDirectory) throws IOException { basePreCommitHook.appendCommandCall(preCommitHookBaseScriptCall()); } + private String preliminaryMavenGoalsToInvoke() { + return Stream.of(preliminaryGoals).collect(Collectors.joining(" ")); + } + private String mavenCliArguments() { Stream propagatedProperties = ofNullable(propertiesToPropagate) diff --git a/core/src/main/resources/com/cosium/code/format/git-code-format.pre-commit.sh b/core/src/main/resources/com/cosium/code/format/git-code-format.pre-commit.sh index 409be68..c2cf27d 100644 --- a/core/src/main/resources/com/cosium/code/format/git-code-format.pre-commit.sh +++ b/core/src/main/resources/com/cosium/code/format/git-code-format.pre-commit.sh @@ -1,3 +1,3 @@ #!/bin/bash set -e -%s -f %s com.cosium.code:git-code-format-maven-plugin:on-pre-commit %s +%s -f %s %s com.cosium.code:git-code-format-maven-plugin:on-pre-commit %s