A git version plugin for Mill build tool.
- Mill
- An initialized git project (
git init)
build.mill:
//| mill-version: 1.0.6-native//| mvnDeps://| - com.goyeau::mill-git::<latest version>importcom.goyeau.mill.git.GitVersionedPublishModuleimportmill.scalalib.JavaModuleimportmill.scalalib.publish.{Developer, License, PomSettings, VersionControl}
object`jvm-project`extendsJavaModulewithGitVersionedPublishModule:overridedefpomSettings=PomSettings(
description ="JVM Project",
organization ="com.goyeau",
url ="https://github.com/joan38/mill-git",
licenses =Seq(License.MIT),
versionControl =VersionControl.github("joan38", "mill-git"),
developers =Seq(Developer("joan38", "Joan Goyeau", "https://github.com/joan38"))
)> mill show jvm-project.publishVersion
[1/1] show [2/2] com.goyeau.mill.git.GitVersionModule.version "0.0.0-470-6d0b3d9"build.mill:
//| mill-version: 1.0.6-native//| mvnDeps://| - com.goyeau::mill-git::<latest version>importcom.goyeau.mill.git.GitTaggedDockerModuleimportmill.scalalib.JavaModuleobject`docker-project`extendsJavaModulewithGitTaggedDockerModule {
objectdockerextendsDockerConfigwithGitTaggedDocker {
deftagLatest=true// Default is false
}
}> mill show docker-project.docker.tags
[1/1] show [6/6] docker-project.docker.tags [
"docker-project:0.0.0-470-6d0b3d9",
"docker-project:latest"
]Here is a custom configuration with the default option: build.mill:
//| mill-version: 1.0.6-native//| mvnDeps://| - com.goyeau::mill-git::<latest version>importcom.goyeau.mill.git.GitVersionModuleimportmill.scalalib.JavaModuleobject`job-project`extendsJavaModule {
defjobVersion=GitVersionModule.version(
hashLength =7, // Sets the length of the commit hash to use as a version.
withSnapshotSuffix =false// Add the -SNAPSHOT suffix so that versions gets pushed to the snapshot sonatype.
)()
}> mill show job-project.jobVersion
[1/1] show [2/2] com.goyeau.mill.git.GitVersionModule.version "0.0.0-470-6d0b3d9"| Tag | Tag distance | HEAD hash | Uncommitted changes | Uncommitted hash | gitVersion |
|---|---|---|---|---|---|
| v1.0.0 | 0 | c85ec8a | false | 1.0.0 | |
| v1.0.0 | 0 | c85ec8a | true | 303eee4 | 1.0.0-1-303eee4 |
| v1.0.0 | 123 | c85ec8a | false | 1.0.0-123-c85ec8a | |
| v1.0.0 | 123 | c85ec8a | true | 303eee4 | 1.0.0-124-303eee4 |
| none | c85ec8a | false | c85ec8a | ||
| none | c85ec8a | true | 303eee4 | 303eee4 | |
| none | none | true | 303eee4 | 303eee4 |
Note that we are generating a git hash for the uncommitted changes (even if they are not committed yet).
- Inspired by sbt-dynver
- sbt-git
Contributions are more than welcome!
See CONTRIBUTING.md for all the information and getting help.