Resolving import conflicts in Scala SBT - scala

I'm trying to following this tutorial, but I'm getting the same error for two days. i found some similar questions here in SO, but any of them helped me (maybe is because my lack of knowledge in scala and sbt).
Here is my build.sbt
name := "fitman"
version := "1.0"
scalaVersion := "2.11.6"
lazy val versions = new {
val finatra = "2.1.2"
val logback = "1.1.3"
}
resolvers ++= Seq(
Resolver.sonatypeRepo("releases"),
"Twitter Maven" at "https://maven.twttr.com"
)
libraryDependencies += "com.twitter.finatra" %% "finatra-http" % versions.finatra
libraryDependencies += "com.twitter.finatra" %% "finatra-slf4j" % versions.finatra
libraryDependencies += "ch.qos.logback" % "logback-classic" % versions.logback
Here is the warnings that I'm trying to understand:
SBT project import
[warn] Scala version was updated by one of library dependencies:
[warn] * org.scala-lang:scala-library:(2.11.6, 2.11.4, 2.11.0, 2.11.2) -> 2.11.7
[warn] To force scalaVersion, add the following:
[warn] ivyScala := ivyScala.value map { _.copy(overrideScalaVersion = true) }
[warn] Run 'evicted' to see detailed eviction warnings
[warn] Multiple dependencies with the same organization/name but different versions. To avoid conflict, pick one version:
[warn] * org.scala-lang:scala-library:(2.11.7, 2.11.6)
[warn] * org.scala-lang:scala-reflect:(2.11.7, 2.11.6)
[warn] * org.scala-lang.modules:scala-parser-combinators_2.11:(1.0.4, 1.0.3)
[warn] * org.scala-lang.modules:scala-xml_2.11:(1.0.5, 1.0.3)

One of the libraries you are using requires Scala 2.11.7, so SBT is overriding your scalaVersion setting with it. Update the version of Scala in your build file:
scalaVersion := "2.11.7"

Related

sbt unresolved library dependencies

sbt compile issues unresolved dependencies error
Research SBT configuration. I do have the correct syntax. But SBT still issues error
name := "MyProject"
version := "1.0"
scalaVersion := "2.11.12"
resolvers +=
"Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/releases"
libraryDependencies += "java.io.IOException" % "IOException" % "latest.integration"
libraryDependencies += "java.io.FileReader" % "FileReader" % "latest.integration"
libraryDependencies += "java.io.FileNotFoundExceptiom" % "FileNotFoundException" % "latest.integration"
I have a working scala program. I expect the dependencies to be included instead I receive the following Warning. What am I missing?
Warning Message
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: java.io.IOException#IOException;latest.integration: not found
[warn] :: java.io.FileReader#FileReader;latest.integration: not found
[warn] :: java.io.FileNotFoundExceptiom#FileNotFoundException;latest.integration: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
hmm, there's something weird.
Typically you declare dependencies in a form of a lib/jar that does contain a set of classes, and not the individual class itself.
In your specific case, you don't even need to add any dependency to get java.io.* classes since it belong to standard library and are included by default

sbt: conflicting scala binary versions between project and library dependency

Disclaimer: new sbt/Scala user
So I have the following build.sbt file (sbt.version=1.1.1):
val managedLibs : Setting[_] = libraryDependencies ++= Seq(
"org.scala-lang" % "scala-compiler" % "2.11.10" withSources(),
"org.scala-lang" % "scala-library" % "2.11.10" withSources(),
"org.scala-lang" % "scala-reflect" % "2.11.10" withSources()
)
lazy val root = (project in file("."))
.settings(
name := "foo",
organization := "bar",
scalaVersion := "2.12.4",
sourcesInBase := false,
version := "0.1",
managedLibs
)
What I want to do is to use a different compiler version to build my project and a different compiler version from within my project (i.e., as a library). Sbt does not seem to like this and I am getting the following warnings:
[warn] Binary version (2.11) for dependency org.scala-lang#scala-compiler;2.11.10
[warn] in bar#foo_2.12;0.1 differs from Scala binary version in project (2.12).
[warn] Binary version (2.11) for dependency org.scala-lang#scala-library;2.11.10
[warn] in bar#foo_2.12;0.1 differs from Scala binary version in project (2.12).
[warn] Binary version (2.11) for dependency org.scala-lang#scala-reflect;2.11.10
[warn] in bar#foo_2.12;0.1 differs from Scala binary version in project (2.12).
[warn] Multiple dependencies with the same organization/name but different versions. To avoid conflict, pick one version:
[warn] * org.scala-lang:scala-library:(2.12.4, 2.11.10)
My program compiles and runs without an issue using scala 2.12.4 (it looks like sbt ignored 2.11.10) but I am just curious: is it even possible to use different versions in that way ? Is this a hard restriction imposed by sbt ?
Thanks in advance for your help !

Unresolved dependency SBT, scalariform

I am receiving this compilation error:
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.typesafe.sbt#sbt-scalariform;1.3.0: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
[warn] com.typesafe.sbt:sbt-scalariform:1.3.0 (scalaVersion=2.11, sbtVersion=0.13)
[warn]
In the root of my project I have a build.sbt file:
scalaVersion in ThisBuild := "2.11.6"
I also have a core/build.sbt file with several resolvers, libraryDependencies, and exclusions.
project/plugins.sbt:
addSbtPlugin(...)
resolvers += "Typesafe Public Repo" at "http://repo.typesafe.com/typesafe/releases"
resolvers += "JBoss Repository" at "http://repository.jboss.org/nexus/content/groups/public//"
~/.sbt/0.13/global.sbt
scalaVersion := "2.11.6"
You need to remove scalaVersion := "2.11.6" from ~/.sbt/0.13/global.sbt.
In sbt 0.13, sbt and its ecosystem of plugins is current using Scala 2.10.
The sbt-scalariform changed the groupId/organization
1.3.0 - "com.typesafe.sbt" % "sbt-scalariform" % "1.3.0"
available only for scala 2.9.1, 2.9.2 and 2.10
sbt 0.13
as seen here: https://dl.bintray.com/sbt/sbt-plugin-releases/com.typesafe.sbt/sbt-scalariform/scala_2.10/sbt_0.13/1.3.0/
1.4.0, 1.5.0, ... , 1.8.2 - "org.scalariform" % "sbt-scalariform" & "1.8.2"
https://repo1.maven.org/maven2/org/scalariform/sbt-scalariform_2.10_0.13/
https://search.maven.org/#search%7Cga%7C1%7Ca%3A%22sbt-scalariform%22

Scalding for Scala 2.11

I wrote my build.sbt like this:
name := """scala-hbase"""
version := "1.0"
scalaVersion := "2.11.2"
//scalaVersion := "2.10.4"
/* HBase dependencies */
resolvers ++= Seq(
"Apache Repo" at "https://repository.apache.org/content/repositories/releases",
"Thrift-Repo" at "http://people.apache.org/~rawson/repo",
"ClouderaRepo" at "https://repository.cloudera.com/content/repositories/releases",
"ClouderaRcs" at "https://repository.cloudera.com/artifactory/cdh-releases-rcs",
"Twitter Maven" at "http://maven.twttr.com",
"MVN Repo" at "http://mvnrepository.com/artifact",
"releases" at "http://scala-tools.org/repo-releases"
)
// Hbase 0.94 / Hadoop 2.5.2
libraryDependencies ++= Seq(
//"org.apache.zookeeper" % "zookeeper" % "3.4.6",
//"org.specs2" %% "specs2" % "2.4.5" % "test",
"org.apache.hadoop" % "hadoop-core" % "1.2.1",
"org.apache.hbase" % "hbase" % "0.94.16",
"com.twitter" %% "scalding-args" % "0.10.0",
"com.twitter" %% "scalding-core" % "0.10.0",
"com.twitter" %% "scalding-date" % "0.10.0"
)
// Uncomment to use Akka
//libraryDependencies += "com.typesafe.akka" % "akka-actor_2.11" % "2.3.3"
But I got some unresolved dependencies
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.twitter#scalding-args_2.11;0.10.0: not found
[warn] :: com.twitter#scalding-core_2.11;0.10.0: not found
[warn] :: com.twitter#scalding-date_2.11;0.10.0: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
What version of scalding should i use for scala 2.11 ? Thanks
Scalding 0.13 is now released and it does support Scala 2.11.
https://github.com/twitter/scalding/releases
From google groups
We don't compile for 2.11.0 since its super hard/impossible to have code compatible from 2.9 -> 2.11.
We (at twitter) are still on 2.9.x for the moment so for now we can only support up to the 2.10.x scala's. Hopefully this will change over the next few months.
Also the current scalding version(0.12) is compatible only with scala 2.10(maven)
As #Travis mentioned in the comment, Scalding for Scala version 2.11 is available in the scalding's develop branch(github)

scalacheck/scalatest not found: how to add it in sbt/scala?

I've installed typesafe-stack from http://typesafe.com/stack/download on my ubuntu12, than I created a play project (g8 typesafehub/play-scala) and now I want to add scalatest or scalacheck to my project.
So my_app/project/plugins.sbt has the following lines:
// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
// Use the Play sbt plugin for Play projects
addSbtPlugin("play" % "sbt-plugin" % "2.0.1")
Then I added scalatest using addSbtPlugin:
addSbtPlugin("org.scalatest" %% "scalatest" % "2.0.M1" % "test")
and now it fails with the following message when I run 'sbt test'
[info] Resolving org.scalatest#scalatest;2.0.M1 ...
[warn] module not found: org.scalatest#scalatest;2.0.M1
[warn] ==== typesafe-ivy-releases: tried
[warn] http://repo.typesafe.com/typesafe/ivy-releases/org.scalatest/scalatest/scala_2.9.1/sbt_0.11.3/2.0.M1/ivys/ivy.xml
[warn] ==== local: tried
[warn] ~/.ivy2/local/org.scalatest/scalatest/scala_2.9.1/sbt_0.11.3/2.0.M1/ivys/ivy.xml
[warn] ==== Typesafe repository: tried
[warn] http://repo.typesafe.com/typesafe/releases/org/scalatest/scalatest_2.9.1_0.11.3/2.0.M1/scalatest-2.0.M1.pom
[warn] ==== typesafe-ivy-releases: tried
[warn] http://repo.typesafe.com/typesafe/ivy- releases/org.scalatest/scalatest/scala_2.9.1/sbt_0.11.3/2.0.M1/ivys/ivy.xml
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/org/scalatest/scalatest_2.9.1_0.11.3/2.0.M1/scalatest-2.0.M1.pom
What I don't understand: why does it use this http://repo.typesafe.com/typesafe/releases/org/scalatest/scalatest_2.9.1_0.11.3/2.0.M1/scalatest-2.0.M1.pom URL instead of the real one http://repo.typesafe.com/typesafe/releases/org/scalatest/scalatest_2.9.1/2.0.M1/scalatest_2.9.1-2.0.M1.pom?
Quite the same problem I have with scalacheck: it also tries to download using sbt-version specific artifactId whereas the repository has only scala-version specific.
What am I doing wrong? I understand there must be a switch in sbt somewhere, not to use sbt-version as part of the artifact URL?
I also tried using this in my plugins.sbt
libraryDependencies += "org.scalatest" %% "scalatest" % "2.0.M1" % "test"
but looks like it is completely ignored by sbt and scalatest.jar hasn't appeared in the classpath:
my_app/test/AppTest.scala:1: object scalatest is not a member of package org
[error] import org.scalatest.FunSuite
because the output of sbt clean && sbt test has lots of
Resolving org.easytesting#fest-util;1.1.6 or just another library, but nothing about scalatest.
I use scala 2.9.1 and sbt 0.11.3, trying to use scalatest 2.0.M1 and 1.8; scalacheck:
resolvers ++= Seq(
"snapshots" at "http://oss.sonatype.org/content/repositories/snapshots",
"releases" at "http://oss.sonatype.org/content/repositories/releases"
)
libraryDependencies ++= Seq(
"org.scalacheck" %% "scalacheck" % "1.9" % "test"
)
With the same outcome, i.e. it uses the sbtVersion specific POM URL, which doesn't exist.
What am I doing wrong? Thanks.
Scalatest is not a build plugin, but a testing library. You should add it like this:
libraryDependencies += "org.scalatest" %% "scalatest" % "2.0.M1" % "test"
And you should add it to build.sbt at the base directory of your project (which you referred to as "my_app"), not to project/plugins.sbt.
The reason it has 0.11.3 in the URL it tries to find is because build plugins are tied to the version of SBT you are using.
The plugins.sbt file and the addSbtPlugin are used to add sbt plugins. Not dependencies.
With the template you used, you should add your dependencies in the project/Build.scala. You will find a section with:
val appDependencies = Seq(
// Add your project dependencies here,
)
Replace it with:
val appDependencies = Seq(
"org.scalacheck" %% "scalacheck" % "1.9" % "test",
"org.scalatest" %% "scalatest" % "2.0.M1" % "test"
)
and it should work.