144 lines
4.7 KiB
Ruby
144 lines
4.7 KiB
Ruby
class Openjdk < Formula
|
|
desc "Development kit for the Java programming language"
|
|
homepage "https://openjdk.java.net/"
|
|
url "https://github.com/openjdk/jdk17u/archive/jdk-17-ga.tar.gz"
|
|
sha256 "8971e4c3555fffae60bd58a5fb403e51a1e0dda14645c6214b81ceff954dd411"
|
|
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_big_sur: "5f1fcaf9ae3b8c8754d178c254ebbc968adcf598e6cbb7a07738c740b4124a3c"
|
|
sha256 cellar: :any, big_sur: "a5a37760a9ca28869fa56dfa23f692e14f184c3d0b989be1675fda37b3475747"
|
|
sha256 cellar: :any, catalina: "2438f3d3d2b0590be174654121126c9236328dc0b3a85c89ab7f28de96ae2863"
|
|
sha256 cellar: :any, mojave: "dbb4c5a7d6f6c465b88674417e5fd10ab807daeed7ce8f4617d66010d7c4deb4"
|
|
sha256 x86_64_linux: "d07e4b7c18216b24503672052de152d0713a405193ff9292fbbb3d13e13ccc70"
|
|
end
|
|
|
|
keg_only :shadowed_by_macos
|
|
|
|
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/0d483333a00540d886896bac774ff48b/35/GPL/openjdk-17_macos-aarch64_bin.tar.gz"
|
|
sha256 "b5bf6377aabdc935bd72b36c494e178b12186b0e1f4be50f35134daa33bda052"
|
|
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.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
|