2012-05-03 22:16:33 +00:00
|
|
|
class Akka < Formula
|
2015-05-19 00:00:59 +00:00
|
|
|
desc "Toolkit for building concurrent, distributed, and fault tolerant apps"
|
2014-11-03 01:25:15 +00:00
|
|
|
homepage "http://akka.io/"
|
2016-09-24 21:35:29 +00:00
|
|
|
url "https://downloads.typesafe.com/akka/akka_2.11-2.4.10.zip"
|
|
|
|
sha256 "2410405a11a943444cf1f574f74722b5cbabf4c9fcf8672eb7880c13dab972d8"
|
2012-05-03 22:16:33 +00:00
|
|
|
|
2015-10-22 12:45:37 +00:00
|
|
|
bottle :unneeded
|
|
|
|
|
2016-05-03 02:11:40 +00:00
|
|
|
depends_on :java
|
|
|
|
|
2012-05-03 22:16:33 +00:00
|
|
|
def install
|
|
|
|
# Remove Windows files
|
|
|
|
rm "bin/akka.bat"
|
|
|
|
|
2015-04-10 15:10:50 +00:00
|
|
|
chmod 0755, "bin/akka"
|
|
|
|
chmod 0755, "bin/akka-cluster"
|
|
|
|
|
2015-05-20 21:02:47 +00:00
|
|
|
inreplace ["bin/akka", "bin/akka-cluster"] do |s|
|
2015-06-29 17:06:03 +00:00
|
|
|
# Translate akka script
|
2012-05-03 22:16:33 +00:00
|
|
|
s.gsub! /^declare AKKA_HOME=.*$/, "declare AKKA_HOME=#{libexec}"
|
2015-06-29 17:06:03 +00:00
|
|
|
# dos to unix (bug fix for version 2.3.11)
|
|
|
|
s.gsub! /\r?/, ""
|
2012-05-03 22:16:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
libexec.install Dir["*"]
|
|
|
|
bin.install_symlink libexec/"bin/akka"
|
2015-05-20 21:02:47 +00:00
|
|
|
bin.install_symlink libexec/"bin/akka-cluster"
|
2012-05-03 22:16:33 +00:00
|
|
|
end
|
2016-05-03 02:11:40 +00:00
|
|
|
|
|
|
|
test do
|
|
|
|
(testpath/"src/main/java/sample/hello/HelloWorld.java").write <<-EOS.undent
|
|
|
|
package sample.hello;
|
|
|
|
|
|
|
|
import akka.actor.Props;
|
|
|
|
import akka.actor.UntypedActor;
|
|
|
|
import akka.actor.ActorRef;
|
|
|
|
|
|
|
|
public class HelloWorld extends UntypedActor {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void preStart() {
|
|
|
|
// create the greeter actor
|
|
|
|
final ActorRef greeter = getContext().actorOf(Props.create(Greeter.class), "greeter");
|
|
|
|
// tell it to perform the greeting
|
|
|
|
greeter.tell(Greeter.Msg.GREET, getSelf());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onReceive(Object msg) {
|
|
|
|
if (msg == Greeter.Msg.DONE) {
|
|
|
|
// when the greeter is done, stop this actor and with it the application
|
|
|
|
getContext().stop(getSelf());
|
|
|
|
} else
|
|
|
|
unhandled(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EOS
|
|
|
|
(testpath/"src/main/java/sample/hello/Greeter.java").write <<-EOS.undent
|
|
|
|
package sample.hello;
|
|
|
|
|
|
|
|
import akka.actor.UntypedActor;
|
|
|
|
|
|
|
|
public class Greeter extends UntypedActor {
|
|
|
|
|
|
|
|
public static enum Msg {
|
|
|
|
GREET, DONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onReceive(Object msg) {
|
|
|
|
if (msg == Msg.GREET) {
|
|
|
|
System.out.println("Hello World!");
|
|
|
|
getSender().tell(Msg.DONE, getSelf());
|
|
|
|
} else
|
|
|
|
unhandled(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
EOS
|
|
|
|
(testpath/"src/main/java/sample/hello/Main.java").write <<-EOS.undent
|
|
|
|
package sample.hello;
|
|
|
|
|
|
|
|
public class Main {
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
akka.Main.main(new String[] { HelloWorld.class.getName() });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EOS
|
|
|
|
system "javac", "-classpath", Dir[libexec/"lib/**/*.jar"].join(":"),
|
|
|
|
testpath/"src/main/java/sample/hello/HelloWorld.java",
|
|
|
|
testpath/"src/main/java/sample/hello/Greeter.java",
|
|
|
|
testpath/"src/main/java/sample/hello/Main.java"
|
|
|
|
system "java",
|
|
|
|
"-classpath", (Dir[libexec/"lib/**/*.jar"] + [testpath/"src/main/java"]).join(":"),
|
|
|
|
"akka.Main", "sample.hello.HelloWorld"
|
|
|
|
end
|
2012-05-03 22:16:33 +00:00
|
|
|
end
|