Merge pull request #16173 from akka/wip-native-packager-patriknw

=doc Describe how to use microKernel with sbt-native-packager
This commit is contained in:
Patrik Nordwall 2014-11-03 10:05:46 +01:00
commit 6800c51e56
4 changed files with 44 additions and 22 deletions

View file

@ -12,31 +12,36 @@ The Akka Microkernel is included in the Akka download found at `downloads`_.
.. _downloads: http://akka.io/downloads
To run an application with the microkernel you need to create a Bootable class
that handles the startup and shutdown the application. An example is included below.
Put your application jar in the ``deploy`` directory and additional dependencies in the ``lib`` directory
to have them automatically loaded and placed on the classpath.
To start the kernel use the scripts in the ``bin`` directory, passing the boot
classes for your application.
The start script adds ``config`` directory first in the classpath, followed by ``lib/*``.
It runs java with main class ``akka.kernel.Main`` and the supplied Bootable class as
argument.
Example command (on a unix-based system):
.. code-block:: none
bin/akka sample.kernel.hello.HelloKernel
Use ``Ctrl-C`` to interrupt and exit the microkernel.
On a Windows machine you can also use the bin/akka.bat script.
To run an application with the microkernel you need to create a Bootable class
that handles the startup and shutdown the application.
The code for the Hello Kernel example (see the ``HelloKernel`` class for an example
of creating a Bootable):
.. includecode:: ../../../akka-samples/akka-sample-hello-kernel/src/main/scala/sample/kernel/hello/HelloKernel.scala
Add `sbt-native-packager <https://github.com/sbt/sbt-native-packager>`_ to the plugins.sbt
.. code-block:: none
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.8.0-M2")
Use the package settings for ``akka_application``, and specify the mainClass in build.sbt
.. includecode:: ../../../akka-samples/akka-sample-hello-kernel/build.sbt
Use sbt task ``stage`` to generate the start script. Also you can use task ``universal:packageZipTarball`` to package the application.
To start the application (on a unix-based system):
.. code-block:: none
./target/universal/stage/bin/hello-kernel
Use ``Ctrl-C`` to interrupt and exit the microkernel.
On a Windows machine you can also use the ``target\universal\stage\bin\hello-kernel.bat`` script.

View file

@ -0,0 +1,12 @@
import NativePackagerKeys._
packageArchetype.akka_application
name := """hello-kernel"""
mainClass in Compile := Some("sample.kernel.hello.HelloKernel")
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-kernel" % "2.4-SNAPSHOT",
"com.typesafe.akka" %% "akka-actor" % "2.4-SNAPSHOT"
)

View file

@ -0,0 +1 @@
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.8.0-M2")

View file

@ -23,5 +23,9 @@ addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.3.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.6.2")
// needed for the akka-sample-hello-kernel
// it is also defined in akka-samples/akka-sample-hello-kernel/project/plugins.sbt
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.8.0-M2")
// stats reporting
libraryDependencies += "com.timgroup" % "java-statsd-client" % "2.0.0"