Publishing Scala project to local repository? - sbt

I'm trying to publish a project into my local repository with sbt.
This is my build.sbt file
name := "myProject"
organization := "co.myorganization"
version := "2.0"
scalaVersion := "2.11.0"
sbtPlugin := true
This is my publishLocal command output:
[info] :: delivering :: co.myorganization#myProject;2.0 :: 2.0 :: release :: Thu May 15 14:57:24 COT 2014
All seems to work fine but in my other project I'm getting this error when I try to use it as a dependency like so:
"co.myorganization" % "my-project" % "2.0"
Error output:
::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: co.myorganization#my-project;2.0: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: co.s4n#s4n-autenticacion;2.0: not found
[error] Missing task key: scalaInstance
java.lang.IllegalArgumentException
at org.sbtidea.Settings.logErrorAndFail(Settings.scala:11)
at org.sbtidea.Settings$$anonfun$task$1.apply(Settings.scala:24)
at org.sbtidea.Settings$$anonfun$task$1.apply(Settings.scala:24)
at scala.Option.getOrElse(Option.scala:120)
at org.sbtidea.Settings.task(Settings.scala:24)
at org.sbtidea.SbtIdeaPlugin$.projectData(SbtIdeaPlugin.scala:163)
at org.sbtidea.SbtIdeaPlugin$$anonfun$2.applyOrElse(SbtIdeaPlugin.scala:88)
at org.sbtidea.SbtIdeaPlugin$$anonfun$2.applyOrElse(SbtIdeaPlugin.scala:87)
at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:33)
at scala.collection.TraversableLike$$anonfun$collect$1.apply(TraversableLike.scala:278)
at scala.collection.immutable.RedBlackTree$.foreach(RedBlackTree.scala:79)
at scala.collection.immutable.TreeMap.foreach(TreeMap.scala:202)
at scala.collection.TraversableLike$class.collect(TraversableLike.scala:278)
at scala.collection.immutable.TreeMap.collect(TreeMap.scala:48)
at org.sbtidea.SbtIdeaPlugin$.doCommand(SbtIdeaPlugin.scala:87)
at org.sbtidea.SbtIdeaPlugin$$anonfun$org$sbtidea$SbtIdeaPlugin$$ideaCommand$2.apply(SbtIdeaPlugin.scala:45)
at org.sbtidea.SbtIdeaPlugin$$anonfun$org$sbtidea$SbtIdeaPlugin$$ideaCommand$2.apply(SbtIdeaPlugin.scala:45)
at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:60)
at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:60)
at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:62)
at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:62)
at sbt.Command$.process(Command.scala:95)
at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:100)
at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:100)
at sbt.State$$anon$1.process(State.scala:179)
at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:100)
at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:100)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
at sbt.MainLoop$.next(MainLoop.scala:100)
at sbt.MainLoop$.run(MainLoop.scala:93)
at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:71)
at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:66)
at sbt.Using.apply(Using.scala:25)
at sbt.MainLoop$.runWithNewLog(MainLoop.scala:66)
at sbt.MainLoop$.runAndClearLast(MainLoop.scala:49)
at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:33)
at sbt.MainLoop$.runLogged(MainLoop.scala:25)
at sbt.StandardMain$.runManaged(Main.scala:57)
at sbt.xMain.run(Main.scala:29)
at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:57)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:77)
at xsbt.boot.Launch$.run(Launch.scala:57)
at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:45)
at xsbt.boot.Launch$.launch(Launch.scala:65)
at xsbt.boot.Launch$.apply(Launch.scala:16)
at xsbt.boot.Boot$.runImpl(Boot.scala:32)
at xsbt.boot.Boot$.main(Boot.scala:21)
at xsbt.boot.Boot.main(Boot.scala)
[error] java.lang.IllegalArgumentException
Please advise.

If you build the project as plugin sbtPlugin := true it will add an extra information about the sbt version.
You have to add these kind of artefacts with addSbtPlugin, additionally because you've overridden default Scala version for the plugin you'd have to add it to the addSbtPlugin method:
addSbtPlugin("co.myorganization" % "myproject" % "2.0", "0.13", "2.11")
assuming that you want to add your plugin to Sbt version 0.13 and Scala 2.11.
When doing plugins better stick with default version of Scala.
If your intention is not to have a plugin remove sbtPlugin := true from your build.sbt.

Perhaps you need to add your local repository to the resolvers list?
resolvers += "Local Maven Repository" at file(
Path.userHome.absolutePath+"/.m2/repository").toURL.toString

Related

sbt behind local artifactory proxy

When setting up a sbt project with a local artifactory / maven proxy I see the following message:
In order to specify that all resolvers added in the sbt project should
be ignored in favor of those configured in the repositories
configuration, add the following configuration option to the sbt
launcher script:
-Dsbt.override.build.repos=true
Add the following to your build.sbt file:
resolvers +=
"Artifactory" at "http://url/artifactory/virtualRepository/"
But what I would like to achieve is a behaviour similar to maven i.e. not manually overriding resolvers in the SBT file, but rather via the configuration.
Is this possible as well? If yes how?
Desired behaviour
the project should compile fine without local artifactory proxy
when available / configured in repositories the local one should be used as the source / cache for quicker access
currently, I only get unresolved dependencies for sbt plugins:
::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.scalariform#sbt-scalariform;1.6.0: not found
[warn] :: org.scoverage#sbt-scoverage;1.5.0: not found
[warn] :: org.scalastyle#scalastyle-sbt-plugin;0.8.0: not found
[warn] :: net.virtual-void#sbt-dependency-graph;0.8.2: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
With warnings of
[warn] module not found: org.scalariform#sbt-scalariform;1.6.0
[warn] ==== typesafe-ivy-releases: tried
[warn] https://repo.typesafe.com/typesafe/ivy-releases/org.scalariform/sbt-scalariform/scala_2.10/sbt_0.13/1.6.0/ivys/ivy.xml
[warn] ==== sbt-plugin-releases: tried
[warn] https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/org.scalariform/sbt-scalariform/scala_2.10/sbt_0.13/1.6.0/ivys/ivy.xml
[warn] ==== local: tried
[warn] d:\users\heilerg\.ivy2\local\org.scalariform\sbt-scalariform\scala_2.10\sbt_0.13\1.6.0\ivys\ivy.xml
[warn] ==== my-ivy-proxy-releases: tried
[warn] http://url/artifactory/virtualRepositoryScala/org.scalariform/sbt-scalariform/scala_2.10/sbt_0.13/1.6.0/ivys/ivy.xml
[warn] ==== my-maven-proxy-releases: tried
[warn] http://url/artifactory/virtualRepositoryScala/org/scalariform/sbt-scalariform_2.10_0.13/1.6.0/sbt-scalariform-1.6.0.pom
[warn] ==== Artima Maven Repository: tried
[warn] http://repo.artima.com/releases/org/scalariform/sbt-scalariform_2.10_0.13/1.6.0/sbt-scalariform-1.6.0.pom
[info] Resolving org.scoverage#sbt-scoverage;1.5.0 ...
and SBT logs will show
[ERROR] (o.a.r.RemoteRepoBase:766) - IO error while trying to download resource 'repo1:org/scalariform/sbt-scalariform_2.10_0.13/1.6.0/sbt-scalariform-1.6.0.pom': org.artifactory.api.repo.exception.maven.BadPomException: The target deployment path 'org/scalariform/sbt-scalariform_2.10_0.13/1.6.0/sbt-scalariform-1.6.0.pom' does not match the POM's expected path prefix 'org/scalariform/sbt-scalariform/1.6.0'. Please verify your POM content for correctness and make sure the source path is a valid Maven repository root path.
Somewhere people mention to use the following option in Artifactory to "suppress POM consistency checks", but in the current version of artifactory I can not finde such an option.
edit
I can see only these options
As answered in the comment, a common workaround is "Suppress POM Consistency Checks" - Advanced Settings.
If that is not desirable, another method might be to re-publish the plugin with a valid POM. I've written POM consistency for sbt plugins to show that can be done.
// set some unique postfix
ThisBuild / version := "0.15.0-Pets1"
lazy val root = (project in file("."))
.enablePlugins(SbtPlugin)
.settings(
name := "sbt-assembly",
....
publishMavenStyle := true,
// add this
pomConsistency2021DraftSettings,
)
// Add the following
lazy val pomConsistency2021Draft = settingKey[Boolean]("experimental")
/**
* this is an unofficial experiment to re-publish plugins with better Maven compatibility
*/
def pomConsistency2021DraftSettings: Seq[Setting[_]] = Seq(
pomConsistency2021Draft := Set("true", "1")(sys.env.get("POM_CONSISTENCY").getOrElse("false")),
moduleName := {
if (pomConsistency2021Draft.value)
sbtPluginModuleName2021Draft(moduleName.value,
(pluginCrossBuild / sbtBinaryVersion).value)
else moduleName.value
},
projectID := {
if (pomConsistency2021Draft.value) sbtPluginExtra2021Draft(projectID.value)
else projectID.value
},
)
def sbtPluginModuleName2021Draft(n: String, sbtV: String): String =
s"""${n}_sbt${if (sbtV == "1.0") "1" else if (sbtV == "2.0") "2" else sbtV}"""
def sbtPluginExtra2021Draft(m: ModuleID): ModuleID =
m.withExtraAttributes(Map.empty)
.withCrossVersion(CrossVersion.binary)

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)

Cannot resolve an SBT plugin published to a maven repo

I created a reproducible example about a problem I'm experiencing with SBT plugin resolution:
https://github.com/NicolasRouquette/sbt.problem.example
This example has two SBT projects:
test.plugin a simple SBT plugin
test.app a simple SBT project that uses the test.plugin
There is also a local Maven repository to which the test.plugin is published with a POM file that includes properties like this:
<properties>
<git.branch>master</git.branch>
<git.commit>fe2dc11d6fbb85c5ce0e83b031bbd425997bbd59</git.commit>
<git.tags></git.tags>
</properties>
<properties>
<scalaVersion>2.10</scalaVersion>
<sbtVersion>0.13</sbtVersion>
<extraDependencyAttributes xml:space="preserve">+e:sbtVersion:###:+0.13:###:+module:###:+sbt-license plugin:###:+e:scalaVersion:###:+2.10:###:+organisation:###:+com.banno:###:+branch:###:+##:NULL:##:###:+revision:###:+0.1.5:###:
+e:sbtVersion:###:+0.13:###:+module:###:+sbt-license-report:###:+e:scalaVersion:###:+2.10:###:+organisation:###:+com.typesafe.sbt:###:+branch:###:+##:NULL:##:###:+revision:###:+1.0.0:###:
+e:sbtVersion:###:+0.13:###:+module:###:+sbt-git:###:+e:scalaVersion:###:+2.10:###:+organisation:###:+com.typesafe.sbt:###:+branch:###:+##:NULL:##:###:+revision:###:+0.8.5:###:
+e:sbtVersion:###:+0.13:###:+module:###:+aether-deploy:###:+e:scalaVersion:###:+2.10:###:+organisation:###:+no.arktekk.sbt:###:+branch:###:+##:NULL:##:###:+revision:###:+0.16:###:
</extraDependencyAttributes>
</properties>
I can't run SBT on test.app because SBT fails to resolve the test.plugin:
addSbtPlugin("org.test" % "test-plugin" % "1.0")
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.test#test-plugin;1.0: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
[warn] org.test:test-plugin:1.0 (sbtVersion=0.13, scalaVersion=2.10)
[warn]
[warn] Note: Unresolved dependencies path:
[warn] org.test:test-plugin:1.0 (sbtVersion=0.13, scalaVersion=2.10) (/opt/local/imce/users/nfr/github.imce/example/test.app/project/plugins.sbt#L6-7)
[warn] +- default:test-app-build:0.1-SNAPSHOT (sbtVersion=0.13, scalaVersion=2.10)
sbt.ResolveException: unresolved dependency: org.test#test-plugin;1.0: not found
at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:294)
at sbt.IvyActions$$anonfun$updateEither$1.apply(IvyActions.scala:191)
at sbt.IvyActions$$anonfun$updateEither$1.apply(IvyActions.scala:168)
at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:155)
at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:155)
at sbt.IvySbt$$anonfun$withIvy$1.apply(Ivy.scala:132)
at sbt.IvySbt.sbt$IvySbt$$action$1(Ivy.scala:57)
...
Based on trying to understand what's going on with the debugger, I get the impression that:
resolving plugins happens very early when running SBT; which means that it involves a lot of SBT/Ivy machinery
I don't quite understand how the SBT/Ivy machinery resolves SBT plugins published to a Maven repository (though I've seen some kind of Maven/Ivy conversion somewhere)
it seems that the Maven POM properties are not analyzed to retrieve the sbtVersion (e.g. 0.13) and scalaBinaryVersion (e.g. 2.10) of an artifact
Can someone confirm/correct my analysis?
Is there a way to make this maven-published plugin dependency lookup work?
Thanks for the repro project.
First issue is that you have two <properties> element. sbt will use both the URL layout and the content of the POM to resolve the plugin. Here's how to merge <properties> element. Not sure if there's more elegant way:
makePom := {
val old = makePom.value
val pom = xml.XML.loadFile(old)
val additionalProperties =
(<git.branch>{git.gitCurrentBranch.value}</git.branch>
<git.commit>{git.gitHeadCommit.value.getOrElse("N/A")+(if (git.gitUncommittedChanges.value) "-SNAPSHOT" else "")}</git.commit>
<git.tags>{git.gitCurrentTags.value}</git.tags>)
val newPom = pom.copy(child = pom.child.toSeq map {
case elem: xml.Elem if elem.label == "properties" =>
elem.copy(child = elem.child ++ additionalProperties)
case x => x
})
xml.XML.save(old.toString, newPom, enc = "UTF-8", xmlDecl = true)
old
}
Next, you should've seen something like this when you tried to resolve the plugin:
[warn] ==== Local Test: tried
[warn] file:/xxx/sbt.problem.example/test.app/project/../local.repo/org/test/test-plugin_2.10_0.13/1.0/test-plugin-1.0.pom
See that test.app/project/../local.repo/ would become test.app/local.repo. Instead of ".." here's what you can do in test.app/project/plugins.sbt:
resolvers += new MavenCache("Local Test", baseDirectory.value.getParentFile.getParentFile / "local.repo")
addSbtPlugin("org.test" % "test-plugin" % "1.0")

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

How to keep library dependencies updated to Scala version?

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.

Resources