Skip to content

Commit

Permalink
Merge pull request Homebrew#197126 from Homebrew/java-heredocs
Browse files Browse the repository at this point in the history
Use Java language-specific heredoc delimiters
  • Loading branch information
chenrui333 authored Nov 8, 2024
2 parents 8e38927 + 3cd445a commit 6f41c70
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 38 deletions.
8 changes: 4 additions & 4 deletions Formula/a/aspectj.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ def install
end

test do
(testpath/"Test.java").write <<~EOS
(testpath/"Test.java").write <<~JAVA
public class Test {
public static void main (String[] args) {
System.out.println("Brew Test");
}
}
EOS
(testpath/"TestAspect.aj").write <<~EOS
JAVA
(testpath/"TestAspect.aj").write <<~JAVA
public aspect TestAspect {
private pointcut mainMethod () :
execution(public static void main(String[]));
Expand All @@ -54,7 +54,7 @@ def install
System.out.print("Aspect ");
}
}
EOS
JAVA
ENV["CLASSPATH"] = "#{libexec}/#{name}/lib/aspectjrt.jar:test.jar:testaspect.jar"
system bin/"ajc", "-outjar", "test.jar", "Test.java"
system bin/"ajc", "-outjar", "testaspect.jar", "-outxml", "TestAspect.aj"
Expand Down
4 changes: 2 additions & 2 deletions Formula/b/bazel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ def install
test do
touch testpath/"WORKSPACE"

(testpath/"ProjectRunner.java").write <<~EOS
(testpath/"ProjectRunner.java").write <<~JAVA
public class ProjectRunner {
public static void main(String args[]) {
System.out.println("Hi!");
}
}
EOS
JAVA

(testpath/"BUILD").write <<~EOS
java_binary(
Expand Down
8 changes: 4 additions & 4 deletions Formula/b/byteman.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ def install
end

test do
(testpath/"src/main/java/BytemanHello.java").write <<~EOS
(testpath/"src/main/java/BytemanHello.java").write <<~JAVA
class BytemanHello {
public static void main(String... args) {
System.out.println("Hello, Brew!");
}
}
EOS
JAVA

(testpath/"brew.btm").write <<~EOS
(testpath/"brew.btm").write <<~BTM
RULE trace main entry
CLASS BytemanHello
METHOD main
Expand All @@ -57,7 +57,7 @@ class BytemanHello {
IF true
DO traceln("Exiting main")
ENDRULE
EOS
BTM

system "#{Formula["openjdk"].bin}/javac", "src/main/java/BytemanHello.java"

Expand Down
20 changes: 10 additions & 10 deletions Formula/c/csound.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def caveats
end

test do
(testpath/"test.orc").write <<~EOS
(testpath/"test.orc").write <<~ORC
0dbfs = 1
gi_peer link_create
gi_programHandle faustcompile "process = _;", "--vectorize --loop-variant 1"
Expand All @@ -218,12 +218,12 @@ def caveats
mp3out a_signal, a_signal, "test.mp3"
out a_signal
endin
EOS
ORC

(testpath/"test.sco").write <<~EOS
(testpath/"test.sco").write <<~SCO
i 1 0 1
e
EOS
SCO

if OS.mac?
ENV["OPCODE6DIR64"] = frameworks/"CsoundLib64.framework/Resources/Opcodes64"
Expand All @@ -240,34 +240,34 @@ def caveats
assert_predicate testpath/"test.h5", :exist?
assert_predicate testpath/"test.mp3", :exist?

(testpath/"opcode-existence.orc").write <<~EOS
(testpath/"opcode-existence.orc").write <<~ORC
JackoInfo
instr 1
i_ websocket 8888, 0
i_ wiiconnect 1, 1
endin
EOS
ORC
system bin/"csound", "--orc", "--syntax-check-only", "opcode-existence.orc"

if OS.mac?
(testpath/"mac-opcode-existence.orc").write <<~EOS
(testpath/"mac-opcode-existence.orc").write <<~ORC
instr 1
p5gconnect
endin
EOS
ORC
system bin/"csound", "--orc", "--syntax-check-only", "mac-opcode-existence.orc"
end

system python3, "-c", "import ctcsound"

(testpath/"test.java").write <<~EOS
(testpath/"test.java").write <<~JAVA
import csnd6.*;
public class test {
public static void main(String args[]) {
csnd6.csoundInitialize(csnd6.CSOUNDINIT_NO_ATEXIT | csnd6.CSOUNDINIT_NO_SIGNAL_HANDLER);
}
}
EOS
JAVA
system Formula["openjdk"].bin/"javac", "-classpath", "#{libexec}/csnd6.jar", "test.java"
system Formula["openjdk"].bin/"java", "-classpath", "#{libexec}/csnd6.jar:.",
"-Djava.library.path=#{libexec}", "test"
Expand Down
4 changes: 2 additions & 2 deletions Formula/o/openj9.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,13 @@ def caveats
end

test do
(testpath/"HelloWorld.java").write <<~EOS
(testpath/"HelloWorld.java").write <<~JAVA
class HelloWorld {
public static void main(String args[]) {
System.out.println("Hello, world!");
}
}
EOS
JAVA

system bin/"javac", "HelloWorld.java"

Expand Down
4 changes: 2 additions & 2 deletions Formula/o/openjdk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,13 @@ def caveats
end

test do
(testpath/"HelloWorld.java").write <<~EOS
(testpath/"HelloWorld.java").write <<~JAVA
class HelloWorld {
public static void main(String args[]) {
System.out.println("Hello, world!");
}
}
EOS
JAVA

system bin/"javac", "HelloWorld.java"

Expand Down
4 changes: 2 additions & 2 deletions Formula/o/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,13 @@ def caveats
end

test do
(testpath/"HelloWorld.java").write <<~EOS
(testpath/"HelloWorld.java").write <<~JAVA
class HelloWorld {
public static void main(String args[]) {
System.out.println("Hello, world!");
}
}
EOS
JAVA

system bin/"javac", "HelloWorld.java"

Expand Down
4 changes: 2 additions & 2 deletions Formula/o/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,13 @@ def caveats
end

test do
(testpath/"HelloWorld.java").write <<~EOS
(testpath/"HelloWorld.java").write <<~JAVA
class HelloWorld {
public static void main(String args[]) {
System.out.println("Hello, world!");
}
}
EOS
JAVA

system bin/"javac", "HelloWorld.java"

Expand Down
4 changes: 2 additions & 2 deletions Formula/o/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ def caveats
end

test do
(testpath/"HelloWorld.java").write <<~EOS
(testpath/"HelloWorld.java").write <<~JAVA
class HelloWorld {
public static void main(String args[]) {
System.out.println("Hello, world!");
}
}
EOS
JAVA

system bin/"javac", "HelloWorld.java"

Expand Down
4 changes: 2 additions & 2 deletions Formula/o/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,13 @@ def caveats
end

test do
(testpath/"HelloWorld.java").write <<~EOS
(testpath/"HelloWorld.java").write <<~JAVA
class HelloWorld {
public static void main(String args[]) {
System.out.println("Hello, world!");
}
}
EOS
JAVA

system bin/"javac", "HelloWorld.java"

Expand Down
4 changes: 2 additions & 2 deletions Formula/p/pmd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def install
end

test do
(testpath/"java/testClass.java").write <<~EOS
(testpath/"java/testClass.java").write <<~JAVA
public class BrewTestClass {
// dummy constant
public String SOME_CONST = "foo";
Expand All @@ -27,7 +27,7 @@ def install
return true;
}
}
EOS
JAVA

output = shell_output("#{bin}/pmd check -d #{testpath}/java " \
"-R category/java/bestpractices.xml -f json")
Expand Down
4 changes: 2 additions & 2 deletions Formula/s/spotbugs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def install
end

test do
(testpath/"HelloWorld.java").write <<~EOS
(testpath/"HelloWorld.java").write <<~JAVA
public class HelloWorld {
private double[] myList;
public static void main(String[] args) {
Expand All @@ -55,7 +55,7 @@ def install
return myList;
}
}
EOS
JAVA
system Formula["openjdk"].bin/"javac", "HelloWorld.java"
system Formula["openjdk"].bin/"jar", "cvfe", "HelloWorld.jar", "HelloWorld", "HelloWorld.class"
output = shell_output("#{bin}/spotbugs -textui HelloWorld.jar")
Expand Down
4 changes: 2 additions & 2 deletions Formula/v/vert.x.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def install
end

test do
(testpath/"HelloWorld.java").write <<~EOS
(testpath/"HelloWorld.java").write <<~JAVA
import io.vertx.core.AbstractVerticle;
public class HelloWorld extends AbstractVerticle {
public void start() {
Expand All @@ -33,7 +33,7 @@ def install
System.exit(0);
}
}
EOS
JAVA
output = shell_output("#{bin}/vertx run HelloWorld.java")
assert_equal "Hello World!\n", output
end
Expand Down

0 comments on commit 6f41c70

Please sign in to comment.