How to modify jar name generate by cmd sbt package

Jeremy Len Source

For example , if I ran sbt package and sbt will generate a jar name like project_2.11-version.jar, how can I modify this name to a random name?

scalasbt

Answers

answered 5 days ago yǝsʞǝlA #1

Here is what the docs say:

The generated artifact name is determined by the artifactName setting. This setting is of type (ScalaVersion, ModuleID, Artifact) => String.

And the default implementation is:

artifactName := { (sv: ScalaVersion, module: ModuleID, artifact: Artifact) =>
  artifact.name + "-" + module.revision + "." + artifact.extension
}

You can copy this code into your build.sbt or Build.scala file and change how it constructs the artefact name. For example:

artifactName := { (sv: ScalaVersion, module: ModuleID, artifact: Artifact) =>
  java.util.UUID.randomUUID.toString + "." + artifact.extension
}

comments powered by Disqus