All Projects → ksoichiro → gradle-build-info-plugin

ksoichiro / gradle-build-info-plugin

Licence: Apache-2.0 License
Gradle plugin to include build information such as Git commit ID to your JAR. It can be used to show Git commit information with Spring Boot Actuator.

Programming Languages

groovy
2714 projects

Projects that are alternatives of or similar to gradle-build-info-plugin

Kotlin Gradle Plugin Template
🐘 A template to let you started with custom Gradle Plugins + Kotlin in a few seconds
Stars: ✭ 141 (+327.27%)
Mutual labels:  gradle, gradle-plugin
Versioning
Gradle plug-in to generate version information from the SCM branch (Git or Svn)
Stars: ✭ 157 (+375.76%)
Mutual labels:  gradle, gradle-plugin
Gradle Pitest Plugin
Gradle plugin for PIT Mutation Testing
Stars: ✭ 144 (+336.36%)
Mutual labels:  gradle, gradle-plugin
Gradle Eclipse Aar Plugin
Gradle plugin to use Android AAR libraries on Eclipse.
Stars: ✭ 127 (+284.85%)
Mutual labels:  gradle, gradle-plugin
Maven Git Versioning Extension
This extension will virtually set project versions, based on current git branch or tag.
Stars: ✭ 178 (+439.39%)
Mutual labels:  gradle, gradle-plugin
Forma
Meta build system with Android and Gradle support.
Stars: ✭ 127 (+284.85%)
Mutual labels:  gradle, gradle-plugin
Gradle Android Plugin
[Deprecated] Gradle Android Plugin 中文版使用手册,如有纰漏,望斧正
Stars: ✭ 155 (+369.7%)
Mutual labels:  gradle, gradle-plugin
Reckon
Infer a project's version from your Git repository.
Stars: ✭ 124 (+275.76%)
Mutual labels:  gradle, gradle-plugin
sphinx-gradle-plugin
Sphinx site generation plugin for Gradle
Stars: ✭ 19 (-42.42%)
Mutual labels:  gradle, gradle-plugin
Gradle Launch4j
A gradle-plugin to create windows executables with launch4j
Stars: ✭ 177 (+436.36%)
Mutual labels:  gradle, gradle-plugin
gradle-cleaner-intellij-plugin
Force clear delaying & no longer needed Gradle tasks.
Stars: ✭ 26 (-21.21%)
Mutual labels:  gradle, gradle-plugin
Badass Jlink Plugin
Create a custom runtime image of your modular application
Stars: ✭ 216 (+554.55%)
Mutual labels:  gradle, gradle-plugin
Bytex
ByteX is a bytecode plugin platform based on Android Gradle Transform API and ASM. 字节码插件开发平台
Stars: ✭ 2,140 (+6384.85%)
Mutual labels:  gradle, gradle-plugin
Gson Plugin
辅助 Gson 库的 gradle 插件,防止 Json 数据解析类型异常。
Stars: ✭ 133 (+303.03%)
Mutual labels:  gradle, gradle-plugin
Jib
🏗 Build container images for your Java applications.
Stars: ✭ 11,370 (+34354.55%)
Mutual labels:  gradle, gradle-plugin
Gradle Aem Plugin
Swiss army knife for Adobe Experience Manager related automation. Environment setup & incremental AEM application build which takes seconds, not minutes.
Stars: ✭ 145 (+339.39%)
Mutual labels:  gradle, gradle-plugin
Okbuck
OkBuck is a gradle plugin that lets developers utilize the Buck build system on a gradle project.
Stars: ✭ 1,513 (+4484.85%)
Mutual labels:  gradle, gradle-plugin
Clojurephant
Clojure and Clojurescript support for Gradle
Stars: ✭ 118 (+257.58%)
Mutual labels:  gradle, gradle-plugin
Click Debounce
Using ASM to handle Android's click debounce, specially a quick double click.
Stars: ✭ 175 (+430.3%)
Mutual labels:  gradle, gradle-plugin
Gradle Testsets Plugin
A plugin for the Gradle build system that allows specifying test sets (like integration or acceptance tests).
Stars: ✭ 182 (+451.52%)
Mutual labels:  gradle, gradle-plugin

gradle-build-info-plugin

Build Status Build status Coverage Stagus Bintray Maven Central

Gradle plugin to include build information such as Git commit ID to your JAR.

Usage

Apply plugin:

plugins {
    id 'com.github.ksoichiro.build.info' version '0.2.0'
}

Note that you can use this plugin only when you use java plugin because you build JAR:

apply plugin: 'java'

When used with Spring Boot Actuator dependency, this plugin will also generate git.properties, which will be recognized by Spring Boot Actuator's info endpoint.

Then just build your project:

$ ./gradlew build

Now your Manifest in JAR includes special attributes:

$ unzip -p build/libs/yourJar.jar META-INF/Manifest.MF
Manifest-Version: 1.0
Git-Branch: master
Git-Commit: 154f026
Git-Committer-Date: 2015-12-17 20:05:55 +0900
Build-Date: 2015-12-17 20:15:15 +0900
Build-Java-Version: 1.8.0_45
Build-Java-Vendor: Oracle Corporation
Build-Os-Name: Mac OS X
Build-Os-Version: 10.10.1

And when Spring Boot Actuator is used with it, git.properties will be generated:

$ cat build/resources/main/git.properties
git.branch=master
git.commit.id=38a0c0c
git.commit.time=2015-12-16 23\:40\:13 +0900

Configuration

You can configure this plugin with buildInfo extension in build.gradle:

buildInfo {
    // Date format string used to Git committer date.
    committerDateFormat 'yyyy-MM-dd HH:mm:ss Z'

    // Date format string used to build date.
    buildDateFormat 'yyyy-MM-dd HH:mm:ss Z'

    // Set to true if you want to generate/merge Manifest.MF.
    manifestEnabled true

    // Set to true if you want to generate git.properties.
    // Default is false, but when you use Spring Boot Actuator
    // and you don't set this property explicitly to false,
    // git.properties will be generated.
    gitPropertiesEnabled false

    // Behavior when the plugin cannot read .git directory.
    // Set to MODE_IGNORE if you want to ignore it and proceed task.
    // Set to MODE_ERROR if you want to throw an exception to stop build.
    // Default is MODE_DEFAULT.
    // MODE_DEFAULT will set the values of branch, commit,
    // and committer date to "unknown", then proceed task.
    gitInfoMode com.github.ksoichiro.build.info.BuildInfoExtension.MODE_DEFAULT

    // Set to false if you want to suppress log when .git directory
    // cannot be read.
    // Default is true.
    warnIfGitDirectoryIsMissing false

    // Set to false if you want to exclude some attributes
    // from the manifest file.
    // All properties are true by default.
    attributeGitBranchEnabled false
    attributeGitCommitEnabled false
    attributeGitCommitterDateEnabled false
    attributeBuildDateEnabled false
    attributeBuildJavaVersionEnabled false
    attributeBuildJavaVendorEnabled false
    attributeBuildOsNameEnabled false
    attributeBuildOsVersionEnabled false
}

License

Copyright 2015 Soichiro Kashima

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].