Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openjdk 16 #72535

Closed
wants to merge 13 commits into from
File renamed without changes.
6 changes: 4 additions & 2 deletions Formula/commandbox.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Commandbox < Formula
url "https://downloads.ortussolutions.com/ortussolutions/commandbox/5.3.1/commandbox-bin-5.3.1.zip"
sha256 "f0e1f3b989a8664c3f7d0f02362ae8b0f3ab0ecd2b923b3ceeb89a4cf46cb614"
license "LGPL-3.0-or-later"
revision 1

livecheck do
url :homepage
Expand All @@ -14,7 +15,8 @@ class Commandbox < Formula
sha256 cellar: :any_skip_relocation, all: "7ab51feadd7ba7c1525c98a0d7a96d010a374cc1ea69b7989cb033115a1316eb"
end

depends_on "openjdk"
# not yet compatible with Java 17 on ARM
depends_on "openjdk@11"

resource "apidocs" do
url "https://downloads.ortussolutions.com/ortussolutions/commandbox/5.3.1/commandbox-apidocs-5.3.1.zip"
Expand All @@ -23,7 +25,7 @@ class Commandbox < Formula

def install
(libexec/"bin").install "box"
(bin/"box").write_env_script libexec/"bin/box", Language::Java.overridable_java_home_env
(bin/"box").write_env_script libexec/"bin/box", Language::Java.overridable_java_home_env("11")
doc.install resource("apidocs")
end

Expand Down
2 changes: 1 addition & 1 deletion Formula/dafny.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Dafny < Formula
depends_on "gradle" => :build
depends_on "nuget" => :build
depends_on "dotnet"
depends_on "openjdk"
depends_on "openjdk@11"

# Use the following along with the z3 build below, as long as dafny
# cannot build with latest z3 (https://github.com/dafny-lang/dafny/issues/810)
Expand Down
5 changes: 3 additions & 2 deletions Formula/detekt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Detekt < Formula
url "https://github.com/detekt/detekt/releases/download/v1.17.1/detekt-cli-1.17.1-all.jar"
sha256 "2a01bc4fe9836d08a683be268887ecd88b6f76b8832078fb153feaf126f91678"
license "Apache-2.0"
revision 1

livecheck do
url :homepage
Expand All @@ -12,11 +13,11 @@ class Detekt < Formula

bottle :unneeded

depends_on "openjdk"
depends_on "openjdk@11"

def install
libexec.install "detekt-cli-#{version}-all.jar"
bin.write_jar_script libexec/"detekt-cli-#{version}-all.jar", "detekt"
bin.write_jar_script libexec/"detekt-cli-#{version}-all.jar", "detekt", java_version: "11"
end

test do
Expand Down
7 changes: 6 additions & 1 deletion Formula/google-java-format.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ class GoogleJavaFormat < Formula

def install
libexec.install "google-java-format-#{version}-all-deps.jar" => "google-java-format.jar"
bin.write_jar_script libexec / "google-java-format.jar", "google-java-format"
bin.write_jar_script libexec / "google-java-format.jar", "google-java-format",
"--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"
end

test do
Expand Down
6 changes: 4 additions & 2 deletions Formula/ki.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Ki < Formula
url "https://github.com/Kotlin/kotlin-interactive-shell/archive/refs/tags/v0.3.3.tar.gz"
sha256 "46913b17c85711213251948342d0f4d0fec7dc98dd11c1f24eedb0409338e273"
license "Apache-2.0"
revision 1
head "https://github.com/Kotlin/kotlin-interactive-shell.git", branch: "main"

bottle do
Expand All @@ -14,12 +15,13 @@ class Ki < Formula
end

depends_on "maven" => :build
depends_on "openjdk"
depends_on "openjdk@11"

def install
ENV["JAVA_HOME"] = Formula["openjdk@11"].opt_prefix
system "mvn", "-DskipTests", "package"
libexec.install "lib/ki-shell.jar"
bin.write_jar_script libexec/"ki-shell.jar", "ki"
bin.write_jar_script libexec/"ki-shell.jar", "ki", java_version: "11"
end

test do
Expand Down
5 changes: 3 additions & 2 deletions Formula/ktlint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ class Ktlint < Formula
url "https://github.com/pinterest/ktlint/releases/download/0.41.0/ktlint"
sha256 "438bd098e5e8acc966940480b025af7020bdaa66698c7d76042416314100e183"
license "MIT"
revision 1

bottle do
sha256 cellar: :any_skip_relocation, all: "3e579a1c6a074922e7280071c9cbd87f1604d645b8a1b694b9ecc95739e95111"
end

depends_on "openjdk"
depends_on "openjdk@11"

def install
libexec.install "ktlint"
(libexec/"ktlint").chmod 0755
(bin/"ktlint").write_env_script libexec/"ktlint", JAVA_HOME: Formula["openjdk"].opt_prefix
(bin/"ktlint").write_env_script libexec/"ktlint", JAVA_HOME: Formula["openjdk@11"].opt_prefix
end

test do
Expand Down
4 changes: 2 additions & 2 deletions Formula/micronaut.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class Micronaut < Formula
desc "Modern JVM-based framework for building modular microservices"
homepage "https://micronaut.io/"
url "https://github.com/micronaut-projects/micronaut-starter/archive/v2.4.4.tar.gz"
sha256 "92be3f5d0e05e810221ef0d123f4e227900487636b9ea31198964bbf3ddd853f"
url "https://github.com/micronaut-projects/micronaut-starter/archive/v2.5.4.tar.gz"
sha256 "2f044087a676ee9c00a7d19a9facf5d968befdfbd6e1d322a19f711ce0279439"
license "Apache-2.0"

livecheck do
Expand Down
180 changes: 92 additions & 88 deletions Formula/openjdk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@ class Openjdk < Formula
desc "Development kit for the Java programming language"
homepage "https://openjdk.java.net/"
if Hardware::CPU.arm?
# Temporarily use a openjdk 16 preview on Apple Silicon
# Temporarily use a openjdk 17 preview on Apple Silicon
# (because it is better than nothing)
url "https://github.com/openjdk/jdk-sandbox/archive/a56ddad05cf1808342aeff1b1cd2b0568a6cdc3a.tar.gz"
sha256 "29df31b5eefb5a6c016f50b2518ca29e8e61e3cfc676ed403214e1f13a78efd5"
version "15.0.2"
url "https://github.com/openjdk/jdk/archive/refs/tags/jdk-17+24.tar.gz"
sha256 "9d1ea3fc63ce860e55a9be77f670b18fa7b7e5c9773dca3c70042403e1ee285c"
version "16.0.1"
else
url "https://hg.openjdk.java.net/jdk-updates/jdk15u/archive/jdk-15.0.2-ga.tar.bz2"
sha256 "d07b45b5b319e7034e8ebc41cd78c496e6ee8b1f6e08310dee303beaee8b4a3a"
url "https://github.com/openjdk/jdk16u/archive/refs/tags/jdk-16.0.1-ga.tar.gz"
sha256 "ef53ef8796080a955efbfdbf05ea137ff95ac6d444dab3b2fcd57c9709a3b65d"
end
license :cannot_represent
license "GPL-2.0-only" => { with: "Classpath-exception-2.0" }

livecheck do
url "https://hg.openjdk.java.net/jdk-updates/jdk#{version.major}u/tags"
url "https://github.com/openjdk/jdk#{version.major}u/releases"
strategy :page_match
regex(/>\s*?jdk[._-]v?(\d+(?:\.\d+)*)-ga\s*?</i)
end

Expand All @@ -33,87 +34,90 @@ class Openjdk < Formula
on_linux do
depends_on "pkg-config" => :build
depends_on "alsa-lib"
depends_on "cups"
depends_on "fontconfig"
depends_on "libx11"
depends_on "libxext"
depends_on "libxrandr"
depends_on "libxrender"
depends_on "libxt"
depends_on "libxtst"
depends_on "unzip"
depends_on "zip"
end

# From https://jdk.java.net/archive/
resource "boot-jdk" do
on_macos do
if Hardware::CPU.arm?
url "https://download.java.net/java/early_access/jdk16/31/GPL/openjdk-16-ea+31_osx-x64_bin.tar.gz"
sha256 "8e4a8fdd2d965067bdb56e1a72c7c72343d571b371ac61eee74d9e71bbef63e8"
url "https://download.java.net/java/early_access/jdk17/24/GPL/openjdk-17-ea+24_macos-aarch64_bin.tar.gz"
sha256 "176ab64ad860e363428ce3e4b23e8207576f8a65a567761475281cda25887640"
else
url "https://download.java.net/java/GA/jdk14.0.2/205943a0976c4ed48cb16f1043c5c647/12/GPL/openjdk-14.0.2_osx-x64_bin.tar.gz"
sha256 "386a96eeef63bf94b450809d69ceaa1c9e32a97230e0a120c1b41786b743ae84"
url "https://download.java.net/java/GA/jdk15.0.2/0d1cfde4252546c6931946de8db48ee2/7/GPL/openjdk-15.0.2_osx-x64_bin.tar.gz"
sha256 "578b17748f5a7d111474bc4c9b5a8a06b4a4aa1ba4a4bc3fef014e079ece7c74"
end
end
on_linux do
url "https://download.java.net/java/GA/jdk14.0.2/205943a0976c4ed48cb16f1043c5c647/12/GPL/openjdk-14.0.2_linux-x64_bin.tar.gz"
sha256 "91310200f072045dc6cef2c8c23e7e6387b37c46e9de49623ce0fa461a24623d"
url "https://download.java.net/java/GA/jdk15.0.2/0d1cfde4252546c6931946de8db48ee2/7/GPL/openjdk-15.0.2_linux-x64_bin.tar.gz"
sha256 "91ac6fc353b6bf39d995572b700e37a20e119a87034eeb939a6f24356fbcd207"
end
end

def install
# Path to dual-arch JavaNativeFoundation.framework from Xcode
framework_path = File.expand_path(
"../SharedFrameworks/ContentDeliveryServices.framework/Versions/Current/itms/java/Frameworks",
MacOS::Xcode.prefix,
)

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")

# Inspecting .hgtags to find a build number
# The file looks like this:
#
# 1613004c47e9dc867a2c2c43d716533b1aaedc5f jdk-15.0.2+0
# cc4fdb537bc14734064a9a8eadb091fd1c12b36e jdk-15.0.2+1
# d24e907486b3f90691980b0dde01efca5840abc6 jdk-15.0.2+2
# dbb11e11955ad1240ba775ab0007a14547e14ce6 jdk-15.0.2+3
# 4c4a2eb7b19ecb31620e6bb120e40f8a5fd1737a jdk-15.0.2+4
# e431a9461b1356c4b763443e5333b3f4a8695eaf jdk-15.0.2+5
# d5977ee56509ceaa3d3c8e1aebbca76651358da4 jdk-15.0.2+6
# 38912b2a5bcb396c75f8707e300773c874327451 jdk-15.0.2+7
#
# Since openjdk has move their development from mercurial to git and GitHub
# this approach may need some changes in the future
#
version_to_parse = if Hardware::CPU.arm?
"16"
else
version
boot_jdk = Pathname.pwd/"boot-jdk"
resource("boot-jdk").stage boot_jdk
on_macos do
boot_jdk /= "Contents/Home"
end
build = File.read(".hgtags")
.scan(/ jdk-#{version_to_parse}\+(.+)$/)
.map(&:first)
.map(&:to_i)
.max
raise "cannot find build number in .hgtags" if build.nil?
java_options = ENV.delete("_JAVA_OPTIONS")

args = %W[
--without-version-pre
--without-version-opt
--with-version-build=#{build}
--with-toolchain-path=/usr/bin
--with-boot-jdk=#{boot_jdk}
--disable-warnings-as-errors
--with-boot-jdk-jvmargs=#{java_options}
--with-boot-jdk=#{boot_jdk}
--with-debug-level=release
--with-native-debug-symbols=none
--with-jvm-variants=server
--with-sysroot=#{MacOS.sdk_path}
--with-extra-ldflags=-headerpad_max_install_names
--enable-dtrace
--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}
Moisan marked this conversation as resolved.
Show resolved Hide resolved
--without-version-opt
--without-version-pre
]

if Hardware::CPU.arm?
framework_path = nil
on_macos do
Moisan marked this conversation as resolved.
Show resolved Hide resolved
args += %W[
--disable-warnings-as-errors
--openjdk-target=aarch64-apple-darwin
--with-build-jdk=#{boot_jdk}
--with-extra-cflags=-arch\ arm64
--with-extra-ldflags=-arch\ arm64\ -F#{framework_path}
--with-extra-cxxflags=-arch\ arm64
--enable-dtrace
--with-extra-ldflags=-headerpad_max_install_names
--with-sysroot=#{MacOS.sdk_path}
]

if Hardware::CPU.arm?
# Path to dual-arch JavaNativeFoundation.framework from Xcode
framework_path = File.expand_path(
"../SharedFrameworks/ContentDeliveryServices.framework/Versions/Current/itms/java/Frameworks",
MacOS::Xcode.prefix,
)

args += %W[
--openjdk-target=aarch64-apple-darwin
--with-build-jdk=#{boot_jdk}
--with-extra-cflags=-arch\ arm64
--with-extra-cxxflags=-arch\ arm64
--with-extra-ldflags=-arch\ arm64\ -F#{framework_path}
]
end
end

on_linux do
args += %W[
--with-x=#{HOMEBREW_PREFIX}
--with-cups=#{HOMEBREW_PREFIX}
--with-fontconfig=#{HOMEBREW_PREFIX}
]
end

Expand All @@ -123,38 +127,38 @@ def install
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"]
on_macos do
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"]

if Hardware::CPU.arm?
dest = libexec/"openjdk.jdk/Contents/Home/lib/JavaNativeFoundation.framework"
# Copy JavaNativeFoundation.framework from Xcode
# https://gist.github.com/claui/ea4248aa64d6a1b06c6d6ed80bc2d2b8#gistcomment-3539574
cp_r "#{framework_path}/JavaNativeFoundation.framework", dest, remove_destination: true
if Hardware::CPU.arm?
dest = libexec/"openjdk.jdk/Contents/Home/lib/JavaNativeFoundation.framework"
# Copy JavaNativeFoundation.framework from Xcode
# https://gist.github.com/claui/ea4248aa64d6a1b06c6d6ed80bc2d2b8#gistcomment-3539574
cp_r "#{framework_path}/JavaNativeFoundation.framework", dest, remove_destination: true
cho-m marked this conversation as resolved.
Show resolved Hide resolved

# Replace Apple signature by ad-hoc one (otherwise relocation will break it)
system "codesign", "-f", "-s", "-", "#{dest}/Versions/A/JavaNativeFoundation"
# Replace Apple signature by ad-hoc one (otherwise relocation will break it)
system "codesign", "-f", "-s", "-", "#{dest}/Versions/A/JavaNativeFoundation"
carlocab marked this conversation as resolved.
Show resolved Hide resolved
end
end

on_linux do
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"]
end
end

def caveats
on_macos do
s = <<~EOS
<<~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

if Hardware::CPU.arm?
s += <<~EOS
This is a beta version of openjdk for Apple Silicon
(openjdk 16 preview).
Comment on lines -152 to -153
Copy link
Member

@cho-m cho-m May 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should restore caveat so ARM mac users are aware that this is an Early-Access/Beta version and may experience more bugs than a GA release.

EOS
end

s
end
end

Expand Down
5 changes: 3 additions & 2 deletions Formula/redpen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Redpen < Formula
url "https://github.com/redpen-cc/redpen/releases/download/redpen-1.10.4/redpen-1.10.4.tar.gz"
sha256 "6c3dc4a6a45828f9cc833ca7253fdb036179036631248288251cb9ac4520c39d"
license "Apache-2.0"
revision 1

livecheck do
url :stable
Expand All @@ -13,15 +14,15 @@ class Redpen < Formula

bottle :unneeded

depends_on "openjdk"
depends_on "openjdk@11"

def install
# Don't need Windows files.
rm_f Dir["bin/*.bat"]
libexec.install %w[conf lib sample-doc js]

prefix.install "bin"
bin.env_script_all_files libexec/"bin", JAVA_HOME: Formula["openjdk"].opt_prefix
bin.env_script_all_files libexec/"bin", JAVA_HOME: Formula["openjdk@11"].opt_prefix
end

test do
Expand Down
Loading