Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to modify jar name generate by cmd sbt package

Tags:

scala

sbt

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?

like image 494
Jeremy Len Avatar asked Jan 28 '23 07:01

Jeremy Len


1 Answers

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
}
like image 170
yǝsʞǝla Avatar answered Feb 04 '23 16:02

yǝsʞǝla