value `versionReconciliation` not found in set - scala

I have an existing Scala with sbt project. Sbt version 1.4.7. I want to make dependencies check more strict according to next article: https://www.scala-lang.org/2019/10/17/dependency-management.html
I've added the next configuration to my build.sbt:
versionReconciliation ++= Seq(
"org.typelevel" %% "cats-core" % "relaxed", // "semver" reconciliation is also available
"*" % "*" % "strict"
)
But got the error: error: not found: value versionReconciliation
My plugins.sbt is empty. sbt installed via Sdkman

As the document you references states, to use this way you need to use sbt-coursier, i.e. you need to add addSbtPlugin("io.get-coursier" % "sbt-coursier" % "2.0.0-RC6-8") to be able to use versionReconciliation. Without the plugin you should be able to use the conflictManager key.

Related

when specify the scalaVersion and sbtVersion to resolve the plugin dependencies via “extra”,it doesn't work

I'm trying to add a plugin like this :
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2" extra ("scalaVersion" -> "2.10", "sbtVersion" -> "0.13"))
But when I start sbt session ,the search path still be
https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/com.eed3si9n/sbt-assembly/scala_2.12/sbt_1.0//0.11.2/ivys/ivy.xml
the scalaVersion and sbtVersion still is the one which I'm using.
Could you tell me What should I do?
Thank you!
That is what addSbtPlugin does: it adds the appropriate scalaVersion and sbtVersion to the mentioned artifact (in your case overriding what you have specified manually).
If you want to have full control, do not use addSbtPlugin:
libraryDependencies += "com.eed3si9n" % "sbt-assembly" % "0.11.2" extra ("scalaVersion" -> "2.10", "sbtVersion" -> "0.13")
BUT beware, usually this sort of thing will not work if you fail to add the right attributes appropriate for your SBT version at hand.
In your case, you are apparently using SBT 1.x, which in turn uses Scala 2.12. Trying to use an artifact build with Scala 2.10, ie. for SBT 0.13.x, will break.

sbt ivy2: configuration 'master' not found from 'compile'

I am getting the following error when I build a library bp-kafka-bp2 that depends on library bp-bp2-componentized:
sbt.librarymanagement.ResolveException: unresolved dependency:
com.foo#bp-bp2-componentized_2.11;3.3.+: configuration not found in
com.foo#bp-bp2-componentized_2.11;3.3.0: 'master'. It was required
from com.foo#bp-kafka-bp2_2.11;3.10.1 compile
The unresolved library bp-bp2-componentized does in fact exist in ~/.ivy2/local and does not have a master configuration in its ivy.xml
My questions are:
Should the dependent library (bp-kafka-bp2) be looking for a master configuration of the (not really) missing library?
If it should not be looking for a master config, what can I do to make it stop doing so?
If it should be looking for a master config, how do I induce the build for the (not really) missing library to produce such a config?
I have tried this in sbt versions 1.1.5 and 1.2.1. I have deleted ~/.ivy2/local, ./ivy2/cache and ~/.sbt. I have also removed all the /target and project/target directories in the library I am building and done sbt clean
This library has built just fine for a year or two now. The only recent change I can think of is introducing 2.11 and 2.12 cross-compilation option -- which is not being exercised here, I'm just building 2.11 version on its own.
The direct dependency is declared in a multi-project build.sbt as
lazy val bp2 = (project in file("bp2")).
settings(commonSettings:_*).
settings(Seq(
name := "bp-kafka-bp2"
):_*).
settings(
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % ScalaTestVersion % "test",
"ch.qos.logback" % "logback-classic" % LogbackVersion % "test",
"com.foo" %% "bp-bp2-componentized" % Constellation.dependency("bp-bp2"),
"com.foo" %% "bp-akka-http" % Constellation.dependency("bp-akka")
)
).
dependsOn(reactiveComponentized)
where Constellation.dependency is just a function that looks up a version by name and turns it into a patch range:
object Constellation {
...
def dependency(name: String) : String = versions(name).split("\\.").dropRight(1).mkString(".") + ".+"
}
You can see from the error message that the version is being found and converted to 3.3.+ which is then resolved correctly to a 3.3.0 in the ivy cache. But then it insists on finding a master configuration which is not present.

Unable to find the correct SBT dependency

Today is my first day with Finch.
I am unable to find the right set of SBT dependencies for finch and finagle.
I have tried all the dependencies as shown in Image 2
You are using Scala 2.12 but your dependencies are for Scala 2.11.
This is the correct way to write what you need:
libraryDependencies += "com.github.finagle" %% "finch-core" % "0.13.0"
Build.scala, % and %% symbols meaning

When does a SBT package get downloaded/built?

I want to use http://dispatch.databinder.net/Dispatch.html .
The site indicates I must add this to project/plugins.sbt:
libraryDependencies += "net.databinder.dispatch" %% "core" % "0.9.1"
which I did. I then restarted the play console and compiled.
Importing doesnt work:
import dispatch._
Guess I have been silly, but then I never used a build system when using Java.
How must I trigger the process that downloads/builds the package? Where are the jars (or equivalent) stored; can I reuse them? When is the package available for use by the Play application?
It doesn't say you should add it to project/plugins.sbt. That is the wrong place. It says to add to the build.sbt file, on the root of your project. Being a Play project, project/Build.scala might be more appropriate -- I don't know if it will pick up settings from build.sbt or not.
To add the dependency in your Build.scala:
val appDependencies = Seq(
"net.databinder.dispatch" %% "core" % "0.9.1"
)
You probably need to run sbt update.
From the sbt Command Line Reference:
update Resolves and retrieves external dependencies as described in library dependencies.

new to scala & sbt - trying to compile a project that imports akka.stm._

I'm new to Scala & sbt, and I'm trying to compile a project that imports akka.stm._.
When I try running sbt compile the compilation fails with a message point to that point.
I tried using
https://github.com/paulp/sbt-extras
so I'll have the exact sbt version defined in the "build.sbt" file, but it did not help.
I downloaded the akka-2.0.3.tgz and opened the files, but I don't understand exactly how to install them by default or how to tell sbt to use them.
I also noticed that the build.sbt file contains:
resolvers += "repo.codahale.com" at "http://repo.codahale.com"
libraryDependencies ++= Seq(
// "com.codahale" % "simplespec_2.9.0-1" % "0.3.4"
"com.codahale" % "simplespec_2.9.0-1" % "0.4.1"
// "se.scalablesolutions.akka" %% "akka-sbt-plugin" % "2.0-SNAPSHOT"
I tried uncommenting out the "se.scalablesolutions.akka" (assuming the programmer used the akka-library of that version), but it only printed the message:
[error] Error parsing expression. Ensure that there are no blank lines within a setting.
(There are no blank lines, I just deleted the '//' and replaced the double '%' with a single one)
How do I tell the sbt to find the akka jar files in their place? Can I add another resolver to solve this problem?
I know this kind of question doesn't fit in stackoverflow, but can you at least refer me to some manuals I should read inorder to solve this?
OK, first of all I want to apologize for the newbie question.
(Stackoverflow should make a separate "newbie" section)
First, the elements in the Seq part should be separated by comma.
Second, the akka snapshots were moved to http://repo.akka.io/snapshots so I fixed the build.sbt to:
resolvers += "repo.codahale.com" at "http://repo.codahale.com"
resolvers += "akka" at "http://repo.akka.io/snapshots"
libraryDependencies ++= Seq(
// "com.codahale" % "simplespec_2.9.0-1" % "0.3.4"
"com.codahale" % "simplespec_2.9.0-1" % "0.4.1",
"com.typesafe.akka" % "akka-stm" % "2.0-SNAPSHOT"
)
And the compilation finished successfully.
I don't know if this is the exact configuration in which the original compilation was done, but this issue doesn't disturb me at the moment.