forked from sjackman/linuxbrew-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
akka.rb
108 lines (88 loc) · 3.18 KB
/
akka.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
class Akka < Formula
desc "Toolkit for building concurrent, distributed, and fault tolerant apps"
homepage "https://github.com/akka/akka"
url "https://downloads.typesafe.com/akka/akka_2.11-2.4.20.zip"
sha256 "6f6af368672640512f8e0099a5d88277f4ac64de7d4edd151411e6a80cc78d0f"
license "Apache-2.0"
revision 1
livecheck do
url "https://github.com/akka/akka/releases/latest"
regex(%r{href=.*?/tag/v?(\d+(?:\.\d+)+)["' >]}i)
end
bottle :unneeded
# https://github.com/akka/akka/issues/25046
deprecate! because: "is recommended to use Akka with a build tool"
depends_on "openjdk"
def install
# Remove Windows files
rm "bin/akka.bat"
chmod 0755, "bin/akka"
chmod 0755, "bin/akka-cluster"
inreplace ["bin/akka", "bin/akka-cluster"] do |s|
# Translate akka script
s.gsub! /^declare AKKA_HOME=.*$/, "declare AKKA_HOME=#{libexec}"
# dos to unix (bug fix for version 2.3.11)
s.gsub! /\r?/, ""
end
libexec.install Dir["*"]
bin.install Dir["#{libexec}/bin/*"]
bin.env_script_all_files libexec/"bin", JAVA_HOME: Formula["openjdk"].opt_prefix
end
test do
(testpath/"src/main/java/sample/hello/HelloWorld.java").write <<~EOS
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
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
package sample.hello;
public class Main {
public static void main(String[] args) {
akka.Main.main(new String[] { HelloWorld.class.getName() });
}
}
EOS
system "#{Formula["openjdk"].bin}/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 "#{Formula["openjdk"].bin}/java",
"-classpath", (Dir[libexec/"lib/**/*.jar"] + [testpath/"src/main/java"]).join(":"),
"akka.Main", "sample.hello.HelloWorld"
end
end