homebrew-core/Formula/openjdk.rb

80 lines
2.8 KiB
Ruby

class Openjdk < Formula
desc "Development kit for the Java programming language"
homepage "https://openjdk.java.net/"
url "https://hg.openjdk.java.net/jdk-updates/jdk14u/archive/jdk-14.0.1-ga.tar.bz2"
sha256 "f9c4a55ac858f858222bc5fe6e4b890f9b4a3f942fd0211575b0418aec5c14d6"
bottle do
cellar :any
sha256 "d44db8c5b212a36d73f1102468106124e5f5e2f20600768a9d8cecc172df4601" => :catalina
sha256 "4549644dc93f35362c65fe12543bd77d580944673d836f71108f4bcaabf7c206" => :mojave
sha256 "b72286cb7187fa0682761f70ea5e6f6922667ceac4de4ac3ebd855786358c773" => :high_sierra
end
keg_only "it shadows the macOS `java` wrapper"
depends_on "autoconf" => :build
on_linux do
depends_on "pkg-config" => :build
end
# From https://jdk.java.net/archive/
resource "boot-jdk" do
url "https://download.java.net/java/GA/jdk13.0.2/d4173c853231432d94f001e99d882ca7/8/GPL/openjdk-13.0.2_osx-x64_bin.tar.gz"
sha256 "08fd2db3a3ab6fb82bb9091a035f9ffe8ae56c31725f4e17d573e48c39ca10dd"
end
def install
boot_jdk_dir = Pathname.pwd/"boot-jdk"
resource("boot-jdk").stage boot_jdk_dir
boot_jdk = boot_jdk_dir/"Contents/Home"
java_options = ENV.delete("_JAVA_OPTIONS")
_, _, build = version.to_s.rpartition("+")
chmod 0755, "configure"
system "./configure", "--without-version-pre",
"--without-version-opt",
"--with-version-build=#{build}",
"--with-toolchain-path=/usr/bin",
"--with-extra-ldflags=-headerpad_max_install_names",
"--with-boot-jdk=#{boot_jdk}",
"--with-boot-jdk-jvmargs=#{java_options}",
"--with-debug-level=release",
"--with-native-debug-symbols=none",
"--enable-dtrace=auto",
"--with-jvm-variants=server"
ENV["MAKEFLAGS"] = "JOBS=#{ENV.make_jobs}"
system "make", "images"
jdk = Dir["build/*/images/jdk-bundle/*"].first
libexec.install jdk => "openjdk.jdk"
bin.install_symlink Dir["#{libexec}/openjdk.jdk/Contents/Home/bin/*"]
include.install_symlink Dir["#{libexec}/openjdk.jdk/Contents/Home/include/*.h"]
include.install_symlink Dir["#{libexec}/openjdk.jdk/Contents/Home/include/darwin/*.h"]
end
def caveats
<<~EOS
For the system Java wrappers to find this JDK, symlink it with
sudo ln -sfn #{opt_libexec}/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
EOS
end
test do
(testpath/"HelloWorld.java").write <<~EOS
class HelloWorld {
public static void main(String args[]) {
System.out.println("Hello, world!");
}
}
EOS
system bin/"javac", "HelloWorld.java"
assert_match "Hello, world!", shell_output("#{bin}/java HelloWorld")
end
end