147 lines
4.8 KiB
Ruby
147 lines
4.8 KiB
Ruby
class Openjdk < Formula
|
|
desc "Development kit for the Java programming language"
|
|
homepage "https://openjdk.java.net/"
|
|
url "https://github.com/openjdk/jdk18u/archive/jdk-18.0.1-ga.tar.gz"
|
|
sha256 "4728da4676601af35c6ad998f2283e595ca9ce9b8528a75d74fddf7d03932d71"
|
|
license "GPL-2.0-only" => { with: "Classpath-exception-2.0" }
|
|
|
|
livecheck do
|
|
url :stable
|
|
regex(/^jdk[._-]v?(\d+(?:\.\d+)*)-ga$/i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any, arm64_monterey: "61e9244f1f8f8c0c2139e1df26b9895f5508e3e7538952459b590f8bff50627f"
|
|
sha256 cellar: :any, arm64_big_sur: "99fda507db67f88e289d8275ff7c37e63481c6f837a2c2c084cac1faf6e8fb2b"
|
|
sha256 cellar: :any, monterey: "acb7d100bd61aa51fd0014339897dc8b6405f5c62adf8551cbffe28c1ce6aac7"
|
|
sha256 cellar: :any, big_sur: "a70f028a2ad1233792eb1fd800ab0ed25d06a4d9f29250dbb1a2527685cd4ce6"
|
|
sha256 cellar: :any, catalina: "e91872c557d4697ef33743dd3d161eca51c18f7dfff2c88d042ebc3d4e03e09b"
|
|
sha256 x86_64_linux: "1723a239e00f76755947ff254e9ecf7b6416d49eb7690c1c9dc05a68dae09fe9"
|
|
end
|
|
|
|
keg_only :shadowed_by_macos
|
|
|
|
depends_on "autoconf" => :build
|
|
depends_on xcode: :build
|
|
depends_on macos: :catalina
|
|
|
|
on_linux do
|
|
depends_on "pkg-config" => :build
|
|
depends_on "alsa-lib"
|
|
depends_on "cups"
|
|
depends_on "fontconfig"
|
|
depends_on "gcc"
|
|
depends_on "libx11"
|
|
depends_on "libxext"
|
|
depends_on "libxrandr"
|
|
depends_on "libxrender"
|
|
depends_on "libxt"
|
|
depends_on "libxtst"
|
|
depends_on "unzip"
|
|
depends_on "zip"
|
|
|
|
ignore_missing_libraries "libjvm.so"
|
|
end
|
|
|
|
fails_with gcc: "5"
|
|
|
|
# From https://jdk.java.net/archive/
|
|
resource "boot-jdk" do
|
|
on_macos do
|
|
if Hardware::CPU.arm?
|
|
url "https://download.java.net/java/GA/jdk17.0.2/dfd4a8d0985749f896bed50d7138ee7f/8/GPL/openjdk-17.0.2_macos-aarch64_bin.tar.gz"
|
|
sha256 "602d7de72526368bb3f80d95c4427696ea639d2e0cc40455f53ff0bbb18c27c8"
|
|
else
|
|
url "https://download.java.net/java/GA/jdk17.0.2/dfd4a8d0985749f896bed50d7138ee7f/8/GPL/openjdk-17.0.2_macos-x64_bin.tar.gz"
|
|
sha256 "b85c4aaf7b141825ad3a0ea34b965e45c15d5963677e9b27235aa05f65c6df06"
|
|
end
|
|
end
|
|
on_linux do
|
|
url "https://download.java.net/java/GA/jdk17.0.2/dfd4a8d0985749f896bed50d7138ee7f/8/GPL/openjdk-17.0.2_linux-x64_bin.tar.gz"
|
|
sha256 "0022753d0cceecacdd3a795dd4cea2bd7ffdf9dc06e22ffd1be98411742fbb44"
|
|
end
|
|
end
|
|
|
|
def install
|
|
boot_jdk = Pathname.pwd/"boot-jdk"
|
|
resource("boot-jdk").stage boot_jdk
|
|
boot_jdk /= "Contents/Home" if OS.mac?
|
|
java_options = ENV.delete("_JAVA_OPTIONS")
|
|
|
|
args = %W[
|
|
--disable-warnings-as-errors
|
|
--with-boot-jdk-jvmargs=#{java_options}
|
|
--with-boot-jdk=#{boot_jdk}
|
|
--with-debug-level=release
|
|
--with-jvm-variants=server
|
|
--with-native-debug-symbols=none
|
|
--with-vendor-bug-url=#{tap.issues_url}
|
|
--with-vendor-name=#{tap.user}
|
|
--with-vendor-url=#{tap.issues_url}
|
|
--with-vendor-version-string=#{tap.user}
|
|
--with-vendor-vm-bug-url=#{tap.issues_url}
|
|
--with-version-build=#{revision}
|
|
--without-version-opt
|
|
--without-version-pre
|
|
]
|
|
|
|
args += if OS.mac?
|
|
%W[
|
|
--enable-dtrace
|
|
--with-extra-ldflags=-headerpad_max_install_names
|
|
--with-sysroot=#{MacOS.sdk_path}
|
|
]
|
|
else
|
|
%W[
|
|
--with-x=#{HOMEBREW_PREFIX}
|
|
--with-cups=#{HOMEBREW_PREFIX}
|
|
--with-fontconfig=#{HOMEBREW_PREFIX}
|
|
]
|
|
end
|
|
|
|
chmod 0755, "configure"
|
|
system "./configure", *args
|
|
|
|
ENV["MAKEFLAGS"] = "JOBS=#{ENV.make_jobs}"
|
|
system "make", "images"
|
|
|
|
if OS.mac?
|
|
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"]
|
|
man1.install_symlink Dir[libexec/"openjdk.jdk/Contents/Home/man/man1/*"]
|
|
else
|
|
libexec.install Dir["build/linux-x86_64-server-release/images/jdk/*"]
|
|
bin.install_symlink Dir[libexec/"bin/*"]
|
|
include.install_symlink Dir[libexec/"include/*.h"]
|
|
include.install_symlink Dir[libexec/"include/linux/*.h"]
|
|
man1.install_symlink Dir[libexec/"man/man1/*"]
|
|
end
|
|
end
|
|
|
|
def caveats
|
|
on_macos do
|
|
<<~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
|
|
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
|