diff --git a/docs/using-the-plugin.md b/docs/using-the-plugin.md index cdad2088..62c8dfe0 100644 --- a/docs/using-the-plugin.md +++ b/docs/using-the-plugin.md @@ -372,6 +372,8 @@ It's really simple to setup this plugin; below is a sample pom that you may base Although this should usually give your build some performance boost, it may randomly break if you upgrade your git version and it decides to print information in a different format suddenly. As rule of thumb, keep using the default `jgit` implementation (keep this `false`) until you notice performance problems within your build (usually when you have *hundreds* of maven modules). + + With version *3.0.2* you can also control it using the commandline option `-Dmaven.gitcommitid.nativegit=true` --> false diff --git a/src/main/java/pl/project13/maven/git/GitCommitIdMojo.java b/src/main/java/pl/project13/maven/git/GitCommitIdMojo.java index 0e813d07..f612f7fe 100644 --- a/src/main/java/pl/project13/maven/git/GitCommitIdMojo.java +++ b/src/main/java/pl/project13/maven/git/GitCommitIdMojo.java @@ -198,11 +198,26 @@ public class GitCommitIdMojo extends AbstractMojo { * Set this to {@code 'true'} to use native Git executable to fetch information about the repository. * It is in most cases faster but requires a git executable to be installed in system. * By default the plugin will use jGit implementation as a source of information about the repository. + * * @since 2.1.9 */ @Parameter(defaultValue = "false") boolean useNativeGit; + /** + * Option to be used in command-line to override the value of {@code 'useNativeGit'} specified in + * the pom.xml, or its default value if it's not set explicitly. + * + * NOTE / WARNING: + * Do *NOT* set this property inside the configuration of your plugin. + * Please read https://github.com/git-commit-id/maven-git-commit-id-plugin/issues/315 + * to find out why. + * + * @since 3.0.2 + */ + @Parameter(property = "maven.gitcommitid.nativegit", defaultValue = "false") + boolean useNativeGitViaCommandLine; + /** * Set this to {@code 'true'} to skip plugin execution. * @since 2.1.8 @@ -557,8 +572,15 @@ private void logProperties() { } } + private boolean isUseNativeGit() { + if (System.getProperty("maven.gitcommitid.nativegit") != null) { + return useNativeGitViaCommandLine; + } + return useNativeGit; + } + private void loadGitData(@Nonnull Properties properties) throws GitCommitIdExecutionException { - if (useNativeGit) { + if (isUseNativeGit()) { loadGitDataWithNativeGit(properties); } else { loadGitDataWithJGit(properties);