6

I am using:

  • scala 2.10.3
  • sbt 13.2

with plugin:

addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.7.3")

I am using the universal:packgeBin to generate the universal zip file and publish to ivy repository. I'd like to change the zip file name from project_id_scalaversion_buildVersion.zip to project_id_scalaversion_buildVersion_dist.zip. How would I do that?

Eugene Yokota
  • 94,654
  • 45
  • 215
  • 319
user111724
  • 71
  • 1
  • 2

2 Answers2

14

This answer is based on version 1.0.3 that I have used, but it should apply to the latest version (1.1.5) as well.

You can name your package however you want. The only thing to do is to add the following setting to the configuration of your project:

Universal / packageName := s"${name.value}_${scalaVersion.value}_${version.value}_dist"
Jacob Wang
  • 4,411
  • 5
  • 29
  • 43
devrogs
  • 533
  • 3
  • 13
9

I think you cannot change the name of the generated artifact just for the universal:packageBin easily.

You can change the name of the generated artifact globally, by using artifactName.

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

This will however also modify also the name of the generated jar file, and perhaps some other names of the generated artifacts.

If you wanted to change the name only of the file generated by the universal:packageBin you could rename the file after it was generated. Sbt gives you utilities which make this rather easy.

Universal / packageBin := {
  val originalFileName = (Universal / packageBin).value
  val (base, ext) = originalFileName.baseAndExt
  val newFileName = file(originalFileName.getParent) / (base + "_dist." + ext)
  IO.move(originalFileName, newFileName)
  newFileName
}

Now invoking the Universal/packageBin should execute your new task, which will rename the file after it's created.

Jacob Wang
  • 4,411
  • 5
  • 29
  • 43
lpiepiora
  • 13,659
  • 1
  • 35
  • 47
  • Thank you very much. This did the trick for us in the project target/universal/ folder very nicely. However, we are still having the issue when truing to publish to ivy. Any idea as to how may resolve that plz? Thank you in advanced, Kayvan – user111724 Jul 27 '14 at 20:14
  • @user111724 actually when I think of it, do you care of the name of the *.jar or you have a jar at all. Maybe the simplest working option would be just to use the `version` key. E.g. `version := "0.1_dist"`? Similarly to how `"0.1-SNAPSHOT"` works. – lpiepiora Jul 29 '14 at 19:21
  • this worked for us. than you so much for your help :) – user111724 Aug 21 '14 at 19:47