Removed Maven projects and added bnd4sbt

This commit is contained in:
Roman Roelofsen 2010-06-07 15:59:47 +02:00
parent c863cc5d14
commit 15d6ce3c50
12 changed files with 29 additions and 563 deletions

View file

@ -1,56 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>se.scalablesolutions.akka</groupId>
<artifactId>akka-osgi-parent</artifactId>
<version>0.7-SNAPSHOT</version>
</parent>
<artifactId>akka-dependencies-bundle</artifactId>
<name>Akka Dependencies Bundle</name>
<dependencies>
<dependency>
<artifactId>akka-kernel</artifactId>
<groupId>se.scalablesolutions.akka</groupId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Import-Package>
*;resolution:=optional
</Import-Package>
<Export-Package>
<!-- wrong class file declaration, not needed anyway -->
!test.*,
<!-- dependencies that provide their own bundle -->
!scala.*,
!org.apache.commons.io.*,
!org.codehaus.jackson.*,
!org.codehaus.jettison.*,
!org.jboss.netty.*,
<!-- provided by Akka modules -->
!se.scalablesolutions.akka.*,
<!-- include the rest -->
*;-split-package:=merge-first
</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>

View file

@ -1,49 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>akka-sample-osgi</artifactId>
<name>Akka OSGi Sample Module</name>
<packaging>jar</packaging>
<parent>
<artifactId>akka-osgi-parent</artifactId>
<groupId>se.scalablesolutions.akka</groupId>
<version>0.7-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<artifactId>akka-core</artifactId>
<groupId>se.scalablesolutions.akka</groupId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Bundle-Activator>se.scalablesolutions.akka.osgi.sample.Activator</Bundle-Activator>
<Export-Package>
se.scalablesolutions.akka.osgi.sample
</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>

View file

@ -1,36 +0,0 @@
package se.scalablesolutions.akka.osgi.sample
import org.osgi.framework.{BundleContext, BundleActivator}
import se.scalablesolutions.akka.config.ScalaConfig._
import se.scalablesolutions.akka.actor.{Supervisor, SupervisorFactory}
class Activator extends BundleActivator {
var supervisor: Supervisor = _
val ping = new Ping
def start(context: BundleContext) {
println("Starting Akka OSGi sample")
supervisor = SupervisorFactory(
SupervisorConfig(
RestartStrategy(OneForOne, 3, 100, List(classOf[Exception])),
Supervise(ping, LifeCycle(Permanent)) :: Nil)).newInstance
supervisor.start
println("Supervisor: " + supervisor)
println("Sending ping")
ping send CounterMessage(0)
}
def stop(context: BundleContext) {
println("Stopping Akka OSGi sample")
supervisor.stop
}
}

View file

@ -1,18 +0,0 @@
package se.scalablesolutions.akka.osgi.sample
import se.scalablesolutions.akka.actor.Actor
case class CounterMessage(counter: Int)
class Ping extends Actor {
def receive = {
case CounterMessage(i) => println("Got message " + i)
}
}
class Pong extends Actor {
def receive = {
case _ =>
}
}

View file

@ -1,46 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>se.scalablesolutions.akka</groupId>
<artifactId>akka-osgi-parent</artifactId>
<version>0.7-SNAPSHOT</version>
</parent>
<artifactId>akka-deployer</artifactId>
<name>Akka Deployer</name>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Bundle-Activator>se.scalablesolutions.akka.osgi.deployer.Activator</Bundle-Activator>
<Private-Package>se.scalablesolutions.akka.osgi.deployer.*</Private-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>

View file

@ -1,36 +0,0 @@
package se.scalablesolutions.akka.osgi.deployer
import org.osgi.framework.{BundleContext, BundleActivator}
import java.io.File
class Activator extends BundleActivator {
private val AKKA_DEPLOYER_DIR = "akka.deployer.dir"
private val AKKA_DEPLOYER_POLL = "akka.deployer.poll"
private var watcher: DirWatcher = _
def start(context: BundleContext) {
var bundlesDir = context.getProperty(AKKA_DEPLOYER_DIR)
bundlesDir = if (bundlesDir == null) "akka" else bundlesDir
// check dir exists
if (new File(bundlesDir).listFiles == null) {
System.out.println("DirInstaller WARNING: Directory '" + bundlesDir + "' does not exist!")
return
}
var interval = context.getProperty(AKKA_DEPLOYER_POLL)
interval = if (interval == null) "2000" else interval
watcher = new DirWatcher(context, bundlesDir, interval.toInt)
watcher.startWatching
}
def stop(context: BundleContext) {
if (watcher != null)
watcher.stopWatching
}
}

View file

@ -1,112 +0,0 @@
package se.scalablesolutions.akka.osgi.deployer
import org.osgi.util.tracker.ServiceTracker
import java.io.File
import org.osgi.service.packageadmin.PackageAdmin
import org.osgi.framework.{Bundle, BundleContext}
class DirWatcher(context: BundleContext, bundlesDir: String, interval: Int) {
private var running = false
private final var timestamps = Map[String, Long]()
private val packageAdminTracker = new ServiceTracker(context, classOf[PackageAdmin].getName, null)
packageAdminTracker.open
def startWatching {
if (running) return
running = true
new Thread {
override def run {
try {
while (running) {
val found = getAllFiles(bundlesDir)
analyseNewState(found)
Thread.sleep(interval)
}
}
catch {
case e: InterruptedException =>
}
}
}.start()
}
def stopWatching {
running = false
}
private def getAllFiles(dirName: String): List[File] = {
val content = new File(dirName).listFiles
val files = content.filter(_.isFile).toList
val childs = content.filter(_.isDirectory).toList.flatMap(d => getAllFiles(d.getCanonicalPath))
files ::: childs
}
private def analyseNewState(found: List[File]) {
println("FOUND:" + found)
// new or updated
val changed = found.filter(f => timestamps.getOrElse(f.getCanonicalPath, -1L) < f.lastModified)
changed.foreach {f =>
val name = f.getCanonicalPath
timestamps += (name -> f.lastModified)
if (name.endsWith(".jar")) installOrUpdateBundle(name)
}
println("CHANGED:" + changed)
// removed
val removed = timestamps.filter(f => !found.map(_.getCanonicalPath).contains(f._1))
removed.foreach {f =>
context.getBundles.filter(b => b.getLocation.equals("file:" + f._1)).foreach(_.uninstall)
timestamps -= f._1
}
println("REMOVED:" + removed)
if (changed.size + removed.size > 0)
startAllAndRefresh()
println("")
}
private def startAllAndRefresh() {
context.getBundles.filter(b => b.getState != Bundle.ACTIVE && !isFragment(b)).foreach {b =>
try {
b.start
} catch {
case e: Exception => {
System.out.println("Problems starting bundle: " + b)
e.printStackTrace
}
}
}
val admin = this.packageAdminTracker.getService.asInstanceOf[PackageAdmin]
System.out.println("DirInstaller: Refreshing packages")
admin.refreshPackages(null)
}
private def isFragment(b: Bundle): Boolean = {
var admin: PackageAdmin = this.packageAdminTracker.getService.asInstanceOf[PackageAdmin]
return admin.getBundleType(b) == PackageAdmin.BUNDLE_TYPE_FRAGMENT
}
private def installOrUpdateBundle(s: String) {
for (b <- context.getBundles) {
if (b.getLocation.endsWith(s)) {
System.out.println("DirInstaller: Updating bundle [" + b.getSymbolicName + "]")
b.stop
b.update
return
}
}
System.out.println("DirInstaller: Installing bundle [" + s + "]")
context.installBundle("file:" + s)
}
}

View file

@ -1,127 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>akka-osgi-parent</artifactId>
<groupId>se.scalablesolutions.akka</groupId>
<version>0.7-SNAPSHOT</version>
</parent>
<artifactId>akka-karaf</artifactId>
<name>Akka OSGi Karaf Distribution</name>
<packaging>pom</packaging>
<properties>
<karaf.url>http://www.apache.org/dist/felix/apache-felix-karaf-1.4.0.tar.gz</karaf.url>
<karaf.root.dir>apache-felix-karaf-1.4.0</karaf.root.dir>
</properties>
<dependencies>
<!-- All Akka dependencies, created from the akka-kernel jar -->
<dependency>
<artifactId>akka-dependencies-bundle</artifactId>
<groupId>se.scalablesolutions.akka</groupId>
<version>${project.version}</version>
</dependency>
<!-- Akka dependencies that already provide OSGi bundles -->
<dependency>
<artifactId>scala-library</artifactId>
<groupId>org.scala-lang-osgi</groupId>
<version>2.7.7</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.jboss.netty</groupId>
<artifactId>netty</artifactId>
<version>3.2.0.ALPHA3</version>
</dependency>
<!-- Akka modules -->
<dependency>
<artifactId>akka-core</artifactId>
<groupId>se.scalablesolutions.akka</groupId>
<version>${project.version}</version>
</dependency>
<dependency>
<artifactId>akka-deployer</artifactId>
<groupId>se.scalablesolutions.akka</groupId>
<version>${project.version}</version>
</dependency>
<dependency>
<artifactId>akka-sample-osgi</artifactId>
<groupId>se.scalablesolutions.akka</groupId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution> <id>generate-resources</id>
<phase>generate-resources</phase> <configuration>
<tasks>
<mkdir dir="target/downloaded" />
<get src="${karaf.url}"
dest="target/downloaded/karaf.tar.gz"
usetimestamp="true"
verbose="true" />
<gunzip src="target/downloaded/karaf.tar.gz" />
<untar src="target/downloaded/karaf.tar"
dest="target/generated/runtime" overwrite="false" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>src/main/assembly/runtime.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-distribution-dir</id>
<phase>package</phase>
<goals>
<goal>directory-single</goal>
</goals>
</execution>
<execution>
<id>make-distribution-zip</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View file

@ -1,37 +0,0 @@
<assembly>
<id>runtime</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>src/main/resources/runtime</directory>
<outputDirectory></outputDirectory>
</fileSet>
<fileSet>
<directory>target/generated/runtime</directory>
<outputDirectory></outputDirectory>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<excludes>
<exclude>se.scalablesolutions.akka:akka-deployer</exclude>
</excludes>
<outputDirectory>${karaf.root.dir}/akka</outputDirectory>
<useTransitiveDependencies>false</useTransitiveDependencies>
<useProjectArtifact>false</useProjectArtifact>
<useProjectAttachments>false</useProjectAttachments>
</dependencySet>
<dependencySet>
<includes>
<include>se.scalablesolutions.akka:akka-deployer</include>
</includes>
<outputDirectory>${karaf.root.dir}/deploy</outputDirectory>
<useTransitiveDependencies>false</useTransitiveDependencies>
<useProjectArtifact>false</useProjectArtifact>
<useProjectAttachments>false</useProjectAttachments>
</dependencySet>
</dependencySets>
</assembly>

View file

@ -1,45 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>se.scalablesolutions.akka</groupId>
<artifactId>akka</artifactId>
<version>0.7-SNAPSHOT</version>
</parent>
<artifactId>akka-osgi-parent</artifactId>
<name>Akka OSGi Parent</name>
<packaging>pom</packaging>
<properties>
<osgi.version>4.2.0</osgi.version>
</properties>
<modules>
<module>deployer</module>
<module>akka-dependencies-bundle</module>
<module>akka-sample-osgi</module>
<module>karaf</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>${osgi.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
<version>${osgi.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>

View file

@ -10,6 +10,8 @@ import java.util.jar.Attributes
import java.util.jar.Attributes.Name._ import java.util.jar.Attributes.Name._
import java.io.File import java.io.File
import com.weiglewilczek.bnd4sbt.BNDPlugin
class AkkaParent(info: ProjectInfo) extends DefaultProject(info) { class AkkaParent(info: ProjectInfo) extends DefaultProject(info) {
// ------------------------------------------------------------ // ------------------------------------------------------------
@ -65,6 +67,7 @@ class AkkaParent(info: ProjectInfo) extends DefaultProject(info) {
lazy val akka_jta = project("akka-jta", "akka-jta", new AkkaJTAProject(_), akka_core) lazy val akka_jta = project("akka-jta", "akka-jta", new AkkaJTAProject(_), akka_core)
lazy val akka_kernel = project("akka-kernel", "akka-kernel", new AkkaKernelProject(_), lazy val akka_kernel = project("akka-kernel", "akka-kernel", new AkkaKernelProject(_),
akka_core, akka_http, akka_spring, akka_camel, akka_persistence, akka_amqp) akka_core, akka_http, akka_spring, akka_camel, akka_persistence, akka_amqp)
lazy val akka_osgi = project("akka-osgi", "akka-osgi", new AkkaOSGiParentProject(_))
// functional tests in java // functional tests in java
lazy val akka_fun_test = project("akka-fun-test-java", "akka-fun-test-java", new AkkaFunTestProject(_), akka_kernel) lazy val akka_fun_test = project("akka-fun-test-java", "akka-fun-test-java", new AkkaFunTestProject(_), akka_kernel)
@ -273,6 +276,29 @@ class AkkaParent(info: ProjectInfo) extends DefaultProject(info) {
val jta_spec = "org.apache.geronimo.specs" % "geronimo-jta_1.1_spec" % "1.1.1" % "compile" val jta_spec = "org.apache.geronimo.specs" % "geronimo-jta_1.1_spec" % "1.1.1" % "compile"
} }
// ================= OSGi Packaging ==================
class AkkaOSGiBundleProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) with BNDPlugin {
override def bndClasspath = compileClasspath
override def bndPrivatePackage = Set("")
override def bndExportPackage = Set("se.scalablesolutions.akka.*;version=0.9")
}
class AkkaOSGiAssemblyProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) {
// FIXME: Find out how to replace mvn-assembly within SBT
//override def packageAction = task {
//FileUtilities.copy(info.dependencies.map(_.outputPath), "XXX", true, true, log)
//None
//} dependsOn(compile) describedAs("Creates the OSGi distribution.")
}
class AkkaOSGiParentProject(info: ProjectInfo) extends ParentProject(info) {
lazy val akka_osgi_bundle = project("akka-osgi-bundle", "akka-osgi-bundle",
new AkkaOSGiBundleProject(_), akka_kernel)
lazy val akka_osgi_assembly = project("akka-osgi-assembly", "akka-osgi-assembly",
new AkkaOSGiAssemblyProject(_), akka_osgi_bundle)
}
// ================= TEST ================== // ================= TEST ==================
class AkkaFunTestProject(info: ProjectInfo) extends DefaultProject(info) { class AkkaFunTestProject(info: ProjectInfo) extends DefaultProject(info) {
val jackson_core_asl = "org.codehaus.jackson" % "jackson-core-asl" % "1.2.1" % "compile" val jackson_core_asl = "org.codehaus.jackson" % "jackson-core-asl" % "1.2.1" % "compile"

View file

@ -5,4 +5,6 @@ class Plugins(info: ProjectInfo) extends PluginDefinition(info) {
val spdeSbt = "us.technically.spde" % "spde-sbt-plugin" % "0.4.1" val spdeSbt = "us.technically.spde" % "spde-sbt-plugin" % "0.4.1"
// val repo = "GH-pages repo" at "http://mpeltonen.github.com/maven/" // val repo = "GH-pages repo" at "http://mpeltonen.github.com/maven/"
// val idea = "com.github.mpeltonen" % "sbt-idea-plugin" % "0.1-SNAPSHOT" // val idea = "com.github.mpeltonen" % "sbt-idea-plugin" % "0.1-SNAPSHOT"
lazy val bnd4sbt = "com.weiglewilczek" % "bnd4sbt" % "0.4"
} }