joan38 / mill-git   0.2.5

MIT License GitHub

A git version plugin for Mill build tool

Scala versions: 2.13 2.12
Mill plugins: 0.11 0.10 0.9


Maven Central

A git version plugin for Mill build tool.


  • Mill
  • An initialized git project (git init)


With PublishModule

import $ivy.`com.goyeau::mill-git::<latest version>`
import com.goyeau.mill.git.GitVersionedPublishModule
import mill.scalalib.JavaModule
import mill.scalalib.publish.{Developer, License, PomSettings, VersionControl}

object `jvm-project` extends JavaModule with GitVersionedPublishModule {
  override def pomSettings = PomSettings(
    description = "JVM Project",
    organization = "com.goyeau",
    url = "",
    licenses = Seq(License.MIT),
    versionControl = VersionControl.github("joan38", "mill-git"),
    developers = Seq(Developer("joan38", "Joan Goyeau", ""))
> mill show jvm-project.publishVersion
[1/1] show 
[2/2] com.goyeau.mill.git.GitVersionModule.version 

With DockerModule

import $ivy.`com.goyeau::mill-git::<latest version>`
import com.goyeau.mill.git.GitTaggedDockerModule
import mill.scalalib.JavaModule

object `docker-project` extends JavaModule with GitTaggedDockerModule {
  object docker extends DockerConfig with GitTaggedDocker {
    def tagLatest = true // Default is false
> mill show docker-project.docker.tags
[1/1] show 
[6/6] docker-project.docker.tags 

Custom options

Here is a custom configuration with the default option:

import $ivy.`com.goyeau::mill-git::<latest version>`
import com.goyeau.mill.git.GitVersionModule
import mill.scalalib.JavaModule

object `job-project` extends JavaModule {
  def jobVersion = 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 

Versioning strategy

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).

Related projects


Contributions are more than welcome!
See for all the information and getting help.