Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hndrs/gradle-git-properties-plugin
Gradle Git Properties Plugin with configuration-cache support
https://github.com/hndrs/gradle-git-properties-plugin
configuration-cache git gradle gradle-build gradle-cache gradle-configurations gradle-kotlin gradle-plugin kotlin spring-boot
Last synced: 8 days ago
JSON representation
Gradle Git Properties Plugin with configuration-cache support
- Host: GitHub
- URL: https://github.com/hndrs/gradle-git-properties-plugin
- Owner: hndrs
- License: mit
- Created: 2023-05-21T11:37:46.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-05-28T16:21:57.000Z (over 1 year ago)
- Last Synced: 2024-12-19T03:34:04.717Z (about 2 months ago)
- Topics: configuration-cache, git, gradle, gradle-build, gradle-cache, gradle-configurations, gradle-kotlin, gradle-plugin, kotlin, spring-boot
- Language: Kotlin
- Homepage:
- Size: 113 KB
- Stars: 13
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[![Maven metadata URL](https://img.shields.io/maven-metadata/v?color=green&label=GRADLE%20PLUGIN&metadataUrl=https%3A%2F%2Fplugins.gradle.org%2Fm2%2Fio%2Fhndrs%2Fgit-properties%2Fio.hndrs.git-properties.gradle.plugin%2Fmaven-metadata.xml&style=for-the-badge)](https://plugins.gradle.org/plugin/io.hndrs.git-properties)
[![Coverage](https://img.shields.io/sonar/coverage/hndrs_gradle-git-properties-plugin?server=https%3A%2F%2Fsonarcloud.io&style=for-the-badge)](https://sonarcloud.io/dashboard?id=hndrs_gradle-git-properties-plugin)
[![Supported Java Version](https://img.shields.io/badge/Supported%20Java%20Version-17%2B-informational?style=for-the-badge)]()
[![Sponsor](https://img.shields.io/static/v1?logo=GitHub&label=Sponsor&message=%E2%9D%A4&color=ff69b4&style=for-the-badge)](https://github.com/sponsors/marvinschramm)# Gradle Git Properties
This is a simple gradle plugin that can generate git properties via a `generateGitProperties` task.
If you ask yourself "Why? there is already plugins out there that do this.". You are right!This plugin was build specifically with the purpose of supporting
gradles [configuration-cache](https://docs.gradle.org/8.1.1/userguide/configuration_cache.html) feature.
If you don`t need this functionality, you might choose a more mature plugin.### Using the Plugin
Add the following dependency to your plugin block
```kotlin
plugins {
id("io.hndrs.git-properties") version "1.0.0"
}
```### GenerateProperties Task
The Plugin registers a ```generateGitProperties``` task to the project.
If the project includes the Gradle-Java-Plugin the `generateGitProperties` task will be attached to the
`classes` lifecycle task if the java plugin is present### Default Configuration
When the task is not configured
- it is assumed that a `.git` folder is present in the root of the project.
- the build will fail when an error occurs during the properties generation unless the `--continue-on-error` option is
provided
- the output file is `resources/main/git.properties`The task can be configured the following way if the defaults are not applicable:
```kotlin
import io.hndrs.gradle.plugin.git.properties.GenerateGitPropertiesTasktasks.withType(GenerateGitPropertiesTask::class.java) {
dotGitDirectory.set(File(".git"))
continueOnError.set(false)
output.set(File("resources/main/git.properties"))
}
```> File (build.gradle.kts)
### Behaviour on CI environments
As you may know, CI environments handle the git repository differently and probably only checkout detached HEADs
This plugin handles the branch resolution for- Github Actions
- Gitlab CI
- Travis CIIf you are using a different CI service you can provide the branch name via the `branch-name` option
```bash
./gradlew generateGitProperties --branch-name=$CI_SPECIFIC_ENV
```#### Available Properties
```properties
git.branch=main
git.build.host=localHost
[email protected]
git.build.user.name=John Smith
git.commit.id=e2f8a7bb72036e7a7a03ba243ca0414914cdfa82
git.commit.id.abbrev=e2f8a7b
git.commit.message.full=Merge pull request #1 from hndrs/prepare-initial-release\n\nPreparation of first release. Covers important cache test cases and cleans up code
git.commit.message.short=Merge pull request #1 from hndrs/prepare-initial-release
git.commit.signed=true
git.commit.time=2023-05-24T21:42:38Z
[email protected]
git.commit.user.name=John Smith
[email protected]:hndrs/gradle-git-properties-plugin.git
```