Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting sbt-assembly working

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.

like image 768
adelbertc Avatar asked Jun 11 '12 21:06

adelbertc


1 Answers

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")
like image 110
RM. Avatar answered Oct 13 '22 21:10

RM.