Mill: How to generate uberjar using publishVersion?

43 views Asked by At

Mill can generate (Uber)jar by mill assembly. Generated file is located at out/assembly.dest/out.jar.

How can I customize output filename instead of out.jar? I'd like to use value of publishVersion (I'm using mill-vcs-version).

sbt can generate well-named uberjar.

1

There are 1 answers

0
Tobias Roeser On

You can customize the outcome by overriding the assembly target.

def assembly(): T[PathRef] = T {
  val dest = T.dest / s"${artifactName()}-${publishVersion()}-assembly.jar"
  os.copy(super.assembly().path, dest)
  PathRef(dest)
}

Instead of artifactName, you could also use artifactId, which would also contain the Scala version suffix and potential platform suffixes.

If you need those kind of customizations in multiple places, you should consider using a trait module.