Interface GitCommitIdPlugin.Callback
-
- Enclosing class:
- GitCommitIdPlugin
public static interface GitCommitIdPlugin.Callback
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description intgetAbbrevLength()Minimum length of'git.commit.id.abbrev'property.BuildFileChangeListenergetBuildFileChangeListener()CommitIdGenerationModegetCommitIdGenerationMode()The mode of'git.commit.id'property generation.java.lang.StringgetDateFormat()java.lang.StringgetDateFormatTimeZone()The timezone used in the date format of dates exported by this plugin.java.io.FilegetDotGitDirectory()java.lang.StringgetEvaluateOnCommit()Allow to tell the plugin what commit should be used as reference to generate the properties from.java.util.List<java.lang.String>getExcludeProperties()List of properties to exclude from the resulting file.java.io.FilegetGenerateGitPropertiesFile()GitDescribeConfiggetGitDescribe()Configuration for the'git-describe'command.java.util.List<java.lang.String>getIncludeOnlyProperties()List of properties to include into the resulting file.LogInterfacegetLogInterface()longgetNativeGitTimeoutInMs()Allow to specify a timeout (in milliseconds) for fetching information with the native Git executable.java.lang.StringgetPrefixDot()The prefix to expose the properties on.java.io.FilegetProjectBaseDir()java.lang.StringgetProjectName()CommitIdPropertiesOutputFormatgetPropertiesOutputFormat()java.nio.charset.CharsetgetPropertiesSourceCharset()java.util.DategetReproducibleBuildOutputTimestamp()Timestamp for reproducible output archive entries (https://maven.apache.org/guides/mini/guide-reproducible-builds.html).default java.util.Map<java.lang.String,java.lang.String>getSystemEnv()The system environment variables.booleangetUseBranchNameFromBuildEnvironment()Use branch name from build environment.booleanisOffline()Controls whether the git plugin tries to access remote repos to fetch latest information or only use local information.voidperformPropertiesReplacement(java.util.Properties properties)Callback when the plugin wants to perform the properties replacement.voidperformPublishToAllSystemEnvironments(java.util.Properties properties)Callback when the plugin wants to publish a set of properties.booleanshouldGenerateGitPropertiesFile()Set this to'true'to generate a'git.properties'file.booleanshouldPropertiesEscapeUnicode()java.util.function.Supplier<java.lang.String>supplyProjectVersion()booleanuseNativeGit()Set this to'true'to use native Git executable to fetch information about the repository.
-
-
-
Method Detail
-
getSystemEnv
default java.util.Map<java.lang.String,java.lang.String> getSystemEnv()
The system environment variables. Implementations usually do not need to set or overwrite this, this is mainly meant for testing purposes...- Returns:
- unmodifiable string map view of the current system environment
System.getenv(java.lang.String).
-
supplyProjectVersion
java.util.function.Supplier<java.lang.String> supplyProjectVersion()
- Returns:
- Supplier that provides the version of the project that is currently evaluated.
Used to determine
GitCommitPropertyConstant.BUILD_VERSION.
-
getLogInterface
@Nonnull LogInterface getLogInterface()
- Returns:
- Logging Interface
-
getDateFormat
@Nonnull java.lang.String getDateFormat()
- Returns:
- The date format to be used for any dates exported by this plugin.
It should be a valid
SimpleDateFormatstring.
-
getDateFormatTimeZone
@Nonnull java.lang.String getDateFormatTimeZone()
The timezone used in the date format of dates exported by this plugin. It should be a valid Timezone string such as
'America/Los_Angeles','GMT+10'or'PST'.Try to avoid three-letter time zone IDs because the same abbreviation is often used for multiple time zones. Please review https://docs.oracle.com/javase/7/docs/api/java/util/TimeZone.html for more information on this issue.
- Returns:
- The timezone used in the date format of dates exported by this plugin.
-
getPrefixDot
@Nonnull java.lang.String getPrefixDot()
The prefix to expose the properties on. For example'git'would allow you to access${git.branch}.- Returns:
- The prefix to expose the properties on.
-
getExcludeProperties
java.util.List<java.lang.String> getExcludeProperties()
List of properties to exclude from the resulting file. May be useful when you want to hide
'git.remote.origin.url'(maybe because it contains your repo password?) or the email of the committer.Supports wildcards: you can write
'git.commit.user.*'to exclude both the'name'as well as'email'properties from being emitted into the resulting files.Note: The strings here are Java regular expressions:
'.*'is a wildcard, not plain'*'.- Returns:
- List of properties to exclude
-
getIncludeOnlyProperties
java.util.List<java.lang.String> getIncludeOnlyProperties()
List of properties to include into the resulting file. Only properties specified here will be included. This list will be overruled by the
'excludeProperties'.Supports wildcards: you can write
'git.commit.user.*'to include both the'name'as well as'email'properties into the resulting files.Note: The strings here are Java regular expressions:
'.*'is a wildcard, not plain'*'.- Returns:
- List of properties to include
-
getReproducibleBuildOutputTimestamp
@Nullable java.util.Date getReproducibleBuildOutputTimestamp() throws GitCommitIdExecutionExceptionTimestamp for reproducible output archive entries (https://maven.apache.org/guides/mini/guide-reproducible-builds.html). The value from${project.build.outputTimestamp}is either formatted as ISO 8601yyyy-MM-dd'T'HH:mm:ssXXXor as an int representing seconds since the epoch (like SOURCE_DATE_EPOCH.- Returns:
- Timestamp for reproducible output archive entries.
- Throws:
GitCommitIdExecutionException- In case the user provided time stamp is invalid a GitCommitIdExecutionException is thrown
-
useNativeGit
boolean useNativeGit()
Set this to'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.- Returns:
- Controls if this plugin should use the native Git executable.
-
getNativeGitTimeoutInMs
long getNativeGitTimeoutInMs()
Allow to specify a timeout (in milliseconds) for fetching information with the native Git executable. Note thatuseNativeGitneeds to be set to'true'to use native Git executable.- Returns:
- A timeout (in milliseconds) for fetching information with the native Git executable.
-
getAbbrevLength
int getAbbrevLength()
Minimum length of
'git.commit.id.abbrev'property. Value must be from 2 to 40 (inclusive), other values will result in an exception.An abbreviated commit is a shorter version of commit id. However, it is guaranteed to be unique. To keep this contract, the plugin may decide to print an abbreviated version that is longer than the value specified here.
Example: You have a very big repository, yet you set this value to 2. It's very probable that you'll end up getting a 4 or 7 char long abbrev version of the commit id. If your repository, on the other hand, has just 4 commits, you'll probably get a 2 char long abbreviation.
- Returns:
- Minimum length of
'git.commit.id.abbrev'property.
-
getGitDescribe
GitDescribeConfig getGitDescribe()
Configuration for the'git-describe'command. You can modify the dirty marker, abbrev length and other options here.- Returns:
- Configuration for the
'git-describe'command.
-
getCommitIdGenerationMode
CommitIdGenerationMode getCommitIdGenerationMode()
The mode of
'git.commit.id'property generation.'git.commit.id'property name is incompatible with json export (see issue #122). This property allows one either to preserve backward compatibility or to enable fully valid json export:'flat'(default) generates the property'git.commit.id', preserving backwards compatibility.'full'generates the property'git.commit.id.full', enabling fully valid json object export.
Note: Depending on your plugin configuration you obviously can choose the `prefix` of your properties by setting it accordingly in the plugin's configuration. As a result this is therefore only an illustration what the switch means when the 'prefix' is set to it's default value.
Note: If you set the value to something that's not equal to
'flat'or'full'(ignoring the case) the plugin will output a warning and will fallback to the default'flat'mode.- Returns:
- The mode of
'git.commit.id'property generation.
-
getUseBranchNameFromBuildEnvironment
boolean getUseBranchNameFromBuildEnvironment()
Use branch name from build environment. Set to'false'to use JGit/GIT to get current branch name. Useful when using the JGitflow maven plugin. Note: If not using "Check out to specific local branch' and setting this to false may result in getting detached head state and therefore a commit id as branch name.- Returns:
- Controls if the branch name from build environment should be used.
-
isOffline
boolean isOffline()
Controls whether the git plugin tries to access remote repos to fetch latest information or only use local information. :warning: Before version 5.X.X the default was set tofalsecausing the plugin to operate in online-mode by default.- Returns:
- Controls whether the git plugin tries to access remote repos to fetch latest information.
-
getEvaluateOnCommit
java.lang.String getEvaluateOnCommit()
Allow to tell the plugin what commit should be used as reference to generate the properties from. By default this property is simply set toHEAD
which should reference to the latest commit in your repository. In general this property can be set to something generic likeHEAD^1
or point to a branch or tag-name. To support any kind or use-case this configuration can also be set to an entire commit-hash or it's abbreviated version. A use-case for this feature can be found in https://github.com/git-commit-id/git-commit-id-maven-plugin/issues/338. Please note that for security purposes not all references might be allowed as configuration. If you have a specific use-case that is currently not white listed feel free to file an issue.- Returns:
- Tell the plugin what commit should be used as reference to generate the properties from.
-
getDotGitDirectory
java.io.File getDotGitDirectory()
- Returns:
- The root directory of the repository we want to check.
-
shouldGenerateGitPropertiesFile
boolean shouldGenerateGitPropertiesFile()
Set this to'true'to generate a'git.properties'file. By default plugin only adds properties to maven project properties.- Returns:
- Control if the plugin should generate a
'git.properties'file.
-
performPublishToAllSystemEnvironments
void performPublishToAllSystemEnvironments(java.util.Properties properties)
Callback when the plugin wants to publish a set of properties.- Parameters:
properties- The properties the plugin want's to publish to the user.
-
performPropertiesReplacement
void performPropertiesReplacement(java.util.Properties properties)
Callback when the plugin wants to perform the properties replacement.- Parameters:
properties- The current set of properties.
-
getPropertiesOutputFormat
CommitIdPropertiesOutputFormat getPropertiesOutputFormat()
- Returns:
- The output format of the generated properties file.
-
getBuildFileChangeListener
BuildFileChangeListener getBuildFileChangeListener()
- Returns:
- The BuildFileChangeListener that will be called when an output file of the plugin has changed
-
getProjectName
java.lang.String getProjectName()
- Returns:
- The project name
-
getProjectBaseDir
java.io.File getProjectBaseDir()
- Returns:
- The project base dir
-
getGenerateGitPropertiesFile
java.io.File getGenerateGitPropertiesFile()
- Returns:
- The optional properties file where properties should be dumped into
-
getPropertiesSourceCharset
java.nio.charset.Charset getPropertiesSourceCharset()
- Returns:
- The Charset in which format the properties should be dumped (e.g. 'UTF-8')
-
shouldPropertiesEscapeUnicode
boolean shouldPropertiesEscapeUnicode()
-
-