Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The latest version of <a href="https://github.com/sbt/sbt-assembly" rel="nofollow noreferrer">sbt-assembly</a> as of Nov 2013 is <a href="http://notes.implicit.ly/post/65751699253/sbt-assembly-0-10-1" rel="nofollow noreferrer">0.10.1</a> for sbt 0.13. Using this, I was able to create a fat jar using the latest stable Akka 2.2.3 using the default merge strategy.</p> <h2>Files</h2> <p>project/build.properties:</p> <pre><code>sbt.version=0.13.0 </code></pre> <p>project/assembly.sbt:</p> <pre><code>addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.10.1") </code></pre> <p>assembly.sbt:</p> <pre><code>import AssemblyKeys._ assemblySettings </code></pre> <p>build.sbt:</p> <pre><code>name := "sbt-assembly-akka-sample" version := "0.1.0-SNAPSHOT" scalaVersion := "2.10.3" libraryDependencies ++= Seq( "com.typesafe.akka" %% "akka-actor" % "2.2.3", "com.typesafe.akka" %% "akka-remote" % "2.2.3" ) </code></pre> <p>src/main/scala/actor.scala:</p> <pre><code>package hello import akka.actor.{Actor, Props} import akka.event.Logging class MyActor extends Actor { val log = Logging(context.system, this) def receive = { case "test" ⇒ log.info("received test") case _ ⇒ log.info("received unknown message") } } </code></pre> <p>src/main/scala/app.scala:</p> <pre><code>package hello object Main extends App { import akka.actor.{ActorSystem, Props} val system = ActorSystem("mySystem") val myActor = system.actorOf(Props[MyActor], "myactor") myActor ! "test" } </code></pre> <h2>Output</h2> <p>Here's what I got by running <code>assembly</code>:</p> <pre><code>&gt; assembly [info] Updating {file:/xxx/sbt-assembly-01/}sbt-assembly-01... [info] Resolving org.fusesource.jansi#jansi;1.4 ... [info] Done updating. [info] Compiling 2 Scala sources to /xxx/sbt-assembly-01/target/scala-2.10/classes... [info] Including: uncommons-maths-1.2.2a.jar [info] Including: protobuf-java-2.4.1.jar [info] Including: config-1.0.2.jar [info] Including: netty-3.6.6.Final.jar [info] Including: akka-remote_2.10-2.2.3.jar [info] Including: akka-actor_2.10-2.2.3.jar [info] Passed: Total 0, Failed 0, Errors 0, Passed 0 [info] No tests to run for test:test [info] Including: scala-library-2.10.3.jar [info] Checking every *.class/*.jar file's SHA-1. [info] Merging files... [warn] Merging 'META-INF/NOTICE.txt' with strategy 'rename' [warn] Merging 'META-INF/license' with strategy 'rename' [warn] Merging 'META-INF/LICENSE.txt' with strategy 'rename' [warn] Merging 'META-INF/MANIFEST.MF' with strategy 'discard' [warn] Merging 'reference.conf' with strategy 'concat' [warn] Strategy 'concat' was applied to a file [warn] Strategy 'discard' was applied to a file [warn] Strategy 'rename' was applied to 3 files [info] SHA-1: 1e9dcebeddc8e2a7d41a0c55a663f9ca0000000 [info] Packaging /xxx/sbt-assembly-01/target/scala-2.10/sbt-assembly-akka-sample-assembly-0.1.0-SNAPSHOT.jar ... [info] Done packaging. [success] Total time: 13 s, completed Nov 11, 2013 8:57:18 PM </code></pre> <p>And here's what it looks like running the jar:</p> <pre><code>$ java -jar target/scala-2.10/sbt-assembly-akka-sample-assembly-0.1.0-SNAPSHOT.jar [INFO] [11/11/2013 20:59:48.265] [mySystem-akka.actor.default-dispatcher-2] [akka://mySystem/user/myactor] received test </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload