Reputation: 19308
Here are the relevant lines from the build.sbt
file:
sparkVersion := "2.2.0"
scalaVersion := "2.11.8"
version := "0.10.0"
artifactName := { (sv: ScalaVersion, module: ModuleID, artifact: Artifact) =>
artifact.name + "_" + sv.full + "-" + sparkVersion.value + "_" + module.revision + "." + artifact.extension
}
The $ sbt package
command generates a JAR file named spark-daria_2.11.8-2.2.0_0.10.0.jar
.
I don't want the Scala patch version to be displayed in the generated JAR file. How can I update the artifactName
code to generate a file named spark-daria_2.11-2.2.0_0.10.0.jar
?
I don't want to hardcode it like this:
artifact.name + "_2.11-" + sparkVersion.value + "_" + module.revision + "." + artifact.extension
Upvotes: 3
Views: 3142
Reputation: 19308
If you're using sbt assembly
, you can use scalaBinaryVersion.value
.
Here's an example.
assemblyJarName in assembly := s"${name.value}_${scalaBinaryVersion.value}-${sparkVersion.value}_${version.value}.jar"
You don't need to define the scalaBinaryVersion
variable anywhere, it's magically available in your build.sbt
file.
Upvotes: 1
Reputation: 7353
ScalaVersion#binary
has up-to-minor version string.
The (somewhat unintuitive) name refers to Scala versions with a binary compatible guarantee and is commonly seen in scripts that do cross-building
Upvotes: 3