Git Info

A Gradle plugin that automatically generates a git.properties file containing Git repository information and includes it in your JAR.

The plugin works well with Maven Publish Conventions.

Usage

build.gradle
plugins {
    id 'java'
    id 'no.conta.git-info' version '1.0.1'
}
The plugin will automatically:
  • Generate a git.properties file in build/git-info/

  • Include it in your JAR’s resources at the root level

  • Run before the processResources task

Configuration

Configure the plugin using the gitInfo extension:

build.gradle
contaGitInfo { // using defaults
    enabled = true
    addToResources = true
    addToMetaInf = false
}

Requirements

  • Git repository must be initialized

  • Works without Git installed on the system (uses JGit)

Tasks

generateGitProperties

Generates the git.properties file