Interface IndraGitExtension

  • All Known Implementing Classes:
    IndraGitExtensionImpl

    public interface IndraGitExtension
    An extension exposing git information.
    Since:
    2.0.0
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      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.
      @Nullable org.eclipse.jgit.lib.Ref branch()
      Get an object pointing to the current branch.
      @Nullable String branchName()
      Get the name of the current branch.
      @Nullable org.eclipse.jgit.lib.ObjectId commit()
      Get the ID of the current commit.
      @Nullable String describe()
      Get a git describe string for the project's repository.
      @Nullable org.eclipse.jgit.api.Git git()
      Access the underlying Git repository.
      @Nullable org.eclipse.jgit.lib.Ref headTag()
      Get the tag pointing to the commit checked out as HEAD.
      default boolean isPresent()
      Get if a git repository is present.
      @NonNull List<org.eclipse.jgit.lib.Ref> tags()
      Get all tags created on this repository.
    • Field Detail

      • 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:
        Constant Field Values
      • 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:
        Constant Field Values
    • Method Detail

      • isPresent

        default 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
      • git

        @Nullable org.eclipse.jgit.api.Git git()
        Access the underlying Git repository.

        This 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.

        Returns:
        the git repository
        Since:
        2.0.0
      • tags

        @NonNull List<org.eclipse.jgit.lib.Ref> tags()
        Get all tags created on this repository.
        Returns:
        the tags on this repository, or an empty list if this project is not in a git repository
        Since:
        2.0.0
      • headTag

        @Nullable org.eclipse.jgit.lib.Ref headTag()
        Get the tag pointing to the commit checked out as HEAD.
        Returns:
        the tag at HEAD, or null if the project is not in a git repository or is not checked out to a tag
        Since:
        2.0.0
      • describe

        @Nullable 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
      • branchName

        @Nullable 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
      • branch

        @Nullable org.eclipse.jgit.lib.Ref branch()
        Get an object pointing to the current branch.
        Returns:
        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

        @Nullable 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