Suma
Suma

Reputation: 34423

Remove transitional dependency on Scala library

One of the libaries in my project is adding a dependency on scala-continuations. As this is only used for features of the library I am not using, I want to remove the dependency. This can be done by using:

libraryDependencies += "com.jsuereth" %% "scala-arm" % "1.4" exclude(
  "org.scala-lang.plugins", "scala-continuations-library_2.11"
)

This works, however I do not like the _2.11 part. I could use

 excludeAll(ExclusionRule(organization="org.scala-lang.plugins"))

currently no other artifacts exist with this organization name, however it smells to me, as this can change in the future.

I can compose the name from scalaVersion by using string operations:

libraryDependencies += "com.jsuereth" %% "scala-arm" % "1.4" exclude(
  "org.scala-lang.plugins", "scala-continuations-library_" + scalaVersion.value.split('.').dropRight(1).mkString(".")
)

Is there perhaps some shorter way to do this - some SBT function or perhaps wildcard operation for exclude, or at least to determine the Scala version suffix needed?

Upvotes: 1

Views: 236

Answers (1)

Suma
Suma

Reputation: 34423

SBT contains a predefined key scalaBinaryVersion, which can be used like this:

libraryDependencies += "com.jsuereth" %% "scala-arm" % "1.4" exclude(
  "org.scala-lang.plugins", "scala-continuations-library_" + scalaBinaryVersion.value
)

Upvotes: 2

Related Questions