|
43 | 43 | import org.apache.maven.settings.Settings;
|
44 | 44 | import org.apache.maven.shared.release.policy.version.VersionPolicy;
|
45 | 45 | import org.codehaus.plexus.components.interactivity.Prompter;
|
| 46 | +import org.codehaus.plexus.util.FileUtils; |
46 | 47 | import org.codehaus.plexus.util.StringUtils;
|
47 | 48 | import org.codehaus.plexus.util.cli.CommandLineException;
|
48 | 49 | import org.codehaus.plexus.util.cli.CommandLineUtils;
|
@@ -83,6 +84,9 @@ public abstract class AbstractGitFlowMojo extends AbstractMojo {
|
83 | 84 | /** Command line for Maven executable. */
|
84 | 85 | private final Commandline cmdMvn = new Commandline();
|
85 | 86 |
|
| 87 | + /** Whether .gitmodules file exists in project. */ |
| 88 | + private final boolean gitModulesExists; |
| 89 | + |
86 | 90 | /** Git flow configuration. */
|
87 | 91 | @Parameter(defaultValue = "${gitFlowConfig}")
|
88 | 92 | protected GitFlowConfig gitFlowConfig;
|
@@ -225,6 +229,15 @@ public abstract class AbstractGitFlowMojo extends AbstractMojo {
|
225 | 229 | @Parameter(property = "gitPushOptions")
|
226 | 230 | private String gitPushOptions;
|
227 | 231 |
|
| 232 | + /** |
| 233 | + * Explicitly enable or disable executing submodule update before commit. By |
| 234 | + * default plugin tries to automatically determine if update of the Git |
| 235 | + * submodules is needed. |
| 236 | + * |
| 237 | + */ |
| 238 | + @Parameter(property = "updateGitSubmodules") |
| 239 | + private Boolean updateGitSubmodules; |
| 240 | + |
228 | 241 | /**
|
229 | 242 | * The path to the Maven executable. Defaults to "mvn".
|
230 | 243 | */
|
@@ -253,6 +266,10 @@ public abstract class AbstractGitFlowMojo extends AbstractMojo {
|
253 | 266 | @Component
|
254 | 267 | protected Map<String, VersionPolicy> versionPolicies;
|
255 | 268 |
|
| 269 | + public AbstractGitFlowMojo() { |
| 270 | + gitModulesExists = FileUtils.fileExists(".gitmodules"); |
| 271 | + } |
| 272 | + |
256 | 273 | /**
|
257 | 274 | * Initializes command line executables.
|
258 | 275 | *
|
@@ -807,6 +824,11 @@ protected void gitCommit(final String message) throws MojoFailureException, Comm
|
807 | 824 | */
|
808 | 825 | protected void gitCommit(String message, Map<String, String> messageProperties)
|
809 | 826 | throws MojoFailureException, CommandLineException {
|
| 827 | + if ((gitModulesExists && updateGitSubmodules == null) || Boolean.TRUE.equals(updateGitSubmodules)) { |
| 828 | + getLog().info("Updating git submodules before commit."); |
| 829 | + executeGitCommand("submodule", "update"); |
| 830 | + } |
| 831 | + |
810 | 832 | if (StringUtils.isNotBlank(commitMessagePrefix)) {
|
811 | 833 | message = commitMessagePrefix + message;
|
812 | 834 | }
|
|
0 commit comments