How to keep library dependencies updated to Scala version? - sbt

I am compiling my project with sbt and am getting an UNRESOLVED DEPENDENCIES error.
The fact is that I fetched the example I use (a hello world program) from an online blog, that uses scalaVersion := "2.10.0" as shown below. I am using 2.11.2.
How do I update the library dependencies (in the build.sbt) to the latest version of Scala, specifically the revision part?
build.sbt
name := "Hello Test #1"
version := "1.0"
scalaVersion := "2.10.0"
resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
libraryDependencies += "com.typesafe.akka" % "akka-actor_2.10" % "2.2-M1"
The error:
[info] Resolving com.typesafe.akka#akka-actor_2.11.2;2.2-M1 ...
[warn] module not found: com.typesafe.akka#akka-actor_2.11.2;2.2-M1
[warn] ==== local: tried
[warn] /home/plard/.ivy2/local/com.typesafe.akka/akka-actor_2.11.2/2.2-M1/ivys/ivy.xml
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/com/typesafe/akka/akka-actor_2.11.2/2.2-M1/akka-actor_2.11.2-2.2-M1.pom
[warn] ==== Typesafe Repository: tried
[warn] http://repo.typesafe.com/typesafe/releases/com/typesafe/akka/akka-actor_2.11.2/2.2-M1/akka-actor_2.11.2-2.2-M1.pom
[info] Resolving jline#jline;2.12 ...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.typesafe.akka#akka-actor_2.11.2;2.2-M1: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: com.typesafe.akka#akka-actor_2.11.2;2.2-M1: not found
[error] Total time: 1 s, completed Aug 11, 2014 10:32:11 AM

name := "Hello Test #1"
version := "1.0"
scalaVersion := "2.11.2"
resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.3.4"
This should do it. Note the %% and no version specified for the Akka artifact. Doing so, SBT will automatically append your Scala version to the artifact. See docs for more details.

Related

sbt.librarymanagement.ResolveException: unresolved dependency: com.eed3si9n#sbt-assembly;0.14.6: not found

I am facing issue while using sbt-assembly to build my jar. I have gone through almost all the post available but it did not help resolve my issue.
Below is my build.sbt -
name := "test"
version := "0.1"
scalaVersion := "2.11.8"
sbtVersion := "1.3.6"
assembly.sbt -
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.6")
plugins.sbt -
resolvers += Resolver.url("bintray-sbt-plugins", url("http://dl.bintray.com/sbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns)
error:
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.eed3si9n#sbt-assembly;0.14.6: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
[warn] com.eed3si9n:sbt-assembly:0.14.6 (scalaVersion=2.12, sbtVersion=1.0)
[warn]
[warn] Note: Unresolved dependencies path:
[warn] com.eed3si9n:sbt-assembly:0.14.6 (scalaVersion=2.12, sbtVersion=1.0)
During initial build, it is not downloading below files -
https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/com.eed3si9n/sbt-assembly/scala_2.12/sbt_1.0/0.14.6/ivys/ivy.xml
NaN% [ ] 0 B (0 B / s)
https://repo.typesafe.com/typesafe/ivy-releases/com.eed3si9n/sbt-assembly/scala_2.12/sbt_1.0/0.14.6/ivys/ivy.xml
NaN% [ ] 0 B (0 B / s)
and at the end it says [error] not found:
https://repo1.maven.org/maven2/com/eed3si9n/sbt-assembly_2.12_1.0/0.14.6/sbt-assembly-0.14.6.pom
ivy.xml files exists in given path but the repo1.maven.org path does not exists.
Has anyone faced similar issue?

Sbt plugin publication and resolution on bintray, different paths (sbt-bintray plugin)

I have some troubles to publish/use a custom sbt plugin from bintray. I'm able
to publish sbt-plugin on bintray but when I try to use it the resolver uses
another path.
I have followed the official guide but adapted it to the latest version of the plugin, I have this build.sbt into my plugin :
lazy val commons = Seq(
organization in ThisBuild := "me.my.app",
version in ThisBuild := "0.1.0"
)
lazy val root = (project in file(".")).
settings(commons ++ BintrayPlugin.bintrayPublishSettings: _*).
settings(
sbtPlugin := true,
name := "sbt-plugin",
description := "Share configuration and plugins accros app projects",
bintrayOmitLicense := true,
publishMavenStyle := false,
bintrayRepository := "sbt-plugins",
bintrayOrganization := None
).
settings(
addSbtPlugin("me.lessis" % "bintray-sbt" % "0.3.0"),
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.6.0"),
addSbtPlugin("org.scalastyle" % "scalastyle-sbt-plugin" % "0.8.0")
)
The sbt-plugin> publish task complete successfully and publish my plugin into
me.my.app/sbt-plugin/scala_2.10/sbt_0.13/0.1.0/jars/sbt-plugin.jar
Then I add addSbtPlugin("me.my.app" % "sbt-plugin" % "0.1.0") to my-project\project\plugins.sbt and
reload it. But he fail with
[warn] ==== bintray-{organization}-{repo}: tried
[warn] https://dl.bintray.com/{organization}/sbt-plugins/me/my/app/sbt-plugin_2.10_0.13/0.1.0/sbt-plugin-0.1.0.pom
...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: me.my.app#sbt-plugin;0.1.0: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
[warn] me.my.app:sbt-plugin:0.1.0 (scalaVersion=2.10, sbtVersion=0.13)
[warn]
[warn] Note: Unresolved dependencies path:
[warn] me.my.app:sbt-plugin:0.1.0 (scalaVersion=2.10, sbtVersion=0.13) (/home/me/Projects/app/app-web/project/plugins.sbt#L7-8)
[warn] +- default:app-web-build:0.1-SNAPSHOT (scalaVersion=2.10, sbtVersion=0.13)
sbt.ResolveException: unresolved dependency: me.my.app#sbt-plugin;0.1.0: not found
at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:313)
[error] (*:update) sbt.ResolveException: unresolved dependency: me.my.app#sbt-plugin;0.1.0: not found
As you can see the URL used to download the plugin is not the same as the
one where the plugin has been published. (with publishLocal my plugin is
published under the same path but resolved successfully.
Local : me.my.app/sbt-plugin/scala_2.10/sbt_0.13/0.1.0/jars/sbt-plugin.jar
Upload : me.my.app/sbt-plugin/scala_2.10/sbt_0.13/0.1.0/jars/sbt-plugin.jar
Downlad: me/my/app/sbt-plugin_2.10_0.13/0.1.0/sbt-plugin-0.1.0.pom
I have tried with or without publishMavenStyle := false and with Resolver.bintrayRepo and Resolver.bintrayIvyRepo but without success.
I will be missing something but I have to admit that I feel a bit lost. So what are the missing configuration that should align the upload and download paths ?
Details :
publishMavenStyle := false -> me.my.app/sbt-plugin/scala_2.10/sbt_0.13/0.1.0/jars/sbt-plugin.jar
publishMavenStyle := true -> me.my.app/sbt-plugin/scala_2.10/sbt_0.13/0.1.0/jars/sbt-plugin.jar
Resolver.bintrayRepo -> me/my/app/sbt-plugin_2.10_0.13/0.1.0/sbt-plugin-0.1.0.pom
Resolver.bintrayIvyRepo -> me.my.app/sbt-plugin/scala_2.10/sbt_0.13/0.1.0/ivys/ivy.xml
The publication part was ok. The only problem was on the resolution side.
I had to add a custom resolver with explicit ivyStylePatterns resolver into my-project\build.sbt:
resolvers += Resolver.url("me # bintray", url("https://dl.bintray.com/{my-bintray-account}/{my-bintray-generic-repo}"))(Resolver.ivyStylePatterns)

Unable to resolve dependencies in SBT - Have I missed a fundamental piece of config somewhere?

I have installed sbt 0.13.8 on a new machine (running osx) via brew install sbt, and now I cannot for the life of me manage to successfully resolve any dependencies from any repositories other than the defaults.
To illustrate this, I have created a very simple project, with the file structure as follows:
example/
build.properties
build.sbt
The contents of build.properties is simply:
sbt.version=0.13.8
And the contents of build.sbt is:
lazy val root = (project in file(".")).
settings(
scalaVersion := "2.11.4",
libraryDependencies += "com.twitter.common.zookeeper" % "server-set" % "1.0.83",
resolvers += "Twitter Repository" at "http://maven.twttr.com"
)
That version of the dependency definitely exists in that repository, at http://maven.twttr.com/com/twitter/common/zookeeper/server-set/1.0.83/, yet when I attempt to compile or update the project it fails, and running last has just left me scratching my head:
$ sbt
[info] Set current project to root (in build file:/Users/rb/Workspace/example/)
> update
[info] Updating {file:/Users/rb/Workspace/example/}root...
[info] Resolving com.twitter.common.zookeeper#server-set;1.0.83 ...
[warn] module not found: com.twitter.common.zookeeper#server-set;1.0.83
[warn] ==== local: tried
[warn] /Users/rb/.ivy2/local/com.twitter.common.zookeeper/server-set/1.0.83/ivys/ivy.xml
[warn] ==== typesafe-ivy-releases: tried
[warn] https://repo.typesafe.com/typesafe/ivy-releases/com.twitter.common.zookeeper/server-set/1.0.83/ivys/ivy.xml
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/com/twitter/common/zookeeper/server-set/1.0.83/server-set-1.0.83.pom
[info] Resolving jline#jline;2.12 ...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.twitter.common.zookeeper#server-set;1.0.83: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Unresolved dependencies path:
[warn] com.twitter.common.zookeeper:server-set:1.0.83 (/Users/rb/Workspace/exampl/build.sbt#L4)
[warn] +- root:root_2.11:0.1-SNAPSHOT
...
> last
[info] Updating {file:/Users/rb/Workspace/example/}root...
[debug] Other repositories:
[debug] Default repositories:
[debug] Using inline dependencies specified in Scala.
...
> inspect resolvers
[info] Setting: scala.collection.Seq[sbt.Resolver] = List(Twitter Repository: http://maven.twttr.com)
[info] Description:
[info] The user-defined additional resolvers for automatically managed dependencies.
[info] Provided by:
[info] {file:/Users/rb/Workspace/example/}root/*:resolvers
[info] Defined at:
[info] /Users/rb/Workspace/example/build.sbt:5
[info] Reverse dependencies:
[info] *:externalResolvers
[info] Delegates:
[info] *:resolvers
[info] {.}/*:resolvers
[info] */*:resolvers
[info] Related:
[info] */*:resolvers
> show fullResolvers
[info] ArrayBuffer(Raw(ProjectResolver(inter-project, mapped: )), FileRepository(local,FileConfiguration(true,None),Patterns(ivyPatterns=List(${ivy.home}/local/[organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]), artifactPatterns=List(${ivy.home}/local/[organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]), isMavenCompatible=false, descriptorOptional=false, skipConsistencyCheck=false)), URLRepository(typesafe-ivy-releases,Patterns(ivyPatterns=List(https://repo.typesafe.com/typesafe/ivy-releases/[organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext]), artifactPatterns=List(https://repo.typesafe.com/typesafe/ivy-releases/[organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext]), isMavenCompatible=false, descriptorOptional=false, skipConsistencyCheck=false)), public: https://repo1.maven.org/maven2/)
[success] Total time: 0 s, completed 28-May-2015 10:50:23
As you can see, when inspecting the resolvers the twitter repository is there, but when running update sbt isn't even trying to use it (and it doesn't appear at all in the rather empty list of repositories output by last).
I can't find any clue as to what I'm doing wrong in the docs or update notes. Have I missed a fundamental config file or parameter somewhere whilst initially installing sbt?
Edit: I have managed to work around this by appending to fullResolvers rather than resolvers as follows:
lazy val root = (project in file(".")).
settings(
scalaVersion := "2.11.4",
libraryDependencies += "com.twitter.common.zookeeper" % "server-set" % "1.0.83",
fullResolvers += "Twitter Repository" at "http://maven.twttr.com"
)
Works for me on OS X, without having to use fullResolvers.
I am not sure if this is related but your build.properties file should be under the project directory.
This is how your project structure should look like:
.
├── build.sbt
└── project
└── build.properties

Why SBT doesn't use resolvers from root project (in multi-module project)

In a multi-module project, SBT doesn't seem to use resolvers when building modules. The resolvers are declared in the root project's build.sbt as follows:
resolvers += "SpringSource Milestone Repository" at "http://repo.springsource.org/milestone"
and the projects are declared like:
lazy val core = project.settings(
libraryDependencies ++= { ... }
)
But when compiling, the resolvers are not used and I get :
[info] Resolving org.springframework.scala#spring-scala;1.0.0.BUILD-SNAPSHOT ...
[warn] module not found: org.springframework.scala#spring-scala;1.0.0.BUILD-SNAPSHOT
[warn] ==== local: tried
[warn] /home/ariskk/.ivy2/local/org.springframework.scala/spring-scala/1.0.0.BUILD-SNAPSHOT/ivys/ivy.xml
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/org/springframework/scala/spring-scala/1.0.0.BUILD-SNAPSHOT/spring-scala-1.0.0.BUILD-SNAPSHOT.pom
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.springframework.scala#spring-scala;1.0.0.BUILD-SNAPSHOT: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
Any ideas what might be wrong?
Use the following in the root project's build.sbt:
resolvers in ThisBuild += "SpringSource Milestone Repository" at "http://repo.springsource.org/milestone"
in ThisBuild is the answer. See Scopes.
I had a similar issue with a Scala / ScalaJS project.
The resolver was only taken when added to the 'sub-project'.
//this works NOT
resolvers += Resolver.sonatypeRepo("snapshots")
// this works
lazy val client = (project in file("client")).settings(
scalaVersion := scalaV,
...,
resolvers += Resolver.sonatypeRepo("snapshots"),
...
(sbt 0.13.15)

Why can't SBT find the Play 2.1 plugin?

In my plugins.sbt file, I have
scalaVersion := "2.10.0"
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
addSbtPlugin("play" % "sbt-plugin" % "2.1")
When I try run sbt I get, among other things
[warn] ==== Typesafe repository: tried
[warn] http://repo.typesafe.com/typesafe/releases/play/sbt-plugin_2.10_0.12/2.1/sbt- plugin-2.1.pom
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/play/sbt-plugin_2.10_0.12/2.1/sbt-plugin-2.1.pom
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: play#sbt-plugin;2.1: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
[warn] play:sbt-plugin:2.1 (sbtVersion=0.12, scalaVersion=2.10)
[warn]
sbt.ResolveException: unresolved dependency: play#sbt-plugin;2.1: not found
Why can't SBT find the plugin? I've also tried addSbtPlugin("play" % "sbt-plugin" % "2.1-RC1") with similar results.
The problem was including the scalaVersion setting inside the plugins.sbt file. This causes sbt to search for sbt-plugin_2.10.0_0.12 in the repositories when it should actually search for sbt-plugin_2.9.2_0.12.
I'm not sure about the semantics behind specifying the scalaVersion in the plugins.sbt file, but maybe it's declaring the Scala version that SBT is running on.
Here is a link to the Play 2.1 sbt-plugin files: http://repo.typesafe.com/typesafe/simple/ivy-releases/play/sbt-plugin/scala_2.9.2/sbt_0.12/2.1-RC1/srcs/
As per the documentation,
Add this in your project/plugins.sbt:
addSbtPlugin("play" % "sbt-plugin" % "2.1.0")
Change the project/build.properties
sbt.version=0.12.2

Resources