So thus far I've been compiling my Scala project with SBT (via Typesafe stack). I want to run the code across several machines now, via sbt-assembly. Following directions, the only one change I made was in my project/Build.scala
file. Here is the related part:
resolvers += "Typesafe Releases" at "http://repo.typesafe.com/typesafe/releases",
resolvers += "artifactory" at "http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases",
libraryDependencies += "com.eed3si9n" % "sbt-assembly" % "0.8.3"
When I run sbt compile
however, I get this error:
sbt.ResolveException: unresolved dependency: com.eed3si9n#sbt-assembly/scala_2.9.1/sbt_0.11.2;0.8.3: not found
.
What am I doing wrong?
Thanks!
EDIT
Created a build.sbt
file in the same folder as Build.scala
(folder is /project/
) and have these two lines in it:
Seq[Setting[_]](resolvers += "artifactory" at "http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases",
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.8.3"))
Now the error is:
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.eed3si9n#sbt-assembly;0.8.3: 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.8.3 (sbtVersion=0.11.2, scalaVersion=2.9.1)
[warn]
[error] {file:/Users/myname/current/projectname/project/}default-d7da9a/*:update: sbt.ResolveException: unresolved dependency: com.eed3si9n#sbt-assembly;0.8.3: not found
EDIT 2
Hm, after I do a successful sbt compile
, should I just be able to enter the sbt
console and type in assembly
?
> assembly
[error] Not a valid command: assembly
[error] Not a valid project ID: assembly
[error] Not a valid configuration: assembly
[error] Not a valid key: assembly
[error] assembly
[error]
EDIT 3 JK got it. Had to add the build.sbt
info as specified in the GitHub README.
There are two points here. One is that SBT plugins are not just library dependencies -- in particular, they use the current SBT version in a similar way that other Scala libraries use the Scala version. The other is that libraryDependencies
in project/Build.scala
affects the dependencies for the project, not for the build.
An SBT full build is itself an SBT project, just located one level down the directory tree, and so can have a build of its own configured the same way a normal build is. Unlike a normal build, where going for a "full build" is necessary under a handful of circumstances, there is almost never a reason to use a full build for a build, so using .sbt
files located in project/
is almost always sufficient.
The other issue is the versioning. SBT has a utility function called addSbtPlugin
that handles everything for you. It takes a moduleID and adds all the necessary SBT and Scala versioning information.
So, to get sbt-assembly working in a full build, you create a .sbt
file in under project/
(conventionally either project/build.sbt
or project/plugins.sbt
) and place your build's resolvers and dependencies there:
resolvers += Resolver.url("artifactory", url("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns)
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.8.3")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With