C R
C R

Reputation: 2242

Renaming jar files with sbt when using SbtOneJar

When sbt builds a OneJar file using the SbtOneJar plugin it gives the built jar the name [name]_[scala-version]-[version]-one-jar.jar where name is the name of the project, scala-version is the scalaVersion and version is the version of the project, all variables in the build.sbt file.

How can one set up the build.sbt file so that the name of the jar is [name]-one-jar_[scala-version]-[version].jar

Upvotes: 4

Views: 1555

Answers (1)

C R
C R

Reputation: 2242

Add the following lines to the build.sbt:

// This gets rid of the trailing "-one-jar"

artifact in oneJar <<= moduleName(Artifact(_))

// rename the jar

artifact in oneJar ~= { (art: Artifact) =>
  art.copy(`type` = "jar", extension = "jar", name = art.name + "-one-jar")
}

Upvotes: 2

Related Questions