Interface IndraGitExtension

All Known Implementing Classes:
IndraGitExtensionImpl

public interface IndraGitExtension
An extension exposing git information.

To find the appropriate repository, indra-git will look for a git repository in the root project directory.

This will search in the current project's directory, and if the project is not a git checkout, will traverse parent directories until a .git folder is found.

Since:
2.0.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The manifest attribute used to indicate the git branch an archive is built from.
    static final String
    The manifest attribute used to indicate the git commit an archive is built from.
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    applyVcsInformationToManifest(org.gradle.api.java.archives.Manifest manifest)
    Apply metadata about the current git state to the provided manifest.
    @NotNull org.gradle.api.provider.Provider<String>
    Get the name of the current branch.
    @NotNull org.gradle.api.provider.Provider<org.eclipse.jgit.lib.ObjectId>
    Get the ID of the current commit.
    @NotNull org.gradle.api.provider.Provider<String>
    Get a git describe string for the project's repository.
    boolean
    Get if a git repository is present.
    default <V, P extends RepositoryValueSource.Parameters, S extends RepositoryValueSource<V, P>>
    org.gradle.api.provider.Provider<V>
    repositoryValue(Class<S> valueSource)
    Create a parameterless which uses a value from a git repository.
    <V, P extends RepositoryValueSource.Parameters, S extends RepositoryValueSource<V, P>>
    org.gradle.api.provider.Provider<V>
    repositoryValue(Class<S> valueSource, org.gradle.api.Action<? super org.gradle.api.provider.ValueSourceSpec<P>> configureAction)
    Create a provider which uses a value from a git repository.
    @NotNull org.gradle.api.provider.Provider<List<String>>
    Get the names of all tags in the repository.
  • Field Details

    • MANIFEST_ATTRIBUTE_GIT_COMMIT

      static final String MANIFEST_ATTRIBUTE_GIT_COMMIT
      The manifest attribute used to indicate the git commit an archive is built from.
      Since:
      2.0.0
      See Also:
    • MANIFEST_ATTRIBUTE_GIT_BRANCH

      static final String MANIFEST_ATTRIBUTE_GIT_BRANCH
      The manifest attribute used to indicate the git branch an archive is built from.
      Since:
      2.0.0
      See Also:
  • Method Details

    • isPresent

      boolean isPresent()
      Get if a git repository is present.
      Returns:
      whether or not a git repository is present for the current project.
      Since:
      2.0.0
    • repositoryValue

      default <V, P extends RepositoryValueSource.Parameters, S extends RepositoryValueSource<V, P>> org.gradle.api.provider.Provider<V> repositoryValue(Class<S> valueSource)
      Create a parameterless which uses a value from a git repository.
      Type Parameters:
      V - the value type
      P - the value source type
      Parameters:
      valueSource - the value source type
      Returns:
      the value provider
      Since:
      4.0.0
    • repositoryValue

      <V, P extends RepositoryValueSource.Parameters, S extends RepositoryValueSource<V, P>> org.gradle.api.provider.Provider<V> repositoryValue(Class<S> valueSource, org.gradle.api.Action<? super org.gradle.api.provider.ValueSourceSpec<P>> configureAction)
      Create a provider which uses a value from a git repository.
      Type Parameters:
      V - the value type
      P - the value source type
      Parameters:
      valueSource - the value source type
      configureAction - an action to configure any additional parameters on the value source
      Returns:
      the value provider
      Since:
      4.0.0
    • describe

      @NotNull @NotNull org.gradle.api.provider.Provider<String> describe()
      Get a git describe string for the project's repository.

      The result will be equivalent to the result of executing git describe --tags --long

      Returns:
      the describe string, or null if this project is not in a git repository or if there are no tags in the project's history
      Since:
      2.0.0
    • tagNames

      @NotNull @NotNull org.gradle.api.provider.Provider<List<String>> tagNames()
      Get the names of all tags in the repository.
      Returns:
      tag names, or an empty list if the project is not in a git repository or has no tags
      Since:
      4.0.0
    • branchName

      @NotNull @NotNull org.gradle.api.provider.Provider<String> branchName()
      Get the name of the current branch.
      Returns:
      the name of the active branch, or null if the project is not in a git repository or is checked out to a detached HEAD.
      Since:
      2.0.0
    • commit

      @NotNull @NotNull org.gradle.api.provider.Provider<org.eclipse.jgit.lib.ObjectId> commit()
      Get the ID of the current commit.
      Returns:
      the commit id, or null if the project is not in a git repository or has not had its initial commit
      Since:
      2.0.0
    • applyVcsInformationToManifest

      default void applyVcsInformationToManifest(org.gradle.api.java.archives.Manifest manifest)
      Apply metadata about the current git state to the provided manifest.

      Any unavailable state will not

      Current supported parameters are:

      Git-Branch
      The current branch being built
      Git-Commit
      The current commit being built
      Parameters:
      manifest - the manifest to decorate
      Since:
      2.0.0