Skip to content

Commit

Permalink
Remove workarounds in Java casks. (#58510)
Browse files Browse the repository at this point in the history
  • Loading branch information
reitermarkus authored Feb 6, 2019
1 parent b3e18ae commit 6ba56f9
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 165 deletions.
60 changes: 3 additions & 57 deletions Casks/adoptopenjdk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,66 +5,12 @@
# github.com/AdoptOpenJDK was verified as official when first introduced to the cask
url "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-#{version.before_comma}%2B#{version.after_comma}/OpenJDK11U-jdk_x64_mac_hotspot_#{version.before_comma}_#{version.after_comma}.tar.gz"
appcast 'https://github.com/adoptopenjdk/openjdk11-binaries/releases.atom'
name 'AdoptOpenJDK'
name 'AdoptOpenJDK Java Development Kit'
homepage 'https://adoptopenjdk.net/'

postflight do
system_command '/bin/mv',
args: [
'-f', '--', "#{staged_path}/jdk-#{version.before_comma}+#{version.after_comma}",
"/Library/Java/JavaVirtualMachines/adoptopenjdk-#{version.before_comma}.jdk"
],
sudo: true
artifact "jdk-#{version.before_comma}+#{version.after_comma}", target: "/Library/Java/JavaVirtualMachines/adoptopenjdk-#{version.before_comma}.jdk"

system_command '/bin/mkdir',
args: ['-p', '--', "/Library/Java/JavaVirtualMachines/adoptopenjdk-#{version.before_comma}.jdk/Contents/Home/bundle/Libraries"],
sudo: true

system_command '/bin/ln',
args: [
'-nsf', '--',
"/Library/Java/JavaVirtualMachines/adoptopenjdk-#{version.before_comma}.jdk/Contents/Home/lib/server/libjvm.dylib",
"/Library/Java/JavaVirtualMachines/adoptopenjdk-#{version.before_comma}.jdk/Contents/Home/bundle/Libraries/libserver.dylib"
],
sudo: true

system_command '/usr/libexec/PlistBuddy',
args: [
'-c', "Set :CFBundleGetInfoString AdoptOpenJDK #{version.before_comma}+#{version.after_comma}",
"/Library/Java/JavaVirtualMachines/adoptopenjdk-#{version.before_comma}.jdk/Contents/Info.plist"
],
sudo: true

system_command '/usr/libexec/PlistBuddy',
args: [
'-c', "Set :CFBundleIdentifier net.adoptopenjdk.#{version.before_comma}.jdk",
"/Library/Java/JavaVirtualMachines/adoptopenjdk-#{version.before_comma}.jdk/Contents/Info.plist"
],
sudo: true

system_command '/usr/libexec/PlistBuddy',
args: [
'-c', "Set :CFBundleName AdoptOpenJDK #{version.before_comma}",
"/Library/Java/JavaVirtualMachines/adoptopenjdk-#{version.before_comma}.jdk/Contents/Info.plist"
],
sudo: true

system_command '/usr/libexec/PlistBuddy',
args: [
'-c', "Set :JavaVM:JVMPlatformVersion #{version.before_comma}.#{version.after_comma}",
"/Library/Java/JavaVirtualMachines/adoptopenjdk-#{version.before_comma}.jdk/Contents/Info.plist"
],
sudo: true

system_command '/usr/libexec/PlistBuddy',
args: [
'-c', 'Set :JavaVM:JVMVendor AdoptOpenJDK',
"/Library/Java/JavaVirtualMachines/adoptopenjdk-#{version.before_comma}.jdk/Contents/Info.plist"
],
sudo: true
end

uninstall delete: "/Library/Java/JavaVirtualMachines/adoptopenjdk-#{version.before_comma}.jdk"
uninstall rmdir: '/Library/Java/JavaVirtualMachines'

caveats <<~EOS
More versions are available in the AdoptOpenJDK tap:
Expand Down
26 changes: 3 additions & 23 deletions Casks/java.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,10 @@
sha256 'f365750d4be6111be8a62feda24e265d97536712bc51783162982b8ad96a70ee'

url "https://download.java.net/java/GA/jdk#{version.major}/#{version.after_comma}/GPL/openjdk-#{version.before_comma}_osx-x64_bin.tar.gz"
name 'OpenJDK'
name 'OpenJDK Java Development Kit'
homepage 'https://jdk.java.net/'

postflight do
system_command '/bin/mv',
args: [
'-f', '--',
"#{staged_path}/jdk-#{version.before_comma}.jdk",
"/Library/Java/JavaVirtualMachines/openjdk-#{version.before_comma}.jdk"
],
sudo: true
artifact "jdk-#{version.before_comma}.jdk", target: "/Library/Java/JavaVirtualMachines/openjdk-#{version.before_comma}.jdk"

system_command '/bin/mkdir',
args: ['-p', '--', "/Library/Java/JavaVirtualMachines/openjdk-#{version.before_comma}.jdk/Contents/Home/bundle/Libraries"],
sudo: true

system_command '/bin/ln',
args: [
'-nsf', '--',
"/Library/Java/JavaVirtualMachines/openjdk-#{version.before_comma}.jdk/Contents/Home/lib/server/libjvm.dylib",
"/Library/Java/JavaVirtualMachines/openjdk-#{version.before_comma}.jdk/Contents/Home/bundle/Libraries/libserver.dylib"
],
sudo: true
end

uninstall delete: "/Library/Java/JavaVirtualMachines/openjdk-#{version.before_comma}.jdk"
uninstall rmdir: '/Library/Java/JavaVirtualMachines'

This comment has been minimized.

Copy link
@odrotbohm

odrotbohm Mar 20, 2019

Contributor

Does that change make sense actually? As different Java versions can be installed, a removal of one of them would remove all Java installations, which is probably not what a user wants right?

This comment has been minimized.

Copy link
@reitermarkus

reitermarkus Mar 20, 2019

Author Member

This only removes the directory if it is empty.

end
29 changes: 10 additions & 19 deletions Casks/oracle-jdk-javadoc.rb
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
cask 'oracle-jdk-javadoc' do
version '11.0.1,13:90cf5d8f270a4347a95050320eef3fb7'
sha256 '6255d96128898b8dd3c65d84d9732e47d633879aff4345a5dd8d41bfffdd2199'
version '11.0.2,9:f51449fcd52f4d52b93a989c5c56ed3c'
sha256 '8723e26bf097b4b9375851338270870d3b5ef1a3843f0631597adb9039308083'

url "https://download.oracle.com/otn-pub/java/jdk/#{version.before_comma}+#{version.after_comma.before_colon}/#{version.after_colon}/jdk-#{version.before_comma}_doc-all.zip",
cookies: {
'oraclelicense' => 'accept-securebackup-cookie',
}
name 'Java Standard Edition Development Kit Documentation'
name 'Oracle Java Standard Edition Development Kit Documentation'
homepage "https://www.oracle.com/technetwork/java/javase/documentation/jdk#{version.major}-doc-downloads-4417029.html"

postflight do
`/usr/libexec/java_home -v #{version.before_comma} -X | grep -B0 -A1 JVMHomePath | sed -n -e 's/[[:space:]]*<string>\\(.*\\)<\\/string>/\\1/p'`.split("\n").each do |path|
system_command '/bin/cp',
args: ['-rp', "#{staged_path}/docs", "#{path}/"],
sudo: true
end
end

uninstall_postflight do
`/usr/libexec/java_home -v #{version.before_comma} -X | grep -B0 -A1 JVMHomePath | sed -n -e 's/[[:space:]]*<string>\\(.*\\)<\\/string>/\\1/p'`.split("\n").each do |path|
next unless File.exist?("#{path}/docs")
artifact 'docs', target: "/Library/Java/JavaVirtualMachines/jdk-#{version.before_comma}.jdk/Contents/Home/docs"

system_command '/bin/rm',
args: ['-rf', "#{path}/docs"],
sudo: true
end
end
uninstall rmdir: [
"/Library/Java/JavaVirtualMachines/jdk-#{version.before_comma}.jdk/Contents/Home",
"/Library/Java/JavaVirtualMachines/jdk-#{version.before_comma}.jdk/Contents",
"/Library/Java/JavaVirtualMachines/jdk-#{version.before_comma}.jdk",
'/Library/Java/JavaVirtualMachines',
]

caveats do
license 'https://www.oracle.com/technetwork/java/javase/terms/license/index.html'
Expand Down
25 changes: 2 additions & 23 deletions Casks/oracle-jdk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,15 @@
cookies: {
'oraclelicense' => 'accept-securebackup-cookie',
}
name 'Java Standard Edition Development Kit'
name 'Oracle Java Standard Edition Development Kit'
homepage 'https://www.oracle.com/technetwork/java/javase/overview/index.html'

# auto_updates true: JDK does not auto-update
depends_on macos: '>= :yosemite'

pkg "JDK #{version.before_comma}.pkg"

postflight do
system_command '/bin/ln',
args: ['-nsf', '--', "/Library/Java/JavaVirtualMachines/jdk-#{version.before_comma}.jdk/Contents/Home", '/Library/Java/Home'],
sudo: true
system_command '/bin/ln',
args: ['-nsf', '--', "/Library/Java/JavaVirtualMachines/jdk-#{version.before_comma}.jdk/Contents/MacOS", '/Library/Java/MacOS'],
sudo: true
system_command '/bin/mkdir',
args: ['-p', '--', "/Library/Java/JavaVirtualMachines/jdk-#{version.before_comma}.jdk/Contents/Home/bundle/Libraries"],
sudo: true
system_command '/bin/ln',
args: ['-nsf', '--', "/Library/Java/JavaVirtualMachines/jdk-#{version.before_comma}.jdk/Contents/Home/lib/server/libjvm.dylib", "/Library/Java/JavaVirtualMachines/jdk-#{version.before_comma}.jdk/Contents/Home/bundle/Libraries/libserver.dylib"],
sudo: true
end

uninstall pkgutil: "com.oracle.jdk-#{version.before_comma}",
delete: [
"/Library/Java/JavaVirtualMachines/jdk-#{version.before_comma}.jdk/Contents",
'/Library/Java/Home',
'/Library/Java/MacOS',
],
rmdir: "/Library/Java/JavaVirtualMachines/jdk-#{version.before_comma}.jdk"
rmdir: '/Library/Java/JavaVirtualMachines'

caveats do
license 'https://www.oracle.com/technetwork/java/javase/terms/license/javase-license.html'
Expand Down
26 changes: 3 additions & 23 deletions Casks/sapmachine-jdk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,10 @@

url "https://github.com/SAP/SapMachine/releases/download/sapmachine-#{version.before_comma}+#{version.after_comma}/sapmachine-jdk-#{version.before_comma}.#{version.after_comma.split('-').first}_osx-x64_bin.tar.gz"
appcast "https://sap.github.io/SapMachine/latest/#{version.before_comma}"
name 'SapMachine JDK'
name 'SapMachine Java Development Kit'
homepage 'https://github.com/SAP/SapMachine'

postflight do
system_command '/bin/mv',
args: [
'-f', '--',
"#{staged_path}/sapmachine-jdk-#{version.before_comma}.jdk",
"/Library/Java/JavaVirtualMachines/sapmachine-jdk-#{version.before_comma}.jdk"
],
sudo: true
artifact "sapmachine-jdk-#{version.before_comma}.jdk", target: "/Library/Java/JavaVirtualMachines/sapmachine-jdk-#{version.before_comma}.jdk"

system_command '/bin/mkdir',
args: ['-p', '--', "/Library/Java/JavaVirtualMachines/sapmachine-jdk-#{version.before_comma}.jdk/Contents/Home/bundle/Libraries"],
sudo: true

system_command '/bin/ln',
args: [
'-nsf', '--',
"/Library/Java/JavaVirtualMachines/sapmachine-jdk-#{version.before_comma}.jdk/Contents/Home/lib/server/libjvm.dylib",
"/Library/Java/JavaVirtualMachines/sapmachine-jdk-#{version.before_comma}.jdk/Contents/Home/bundle/Libraries/libserver.dylib"
],
sudo: true
end

uninstall delete: "/Library/Java/JavaVirtualMachines/sapmachine-jdk-#{version.before_comma}.jdk"
uninstall rmdir: '/Library/Java/JavaVirtualMachines'
end
23 changes: 3 additions & 20 deletions Casks/zulu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,10 @@
name 'Azul Zulu Java Standard Edition Development Kit'
homepage 'https://www.azul.com/downloads/zulu/zulu-mac/'

pkg "Double-Click to Install Zulu #{version.major}.pkg"
depends_on macos: '>= :sierra'

postflight do
system_command '/bin/mv',
args: ['-f', '--', "/Library/Java/JavaVirtualMachines/zulu-#{version.major}.jdk", "/Library/Java/JavaVirtualMachines/zulu-#{version.before_comma}.jdk"],
sudo: true
system_command '/bin/ln',
args: ['-nsf', '--', "/Library/Java/JavaVirtualMachines/zulu-#{version.before_comma}.jdk", "/Library/Java/JavaVirtualMachines/zulu-#{version.major}.jdk"],
sudo: true
system_command '/bin/ln',
args: ['-nsf', '--', "/Library/Java/JavaVirtualMachines/zulu-#{version.major}.jdk/Contents/Home", '/Library/Java/Home'],
sudo: true
system_command '/usr/libexec/PlistBuddy',
args: ['-c', 'Add :JavaVM:JVMCapabilities: string JNI', "/Library/Java/JavaVirtualMachines/zulu-#{version.major}.jdk/Contents/Info.plist"],
sudo: true
end
pkg "Double-Click to Install Zulu #{version.major}.pkg"

uninstall pkgutil: "com.azulsystems.zulu.#{version.major}",
delete: [
"/Library/Java/JavaVirtualMachines/zulu-#{version.before_comma}.jdk",
"/Library/Java/JavaVirtualMachines/zulu-#{version.major}.jdk",
'/Library/Java/Home',
]
rmdir: '/Library/Java/JavaVirtualMachines'
end

0 comments on commit 6ba56f9

Please sign in to comment.