homebrew-core/Formula/openjdk@11.rb

162 lines
5.2 KiB
Ruby

class OpenjdkAT11 < Formula
desc "Development kit for the Java programming language"
homepage "https://openjdk.java.net/"
url "https://github.com/openjdk/jdk11u/archive/refs/tags/jdk-11.0.17-ga.tar.gz"
sha256 "1d36043f2cecfe2b079ca288c66ad7f009c50c828f4eab989e1adaeee443367b"
license "GPL-2.0-only"
livecheck do
url :stable
regex(/^jdk[._-]v?(11(?:\.\d+)*)-ga$/i)
end
bottle do
sha256 cellar: :any, arm64_ventura: "65d8e7b7a4e6f86ea503be7583d662040db8b3808cad76db4c7165bec17fcefc"
sha256 cellar: :any, arm64_monterey: "8fde089f21fc5b44cec749335be1cbff63008c0b160ff44cce36a865ad22bcd8"
sha256 cellar: :any, arm64_big_sur: "cef244f475241213637c473bfca2057f0d73081edd9cee4c5e5a1a50d1df013b"
sha256 cellar: :any, ventura: "8082fbf61e89734ef6c97d27f9b79c523aac57e60cce48492307d7527626d94d"
sha256 cellar: :any, monterey: "a7dd4515b5a6c3215390a6fcf07a8809b88cca277ab1c3db190bf644eebce6fe"
sha256 cellar: :any, big_sur: "a129af42c5d12e807a111916faa1654ac2547510d68994327288a83976da727b"
sha256 cellar: :any_skip_relocation, x86_64_linux: "5c4cdc324c887be6e88483846a2368ada8c6a64f77045991d8c2bb535143e546"
end
keg_only :versioned_formula
depends_on "autoconf" => :build
depends_on "pkg-config" => :build
depends_on "giflib"
depends_on "harfbuzz"
depends_on "jpeg-turbo"
depends_on "libpng"
depends_on "little-cms2"
uses_from_macos "cups"
uses_from_macos "unzip"
uses_from_macos "zip"
uses_from_macos "zlib"
on_linux do
depends_on "alsa-lib"
depends_on "fontconfig"
depends_on "freetype"
depends_on "libx11"
depends_on "libxext"
depends_on "libxrandr"
depends_on "libxrender"
depends_on "libxt"
depends_on "libxtst"
end
resource "boot-jdk" do
on_macos do
on_arm do
url "https://cdn.azul.com/zulu/bin/zulu11.58.15-ca-jdk11.0.16-macosx_aarch64.tar.gz"
sha256 "cb71a8ad38755f881a692098ca02378183a7a9c5093d7e6ad98ca5e7bc74b937"
end
on_intel do
url "https://download.java.net/java/GA/jdk10/10.0.2/19aef61b38124481863b1413dce1855f/13/openjdk-10.0.2_osx-x64_bin.tar.gz"
sha256 "77ea7675ee29b85aa7df138014790f91047bfdafbc997cb41a1030a0417356d7"
end
end
# Bootstrapping with JDK 10 hit a java.util.ConcurrentModificationException so we use JDK 11
on_linux do
url "https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz"
sha256 "99be79935354f5c0df1ad293620ea36d13f48ec3ea870c838f20c504c9668b57"
end
end
def install
boot_jdk = buildpath/"boot-jdk"
resource("boot-jdk").stage boot_jdk
boot_jdk /= "Contents/Home" if OS.mac? && !Hardware::CPU.arm?
java_options = ENV.delete("_JAVA_OPTIONS")
args = %W[
--disable-hotspot-gtest
--disable-warnings-as-errors
--with-boot-jdk-jvmargs=#{java_options}
--with-boot-jdk=#{boot_jdk}
--with-debug-level=release
--with-conf-name=release
--with-jvm-variants=server
--with-jvm-features=shenandoahgc
--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}
--without-version-opt
--without-version-pre
--with-giflib=system
--with-harfbuzz=system
--with-lcms=system
--with-libjpeg=system
--with-libpng=system
--with-zlib=system
]
ldflags = ["-Wl,-rpath,#{loader_path.gsub("$", "\\$$")}/server"]
args += if OS.mac?
ldflags << "-headerpad_max_install_names"
%W[
--enable-dtrace
--with-sysroot=#{MacOS.sdk_path}
]
else
%W[
--with-x=#{HOMEBREW_PREFIX}
--with-cups=#{HOMEBREW_PREFIX}
--with-fontconfig=#{HOMEBREW_PREFIX}
--with-freetype=system
--with-stdc++lib=dynamic
]
end
args << "--with-extra-ldflags=#{ldflags.join(" ")}"
system "bash", "configure", *args
ENV["MAKEFLAGS"] = "JOBS=#{ENV.make_jobs}"
system "make", "images", "CONF=release"
cd "build/release/images" do
jdk = libexec
if OS.mac?
libexec.install Dir["jdk-bundle/*"].first => "openjdk.jdk"
jdk /= "openjdk.jdk/Contents/Home"
else
libexec.install Dir["jdk/*"]
end
bin.install_symlink Dir[jdk/"bin/*"]
include.install_symlink Dir[jdk/"include/*.h"]
include.install_symlink Dir[jdk/"include/*/*.h"]
man1.install_symlink Dir[jdk/"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-11.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