added final tasks (package up distribution and executable JAR) to SBT build

This commit is contained in:
Jonas Bonér 2010-03-09 22:07:14 +01:00
parent 7873a7a9e0
commit 5e7f928cb0
6 changed files with 134 additions and 353 deletions

View file

@ -79,7 +79,7 @@ object Kernel extends Logging {
(____ /__|_ \__|_ \(____ /
\/ \/ \/ \/
""")
log.info(" Running version %s", Config.VERSION)
log.info(" Running version %s", Config.VERSION)
log.info("==============================")
}
}

View file

@ -2,205 +2,3 @@
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>.
*/
package se.scalablesolutions.akka.sample.chat
import se.scalablesolutions.akka.actor.{SupervisorFactory, Actor, RemoteActor}
import se.scalablesolutions.akka.stm.Transaction._
import se.scalablesolutions.akka.remote.RemoteServer
import se.scalablesolutions.akka.util.Logging
import se.scalablesolutions.akka.config.ScalaConfig._
import se.scalablesolutions.akka.config.OneForOneStrategy
import scala.collection.mutable.HashMap
import se.scalablesolutions.akka.state.{PersistentVector, RedisStorage}
/******************************************************************************
To run the sample:
1. Run 'mvn install' (builds and deploys jar to AKKA_HOME/deploy)
2. In another shell run 'java -jar ./dist/akka-0.6.jar' to start up Akka microkernel
3. In the first shell run 'mvn scala:console -o'
4. In the REPL you get execute:
- scala> import se.scalablesolutions.akka.sample.chat._
- scala> Runner.run
5. See the chat simulation run
6. Run it again to see full speed after first initialization
******************************************************************************/
/**
* ChatServer's internal events.
*/
sealed trait Event
case class Login(user: String) extends Event
case class Logout(user: String) extends Event
case class GetChatLog(from: String) extends Event
case class ChatLog(log: List[String]) extends Event
case class ChatMessage(from: String, message: String) extends Event
/**
* Chat client.
*/
class ChatClient(val name: String) {
import Actor.Sender.Self
def login = ChatService ! Login(name)
def logout = ChatService ! Logout(name)
def post(message: String) = ChatService ! ChatMessage(name, name + ": " + message)
def chatLog: ChatLog = (ChatService !! GetChatLog(name)).getOrElse(throw new Exception("Couldn't get the chat log from ChatServer"))
}
/**
* Internal chat client session.
*/
class Session(user: String, storage: Actor) extends Actor {
private val loginTime = System.currentTimeMillis
private var userLog: List[String] = Nil
log.info("New session for user [%s] has been created at [%s]", user, loginTime)
def receive = {
case msg @ ChatMessage(from, message) =>
userLog ::= message
storage ! msg
case msg @ GetChatLog(_) =>
storage forward msg
}
}
/**
* Abstraction of chat storage holding the chat log.
*/
trait ChatStorage extends Actor
/**
* Redis-backed chat storage implementation.
*/
class RedisChatStorage extends ChatStorage {
lifeCycle = Some(LifeCycle(Permanent))
private var chatLog = atomic { RedisStorage.getVector("akka.chat.log") }
log.info("Redis-based chat storage is starting up...")
def receive = {
case msg @ ChatMessage(from, message) =>
log.debug("New chat message [%s]", message)
atomic {
chatLog + message.getBytes("UTF-8")
}
case GetChatLog(_) =>
val messageList = atomic {
chatLog.map(bytes => new String(bytes, "UTF-8")).toList
}
reply(ChatLog(messageList))
}
override def postRestart(reason: Throwable) = chatLog = RedisStorage.getVector("akka.chat.log")
}
/**
* Implements user session management.
* <p/>
* Uses self-type annotation (this: Actor =>) to declare that it needs to be mixed in with an Actor.
*/
trait SessionManagement { this: Actor =>
val storage: ChatStorage // needs someone to provide the ChatStorage
val sessions = new HashMap[String, Actor]
protected def sessionManagement: PartialFunction[Any, Unit] = {
case Login(username) =>
log.info("User [%s] has logged in", username)
val session = new Session(username, storage)
session.start
sessions += (username -> session)
case Logout(username) =>
log.info("User [%s] has logged out", username)
val session = sessions(username)
session.stop
sessions -= username
}
protected def shutdownSessions =
sessions.foreach { case (_, session) => session.stop }
}
/**
* Implements chat management, e.g. chat message dispatch.
* <p/>
* Uses self-type annotation (this: Actor =>) to declare that it needs to be mixed in with an Actor.
*/
trait ChatManagement { this: Actor =>
val sessions: HashMap[String, Actor] // needs someone to provide the Session map
protected def chatManagement: PartialFunction[Any, Unit] = {
case msg @ ChatMessage(from, _) => sessions(from) ! msg
case msg @ GetChatLog(from) => sessions(from) forward msg
}
}
/**
* Creates and links a RedisChatStorage.
*/
trait RedisChatStorageFactory { this: Actor =>
val storage: ChatStorage = spawnLink(classOf[RedisChatStorage]) // starts and links ChatStorage
}
/**
* Chat server. Manages sessions and redirects all other messages to the Session for the client.
*/
trait ChatServer extends Actor {
faultHandler = Some(OneForOneStrategy(5, 5000))
trapExit = List(classOf[Exception])
val storage: ChatStorage
log.info("Chat service is starting up...")
// actor message handler
def receive = sessionManagement orElse chatManagement
// abstract methods to be defined somewhere else
protected def chatManagement: PartialFunction[Any, Unit]
protected def sessionManagement: PartialFunction[Any, Unit]
protected def shutdownSessions: Unit
override def shutdown = {
log.info("Chat server is shutting down...")
shutdownSessions
unlink(storage)
storage.stop
}
}
/**
* Object encapsulating the full Chat Service.
*/
object ChatService extends
ChatServer with
SessionManagement with
ChatManagement with
RedisChatStorageFactory
/**
* Test runner emulating a chat session.
*/
object Runner {
// create a handle to the remote ChatService
ChatService.makeRemote("localhost", 9999)
ChatService.start
def run = {
val client = new ChatClient("jonas")
client.login
client.post("Hi there")
println("CHAT LOG:\n\t" + client.chatLog.log.mkString("\n\t"))
client.post("Hi again")
println("CHAT LOG:\n\t" + client.chatLog.log.mkString("\n\t"))
client.logout
}
}

View file

@ -1,64 +0,0 @@
#####################
# Akka Config File #
###################
# This file has all the default settings, so all these could be removed with no visible effect.
# Modify as needed.
<log>
filename = "./logs/akka.log"
roll = "daily" # Options: never, hourly, daily, sunday/monday/...
level = "debug" # Options: fatal, critical, error, warning, info, debug, trace
console = on
# syslog_host = ""
# syslog_server_name = ""
</log>
<akka>
version = "0.7-SNAPSHOT"
<actor>
timeout = 5000 # default timeout for future based invocations
concurrent-mode = off # if turned on, then the same actor instance is allowed to execute concurrently -
# e.g. departing from the actor model for better performance
serialize-messages = on # does a deep clone of (non-primitive) messages to ensure immutability
</actor>
<stm>
service = on
restart-on-collision = off # (not implemented yet) if 'on' then it reschedules the transaction,
# if 'off' then throws an exception or rollback for user to handle
wait-for-completion = 100 # how long time in millis a transaction should be given time to complete when a collision is detected
wait-nr-of-times = 3 # the number of times it should check for completion of a pending transaction upon collision
distributed = off # not implemented yet
</stm>
<remote>
service = on
hostname = "localhost"
port = 9999
connection-timeout = 1000 # in millis
</remote>
<rest>
service = on
hostname = "localhost"
port = 9998
</rest>
<storage>
system = "cassandra" # Options: cassandra (coming: terracotta, redis, tokyo-cabinet, tokyo-tyrant, voldemort, memcached, hazelcast)
<cassandra>
service = on
storage-format = "java" # Options: java, scala-json, java-json
blocking = false # inserts and queries should be blocking or not
<thrift-server>
service = on
pidfile = "akka.pid"
</thrift-server>
</cassandra>
</rest>
</akka>

View file

@ -1,35 +0,0 @@
####################
# Akka Config File #
####################
# This file has all the default settings, so all these could be removed with no visible effect.
# Modify as needed.
<akka>
version = "0.7-SNAPSHOT"
boot = ["se.scalablesolutions.akka.security.samples.Boot"] # FQN to the class doing initial active object/actor
# supervisor bootstrap, should be defined in default constructor
<rest>
filters = "se.scalablesolutions.akka.security.AkkaSecurityFilterFactory"
# only one authenticator can be enabled for the security filter factory
authenticator = "se.scalablesolutions.akka.security.samples.BasicAuthenticationService"
# authenticator = "se.scalablesolutions.akka.security.samples.DigestAuthenticationService"
# authenticator = "se.scalablesolutions.akka.security.samples.SpnegoAuthenticationService"
#
# <kerberos>
# servicePrincipal = "HTTP/localhost@EXAMPLE.COM"
# keyTabLocation = "URL to keytab"
# kerberosDebug = "true"
# realm = "EXAMPLE.COM"
# </kerberos>
# service = on
# hostname = "localhost"
# port = 9998
</rest>
</akka>

View file

@ -2,17 +2,16 @@ import sbt._
class AkkaJavaUtilProject(info: ProjectInfo) extends DefaultProject(info) {
val akka_databinder = "DataBinder" at "http://databinder.net/repo"
val akka_configgy = "Configgy" at "http://www.lag.net/repo"
val akka_multiverse = "Multiverse" at "http://multiverse.googlecode.com/svn/maven-repository/releases"
val akka_jBoss = "jBoss" at "http://repository.jboss.org/maven2"
val guiceyfruit = "GuiceyFruit" at "http://guiceyfruit.googlecode.com/svn/repo/releases/"
val databinder = "DataBinder" at "http://databinder.net/repo"
val configgy = "Configgy" at "http://www.lag.net/repo"
val multiverse = "Multiverse" at "http://multiverse.googlecode.com/svn/maven-repository/releases"
val jBoss = "jBoss" at "http://repository.jboss.org/maven2"
val guiceyfruit = "GuiceyFruit" at "http://guiceyfruit.googlecode.com/svn/repo/releases/"
val guicey = "org.guiceyfruit" % "guice-core" % "2.0-beta-4" % "compile"
val proto = "com.google.protobuf" % "protobuf-java" % "2.2.0" % "compile"
val multi = "org.multiverse" % "multiverse-alpha" % "0.3" % "compile"
override def packageDocsJar = defaultJarPath("-javadoc.jar")
override def packageSrcJar= defaultJarPath("-sources.jar")
val guicey = "org.guiceyfruit" % "guice-core" % "2.0-beta-4" % "compile"
val proto = "com.google.protobuf" % "protobuf-java" % "2.2.0" % "compile"
val multi = "org.multiverse" % "multiverse-alpha" % "0.3" % "compile"
override def packageDocsJar = defaultJarPath("-javadoc.jar")
override def packageSrcJar= defaultJarPath("-sources.jar")
}

View file

@ -35,8 +35,14 @@
-------------------------------------------------------------------------------*/
import sbt._
import java.util.jar.Attributes
class AkkaParent(info: ProjectInfo) extends DefaultProject(info) {
// project versions
val JERSEY_VERSION = "1.1.5"
val ATMO_VERSION = "0.6-SNAPSHOT"
val CASSANDRA_VERSION = "0.5.0"
class AkkaParent(info: ProjectInfo) extends ParentProject(info) {
// repos
val sunjdmk = "sunjdmk" at "http://wp5.e-taxonomy.eu/cdmlib/mavenrepo"
val databinder = "DataBinder" at "http://databinder.net/repo"
@ -49,13 +55,8 @@ class AkkaParent(info: ProjectInfo) extends ParentProject(info) {
val google = "google" at "http://google-maven-repository.googlecode.com/svn/repository"
val m2 = "m2" at "http://download.java.net/maven/2"
// project versions
val JERSEY_VERSION = "1.1.5"
val ATMO_VERSION = "0.6-SNAPSHOT"
val CASSANDRA_VERSION = "0.5.0"
// project defintions
lazy val akka_java_util = project("akka-util-java", "akka-java-util", new AkkaJavaUtilProject(_))
lazy val akka_java_util = project("akka-util-java", "akka-util-java", new AkkaJavaUtilProject(_))
lazy val akka_util = project("akka-util", "akka-util", new AkkaUtilProject(_))
lazy val akka_core = project("akka-core", "akka-core", new AkkaCoreProject(_), akka_util, akka_java_util)
lazy val akka_amqp = project("akka-amqp", "akka-amqp", new AkkaAMQPProject(_), akka_core)
@ -65,74 +66,153 @@ class AkkaParent(info: ProjectInfo) extends ParentProject(info) {
lazy val akka_security = project("akka-security", "akka-security", new AkkaSecurityProject(_), akka_core)
lazy val akka_persistence = project("akka-persistence", "akka-persistence", new AkkaPersistenceParentProject(_))
lazy val akka_cluster = project("akka-cluster", "akka-cluster", new AkkaClusterParentProject(_))
lazy val akka_kernel = project("akka-kernel", "akka-kernel", new AkkaKernelProject(_), akka_core, akka_rest, akka_persistence, akka_cluster, akka_amqp, akka_security, akka_comet)
lazy val akka_kernel = project("akka-kernel", "akka-kernel", new AkkaKernelProject(_), akka_core, akka_rest, akka_persistence, akka_cluster, akka_amqp, akka_security, akka_comet, akka_patterns)
// examples
lazy val akka_fun_test = project("akka-fun-test-java", "akka-fun-test-java", new AkkaFunTestProject(_), akka_kernel)
lazy val akka_samples = project("akka-samples", "akka-samples", new AkkaSamplesParentProject(_))
def akkaHome = {
def distName = "%s-%s.zip".format(name, version)
lazy val akkaHome = {
val home = System.getenv("AKKA_HOME")
if (home == null) throw new Error("You need to set the $AKKA_HOME environment variable to the root of the Akka distribution")
home
}
lazy val deployPath = Path.fromFile(new java.io.File(akkaHome + "/deploy"))
lazy val distPath = Path.fromFile(new java.io.File(akkaHome + "/dist"))
override def mainClass = Some("se.scalablesolutions.akka.Main")
override def packageOptions =
manifestClassPath.map(cp => ManifestAttributes((Attributes.Name.CLASS_PATH, cp))).toList :::
getMainClass(false).map(MainClass(_)).toList
override def manifestClassPath = Some(allArtifacts.getFiles
.filter(_.getName.endsWith(".jar"))
.map("lib_managed/scala_%s/compile/".format(defScalaVersion.value) + _.getName)
.mkString(" ") +
" dist/akka-util_%s-%s.jar".format(defScalaVersion.value, version) +
" dist/akka-util-java_%s-%s.jar".format(defScalaVersion.value, version) +
" dist/akka-core_%s-%s.jar".format(defScalaVersion.value, version) +
" dist/akka-rest_%s-%s.jar".format(defScalaVersion.value, version) +
" dist/akka-comet_%s-%s.jar".format(defScalaVersion.value, version) +
" dist/akka-security_%s-%s.jar".format(defScalaVersion.value, version) +
" dist/akka-persistence-common_%s-%s.jar".format(defScalaVersion.value, version) +
" dist/akka-persistence-redis_%s-%s.jar".format(defScalaVersion.value, version) +
" dist/akka-persistence-cassandra_%s-%s.jar".format(defScalaVersion.value, version) +
" dist/akka-persistence-mongo_%s-%s.jar".format(defScalaVersion.value, version) +
" dist/akka-cluster-jgroups_%s-%s.jar".format(defScalaVersion.value, version) +
" dist/akka-cluster-shoal_%s-%s.jar".format(defScalaVersion.value, version) +
" dist/akka-amqp_%s-%s.jar".format(defScalaVersion.value, version) +
" dist/akka-patterns_%s-%s.jar".format(defScalaVersion.value, version) +
" dist/akka-kernel_%s-%s.jar".format(defScalaVersion.value, version)
)
/*
override def manifestClassPath = Some(allArtifacts.getFiles
.filter(_.getName.endsWith(".jar"))
.map { jar =>
println("------- " + jar)
if (jar.getName.contains("akka")) "dist/" + jar.getName
else "lib_managed/scala_2.7.7/compile/" + jar.getName
}.mkString(" "))
*/
def removeDupEntries(paths: PathFinder) =
Path.lazyPathFinder {
val mapped = paths.get map { p => (p.relativePath, p) }
(Map() ++ mapped).values.toList
}
def allArtifacts = {
removeDupEntries(runClasspath filter ClasspathUtilities.isArchive) +++
((outputPath ##) / defaultJarName) +++
mainResources +++
mainDependencies.scalaJars +++
descendents(info.projectPath, "*.conf") +++
descendents(info.projectPath / "dist", "*.jar") +++
descendents(path("lib") ##, "*.jar") +++
descendents(configurationPath(Configurations.Compile) ##, "*.jar")
}
def deployTask(info: ProjectInfo, toDir: Path) = task {
val projectPath = info.projectPath.toString
val moduleName = projectPath.substring(projectPath.lastIndexOf('/') + 1, projectPath.length)
// FIXME need to find out a way to grab these paths from the sbt system
val JAR_FILE_NAME = moduleName + "_%s-%s.jar".format(defScalaVersion.value, version)
val JAR_FILE_PATH = projectPath + "/target/scala_%s/".format(defScalaVersion.value) + JAR_FILE_NAME
val from = Path.fromFile(new java.io.File(JAR_FILE_PATH))
val to = Path.fromFile(new java.io.File(toDir + "/" + JAR_FILE_NAME))
log.info("Deploying " + to)
FileUtilities.copyFile(from, to, log)
}
lazy val dist = zipTask(allArtifacts, "dist", distName) dependsOn (`package`) describedAs("Zips up the distribution.")
// subprojects
class AkkaCoreProject(info: ProjectInfo) extends DefaultProject(info) {
val sjson = "sjson.json" % "sjson" % "0.4" % "compile"
val werkz = "org.codehaus.aspectwerkz" % "aspectwerkz-nodeps-jdk5" % "2.1" % "compile"
val werkz_core = "org.codehaus.aspectwerkz" % "aspectwerkz-jdk5" % "2.1" % "compile"
val netty = "org.jboss.netty" % "netty" % "3.2.0.BETA1" % "compile"
val commons_io = "commons-io" % "commons-io" % "1.4" % "compile"
val dispatch_json = "net.databinder" % "dispatch-json_2.7.7" % "0.6.4" % "compile"
val dispatch_http = "net.databinder" % "dispatch-http_2.7.7" % "0.6.4" % "compile"
val dispatch_htdisttp = "net.databinder" % "dispatch-http_2.7.7" % "0.6.4" % "compile"
val sjson = "sjson.json" % "sjson" % "0.4" % "compile"
val sbinary = "sbinary" % "sbinary" % "0.3" % "compile"
val jackson = "org.codehaus.jackson" % "jackson-mapper-asl" % "1.2.1" % "compile"
val jackson_core = "org.codehaus.jackson" % "jackson-core-asl" % "1.2.1" % "compile"
val voldemort = "voldemort.store.compress" % "h2-lzf" % "1.0" % "compile"
val javautils = "org.scala-tools" % "javautils" % "2.7.4-0.1" % "compile"
val netty = "org.jboss.netty" % "netty" % "3.2.0.BETA1" % "compile"
// testing
val scalatest = "org.scalatest" % "scalatest" % "1.0" % "test"
val junit = "junit" % "junit" % "4.5" % "test"
lazy val dist = deployTask(info, distPath) dependsOn(`package`) describedAs("Deploying")
}
class AkkaUtilProject(info: ProjectInfo) extends DefaultProject(info) {
val werkz = "org.codehaus.aspectwerkz" % "aspectwerkz-nodeps-jdk5" % "2.1" % "compile"
val werkz_core = "org.codehaus.aspectwerkz" % "aspectwerkz-jdk5" % "2.1" % "compile"
val configgy = "net.lag" % "configgy" % "1.4.7" % "compile"
lazy val dist = deployTask(info, distPath) dependsOn(`package`) describedAs("Deploying")
}
class AkkaJavaUtilProject(info: ProjectInfo) extends DefaultProject(info) {
val guicey = "org.guiceyfruit" % "guice-core" % "2.0-beta-4" % "compile"
val protobuf = "com.google.protobuf" % "protobuf-java" % "2.2.0" % "compile"
val multiverse = "org.multiverse" % "multiverse-alpha" % "0.4-SNAPSHOT" % "compile"
lazy val dist = deployTask(info, distPath) dependsOn(`package`) describedAs("Deploying")
}
class AkkaAMQPProject(info: ProjectInfo) extends DefaultProject(info) {
val rabbit = "com.rabbitmq" % "amqp-client" % "1.7.2"
lazy val dist = deployTask(info, distPath) dependsOn(`package`) describedAs("Deploying")
}
class AkkaRestProject(info: ProjectInfo) extends DefaultProject(info) {
val servlet = "javax.servlet" % "servlet-api" % "2.5" % "provided"
val servlet = "javax.servlet" % "servlet-api" % "2.5" % "compile"
val jersey = "com.sun.jersey" % "jersey-core" % JERSEY_VERSION % "compile"
val jersey_server = "com.sun.jersey" % "jersey-server" % JERSEY_VERSION % "compile"
val jersey_json = "com.sun.jersey" % "jersey-json" % JERSEY_VERSION % "compile"
val jersey_contrib = "com.sun.jersey.contribs" % "jersey-scala" % JERSEY_VERSION % "compile"
val jsr311 = "javax.ws.rs" % "jsr311-api" % "1.1" % "compile"
lazy val dist = deployTask(info, distPath) dependsOn(`package`) describedAs("Deploying")
}
class AkkaCometProject(info: ProjectInfo) extends DefaultProject(info) {
val grizzly = "com.sun.grizzly" % "grizzly-comet-webserver" % "1.9.18-i" % "compile"
val servlet = "javax.servlet" % "servlet-api" % "2.5" % "provided"
val servlet = "javax.servlet" % "servlet-api" % "2.5" % "compile"
val atmo = "org.atmosphere" % "atmosphere-annotations" % ATMO_VERSION % "compile"
val atmo_jersey = "org.atmosphere" % "atmosphere-jersey" % ATMO_VERSION % "compile"
val atmo_runtime = "org.atmosphere" % "atmosphere-runtime" % ATMO_VERSION % "compile"
lazy val dist = deployTask(info, distPath) dependsOn(`package`) describedAs("Deploying")
}
class AkkaPatternsProject(info: ProjectInfo) extends DefaultProject(info) {
// testing
val scalatest = "org.scalatest" % "scalatest" % "1.0" % "test"
val junit = "junit" % "junit" % "4.5" % "test"
lazy val dist = deployTask(info, distPath) dependsOn(`package`) describedAs("Deploying")
}
class AkkaSecurityProject(info: ProjectInfo) extends DefaultProject(info) {
@ -144,21 +224,25 @@ class AkkaParent(info: ProjectInfo) extends ParentProject(info) {
val scalatest = "org.scalatest" % "scalatest" % "1.0" % "test"
val junit = "junit" % "junit" % "4.5" % "test"
val mockito = "org.mockito" % "mockito-all" % "1.8.1" % "test"
lazy val dist = deployTask(info, distPath) dependsOn(`package`) describedAs("Deploying")
}
class AkkaPersistenceCommonProject(info: ProjectInfo) extends DefaultProject(info) {
val thrift = "com.facebook" % "thrift" % "1.0" % "compile"
val commons_pool = "commons-pool" % "commons-pool" % "1.5.1" % "compile"
lazy val dist = deployTask(info, distPath) dependsOn(`package`) describedAs("Deploying")
}
class AkkaRedisProject(info: ProjectInfo) extends DefaultProject(info) {
val redis = "com.redis" % "redisclient" % "1.1" % "compile"
override def testOptions = TestFilter((name: String) => name.endsWith("Test")) :: Nil
lazy val dist = deployTask(info, distPath) dependsOn(`package`) describedAs("Deploying")
}
class AkkaMongoProject(info: ProjectInfo) extends DefaultProject(info) {
val mongo = "org.mongodb" % "mongo-java-driver" % "1.1" % "compile"
override def testOptions = TestFilter((name: String) => name.endsWith("Test")) :: Nil
lazy val dist = deployTask(info, distPath) dependsOn(`package`) describedAs("Deploying")
}
class AkkaCassandraProject(info: ProjectInfo) extends DefaultProject(info) {
@ -171,6 +255,7 @@ class AkkaParent(info: ProjectInfo) extends ParentProject(info) {
val slf4j_log4j = "org.slf4j" % "slf4j-log4j12" % "1.5.8" % "test"
val log4j = "log4j" % "log4j" % "1.2.15" % "test"
override def testOptions = TestFilter((name: String) => name.endsWith("Test")) :: Nil
lazy val dist = deployTask(info, distPath) dependsOn(`package`) describedAs("Deploying")
}
class AkkaPersistenceParentProject(info: ProjectInfo) extends ParentProject(info) {
@ -182,11 +267,13 @@ class AkkaParent(info: ProjectInfo) extends ParentProject(info) {
class AkkaJgroupsProject(info: ProjectInfo) extends DefaultProject(info) {
val jgroups = "jgroups" % "jgroups" % "2.8.0.CR7" % "compile"
lazy val dist = deployTask(info, distPath) dependsOn(`package`) describedAs("Deploying")
}
class AkkaShoalProject(info: ProjectInfo) extends DefaultProject(info) {
val shoal = "shoal-jxta" % "shoal" % "1.1-20090818" % "compile"
val shoal_extra = "shoal-jxta" % "jxta" % "1.1-20090818" % "compile"
lazy val dist = deployTask(info, distPath) dependsOn(`package`) describedAs("Deploying")
}
class AkkaClusterParentProject(info: ProjectInfo) extends ParentProject(info) {
@ -194,15 +281,8 @@ class AkkaParent(info: ProjectInfo) extends ParentProject(info) {
lazy val akka_cluster_shoal = project("akka-cluster-shoal", "akka-cluster-shoal", new AkkaShoalProject(_), akka_core)
}
class AkkaKernelProject(info: ProjectInfo) extends DefaultProject(info) with AssemblyProject {
val jersey_server = "com.sun.jersey" % "jersey-server" % JERSEY_VERSION % "compile"
val atmo = "org.atmosphere" % "atmosphere-annotations" % ATMO_VERSION % "compile"
val atmo_jersey = "org.atmosphere" % "atmosphere-jersey" % ATMO_VERSION % "compile"
val atmo_runtime = "org.atmosphere" % "atmosphere-runtime" % ATMO_VERSION % "compile"
val assemblyDistPath = Path.fromFile(new java.io.File(akkaHome + "/dist/akka-" + version.toString + ".jar"))
def mainMethod = Some("se.scalablesolutions.akka.Main")
override def packageOptions: Seq[PackageOption] = MainClass("se.scalablesolutions.akka.Main") :: Nil
class AkkaKernelProject(info: ProjectInfo) extends DefaultProject(info) {
lazy val dist = deployTask(info, distPath) dependsOn(`package`) describedAs("Deploying")
}
// examples
@ -217,27 +297,33 @@ class AkkaParent(info: ProjectInfo) extends ParentProject(info) {
val jmock = "org.jmock" % "jmock" % "2.4.0" % "test"
}
class AkkaSampleChatProject(info: ProjectInfo) extends DefaultProject(info)
class AkkaSampleChatProject(info: ProjectInfo) extends DefaultProject(info) {
lazy val dist = deployTask(info, deployPath) dependsOn(`package`) describedAs("Deploying")
}
class AkkaSampleLiftProject(info: ProjectInfo) extends DefaultProject(info) {
val lift = "net.liftweb" % "lift-webkit" % "1.1-M6" % "compile"
val lift_util = "net.liftweb" % "lift-util" % "1.1-M6" % "compile"
val servlet = "javax.servlet" % "servlet-api" % "2.5" % "provided"
val servlet = "javax.servlet" % "servlet-api" % "2.5" % "compile"
// testing
val jetty = "org.mortbay.jetty" % "jetty" % "6.1.6" % "test"
val junit = "junit" % "junit" % "4.5" % "test"
lazy val dist = deployTask(info, deployPath) dependsOn(`package`) describedAs("Deploying")
}
class AkkaSampleRestJavaProject(info: ProjectInfo) extends DefaultProject(info)
class AkkaSampleRestJavaProject(info: ProjectInfo) extends DefaultProject(info) {
lazy val dist = deployTask(info, deployPath) dependsOn(`package`) describedAs("Deploying")
}
class AkkaSampleRestScalaProject(info: ProjectInfo) extends DefaultProject(info) {
val jsr311 = "javax.ws.rs" % "jsr311-api" % "1.1" % "compile"
lazy val dist = deployTask(info, deployPath) dependsOn(`package`) describedAs("Deploying")
}
class AkkaSampleSecurityProject(info: ProjectInfo) extends DefaultProject(info) {
val jsr311 = "javax.ws.rs" % "jsr311-api" % "1.1" % "compile"
val jsr250 = "javax.annotation" % "jsr250-api" % "1.0"
lazy val dist = deployTask(info, deployPath) dependsOn(`package`) describedAs("Deploying")
}
class AkkaSamplesParentProject(info: ProjectInfo) extends ParentProject(info) {
@ -246,15 +332,12 @@ class AkkaParent(info: ProjectInfo) extends ParentProject(info) {
lazy val akka_sample_rest_java = project("akka-sample-rest-java", "akka-sample-rest-java", new AkkaSampleRestJavaProject(_), akka_kernel)
lazy val akka_sample_rest_scala = project("akka-sample-rest-scala", "akka-sample-rest-scala", new AkkaSampleRestScalaProject(_), akka_kernel)
lazy val akka_sample_security = project("akka-sample-security", "akka-sample-security", new AkkaSampleSecurityProject(_), akka_kernel)
//FileUtilities.copyFile(assemblyOutputPath, assemblyDistPath, log)
}
}
trait AssemblyProject extends BasicScalaProject {
val assemblyDistPath: Path
def assemblyExclude(base: PathFinder) = base / "META-INF" ** "*"
//def assemblyExclude(base: PathFinder) = base / "META-INF" ** "*"
def assemblyExclude(base: PathFinder) = Path.emptyPathFinder
def assemblyOutputPath = outputPath / assemblyJarName
def assemblyJarName = artifactID + "-assembly-" + version + ".jar"
def assemblyTemporaryPath = outputPath / "assembly-libs"
@ -263,16 +346,16 @@ trait AssemblyProject extends BasicScalaProject {
def assemblyPaths(tempDir: Path, classpath: PathFinder, extraJars: PathFinder, exclude: PathFinder => PathFinder) = {
val (libs, directories) = classpath.get.toList.partition(ClasspathUtilities.isArchive)
for(jar <- extraJars.get ++ libs) FileUtilities.unzip(jar, tempDir, log)
val filter = new NameFilter {
def accept(name: String) = !name.endsWith("LICENSE") && !name.endsWith("MANIFEST.MF")
}
for(jar <- extraJars.get ++ libs) FileUtilities.unzip(jar, tempDir, filter, log).left.foreach(error)
val base = (Path.lazyPathFinder(tempDir :: directories) ##)
(descendents(base, "*") --- exclude(base)).get
}
lazy val assembly = assemblyTask(assemblyTemporaryPath, assemblyClasspath, assemblyExtraJars, assemblyExclude) dependsOn(compile) describedAs("Packaging assembly")
lazy val assembly = assemblyTask(assemblyTemporaryPath, assemblyClasspath, assemblyExtraJars, assemblyExclude) dependsOn(compile) describedAs("Packaging assembly ")
lazy val dist = task({ log.info("Creating distribution " + assemblyDistPath); FileUtilities.copyFile(assemblyOutputPath, assemblyDistPath, log) }) dependsOn(assembly) describedAs("Creating distribution")
def assemblyTask(tempDir: Path, classpath: PathFinder, extraJars: PathFinder, exclude: PathFinder => PathFinder) = {
def assemblyTask(tempDir: Path, classpath: PathFinder, extraJars: PathFinder, exclude: PathFinder => PathFinder) =
packageTask(Path.lazyPathFinder(assemblyPaths(tempDir, classpath, extraJars, exclude)), assemblyOutputPath, packageOptions)
}
}