homebrew-core/Formula/openjdk@17.rb

145 lines
4.8 KiB
Ruby

class OpenjdkAT17 < Formula
desc "Development kit for the Java programming language"
homepage "https://openjdk.java.net/"
url "https://github.com/openjdk/jdk17u/archive/jdk-17.0.3-ga.tar.gz"
sha256 "9a23da36c4e8f26a7197c6e6b763c7be83bc8788f495ae9dadfabadf8c7d57c2"
license "GPL-2.0-only" => { with: "Classpath-exception-2.0" }
livecheck do
url :stable
regex(/^jdk[._-]v?(17(?:\.\d+)*)-ga$/i)
end
bottle do
sha256 cellar: :any, arm64_monterey: "a0f5189a1719c2d6530ee79eb018470e9e86321c745ed73c5e15c8465df0c24d"
sha256 cellar: :any, arm64_big_sur: "caf9fc1ab57cbe96155d11cc4c5076fa05204058c41dab9bee6e79d79aa27192"
sha256 cellar: :any, monterey: "b7cf051662b5d6a7839e6d65010adff4a0c980fa03b56447090996d6052aa569"
sha256 cellar: :any, big_sur: "c47a05de36d684b0b893fb096bc1adfee80b47b47eda4e08204fab0151abe746"
sha256 cellar: :any, catalina: "49bd4a42120737354c356f2ce35c5b65937fdf8970815693b0268c367f5e5de8"
sha256 x86_64_linux: "1c4ff0b196cbe8daa32e0e73d47b5424572a2f641708ae91a9f6fcc8dbb05568"
end
keg_only :versioned_formula
depends_on "autoconf" => :build
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.1/2a2082e5a09d4267845be086888add4f/12/GPL/openjdk-17.0.1_macos-aarch64_bin.tar.gz"
sha256 "45acad5647960ecde83dc1fb6dda72e5e274798660fa9acff0fb9cc8a37b5794"
else
url "https://download.java.net/java/GA/jdk16.0.2/d4a915d82b4c4fbb9bde534da945d746/7/GPL/openjdk-16.0.2_osx-x64_bin.tar.gz"
sha256 "e65f2437585f16a01fa8e10139d0d855e8a74396a1dfb0163294ed17edd704b8"
end
end
on_linux do
url "https://download.java.net/java/GA/jdk16.0.2/d4a915d82b4c4fbb9bde534da945d746/7/GPL/openjdk-16.0.2_linux-x64_bin.tar.gz"
sha256 "6c714ded7d881ca54970ec949e283f43d673a142fda1de79b646ddd619da9c0c"
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-17.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