{"id":16782614,"url":"https://github.com/davidmoten/git-properties-maven-plugin","last_synced_at":"2025-07-21T05:05:00.699Z","repository":{"id":37863288,"uuid":"234182897","full_name":"davidmoten/git-properties-maven-plugin","owner":"davidmoten","description":"Maven plugin to write a git.properties file to an output directory and to set maven properties for use in pom.xml","archived":false,"fork":false,"pushed_at":"2025-06-30T06:40:16.000Z","size":65,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-11T04:43:39.665Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/davidmoten.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-01-15T22:06:14.000Z","updated_at":"2025-06-30T06:40:13.000Z","dependencies_parsed_at":"2023-12-25T06:28:18.442Z","dependency_job_id":"57a5abb9-c50c-44fd-8712-b39e7692a224","html_url":"https://github.com/davidmoten/git-properties-maven-plugin","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/davidmoten/git-properties-maven-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidmoten%2Fgit-properties-maven-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidmoten%2Fgit-properties-maven-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidmoten%2Fgit-properties-maven-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidmoten%2Fgit-properties-maven-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidmoten","download_url":"https://codeload.github.com/davidmoten/git-properties-maven-plugin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidmoten%2Fgit-properties-maven-plugin/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266242072,"owners_count":23898102,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T07:46:44.712Z","updated_at":"2025-07-21T05:05:00.680Z","avatar_url":"https://github.com/davidmoten.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# git-properties-maven-plugin\n\u003ca href=\"https://github.com/davidmoten/git-properties-maven-plugin/actions/workflows/ci.yml\"\u003e\u003cimg src=\"https://github.com/davidmoten/git-properties-maven-plugin/actions/workflows/ci.yml/badge.svg\"/\u003e\u003c/a\u003e\u003cbr/\u003e\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.davidmoten/git-properties-maven-plugin/badge.svg?style=flat)](https://maven-badges.herokuapp.com/maven-central/com.github.davidmoten/git-properties-maven-plugin)\u003cbr/\u003e\n[![codecov](https://codecov.io/gh/davidmoten/git-properties-maven-plugin/branch/master/graph/badge.svg)](https://codecov.io/gh/davidmoten/git-properties-maven-plugin)\u003cbr/\u003e\n\nA maven plugin that \n* writes a file to the artifact classpath (by default) containing the current git commit hash (long and short) and the timestamp of that commit \n* sets properties that can be used in the pom.xml (e.g. in \u003cfinalName\u003e) but only if the plugin is bound to the **initialize** phase (which is the default)\n* relies on the existence of the git binary on the current path\n\n**Status:** *deployed to Maven Central*\n## Usage\n\nAdd this fragment to the build/plugins section in your pom.xml:\n\n```xml\n\u003cplugin\u003e\n    \u003cgroupId\u003ecom.github.davidmoten\u003c/groupId\u003e\n    \u003cartifactId\u003egit-properties-maven-plugin\u003c/artifactId\u003e\n    \u003cversion\u003eVERSION_HERE\u003c/version\u003e\n    \u003cexecutions\u003e\n        \u003cexecution\u003e\n            \u003cid\u003eproperties\u003c/id\u003e\n            \u003cgoals\u003e\n                \u003cgoal\u003eproperties\u003c/goal\u003e\n            \u003c/goals\u003e\n        \u003c/execution\u003e\n    \u003c/executions\u003e\n\u003c/plugin\u003e\n```\nThe above fragment will add a `git.properties` file to the generated artifact classpath (`${project.build.outputDirectory}`) when you run `mvn clean install`. The file looks like this:\n\n```\ngit.commit.hash=b49337feb3260a67bc4b5b188e4d0d3f17408150\ngit.commit.hash.short=b49337f\ngit.commit.timestamp=20200116220611\ngit.commit.timestamp.format=yyyyMMddHHmmss\ngit.commit.timestamp.format.timezone=UTC\ngit.commit.timestamp.iso8601=2020-01-16T22:06:11Z\ngit.commit.timestamp.iso8601.format=yyyy-MM-dd'T'HH:mm:ssX\ngit.commit.timestamp.epoch.ms=1579212371000\n\n```\n\nIf you are generating a jar or war artifact then the file will a resource at the root of the classpath (`/git.properties`). \n\nThe same properties are set for use in the pom.xml also so you can use `${git.commit.hash.short}` for instance anywhere in the pom.xml.\n\n### Overriding defaults\nYou can override the default location, filename, and timestamp formats like this:\n\n```xml\n\u003cplugin\u003e\n    \u003cgroupId\u003ecom.github.davidmoten\u003c/groupId\u003e\n    \u003cartifactId\u003egit-properties-maven-plugin\u003c/artifactId\u003e\n    \u003cversion\u003eVERSION_HERE\u003c/version\u003e\n    \u003cexecutions\u003e\n        \u003cexecution\u003e\n            \u003cid\u003ewrite-properties\u003c/id\u003e\n            \u003cgoals\u003e\n                \u003cgoal\u003eproperties\u003c/goal\u003e\n            \u003c/goals\u003e\n        \u003c/execution\u003e\n    \u003c/executions\u003e\n    \u003cconfiguration\u003e\n        \u003coutputDirectory\u003e${project.build.outputDirectory}/git\u003c/outputDirectory\u003e\n        \u003cfilename\u003ecommit.properties\u003c/filename\u003e\n        \u003ctimestampFormat\u003eyyyy-MM-dd HH:mm:ssZ\u003c/timestampFormat\u003e\n        \u003ctimestampFormatTimeZone\u003eAEST\u003c/timestampFormatTimeZone\u003e\n    \u003c/configuration\u003e\n\u003c/plugin\u003e\n```\n### Using properties set by git-properties-maven-plugin\nBecause the plugin is bound by default to the **initialize** phase the properties it sets (with the same key names and values as in the `git.properties` file) are available for use in the pom.xml. For example you can set the \u003cfinalName\u003e to use the short git commit hash and the commit timestamp as well:\n\n```xml\n\u003cfinalName\u003e${project-artifactId}-${project.version}-${git.commit.hash.short}-${git.commit.timestamp}\u003c/finalName\u003e\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidmoten%2Fgit-properties-maven-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidmoten%2Fgit-properties-maven-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidmoten%2Fgit-properties-maven-plugin/lists"}