Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using SBT to generate a JAR file name that doesn't include the Scala patch version

Tags:

jar

scala

sbt

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
like image 639
Powers Avatar asked Dec 18 '25 11:12

Powers


1 Answers

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

like image 186
Oleg Pyzhcov Avatar answered Dec 20 '25 23:12

Oleg Pyzhcov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!