You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

99 lines
5.1 KiB

cask 'java8' do
version '1.8.0_152-b16,aa0333dd3019491ca4f6ddbe78cdb6d0'
sha256 '9f9008e2b05e431838c8ee5f0d54f7715da386bc70b14d4910766c71e9f7923f'
java_update = version.sub(%r{.*_(\d+)-.*}, '\1')
url "http://download.oracle.com/otn-pub/java/jdk/#{version.minor}u#{version.before_comma.split('_').last}/#{version.after_comma}/jdk-#{version.minor}u#{java_update}-macosx-x64.dmg",
cookies: {
'oraclelicense' => 'accept-securebackup-cookie',
}
name 'Java Standard Edition Development Kit'
homepage "https://www.oracle.com/technetwork/java/javase/downloads/jdk#{version.minor}-downloads-2133151.html"
pkg "JDK #{version.minor} Update #{java_update}.pkg"
postflight do
system_command '/usr/libexec/PlistBuddy',
args: ['-c', 'Add :JavaVM:JVMCapabilities: string BundledApp', "/Library/Java/JavaVirtualMachines/jdk#{version.split('-')[0]}.jdk/Contents/Info.plist"],
sudo: true
system_command '/usr/libexec/PlistBuddy',
args: ['-c', 'Add :JavaVM:JVMCapabilities: string JNI', "/Library/Java/JavaVirtualMachines/jdk#{version.split('-')[0]}.jdk/Contents/Info.plist"],
sudo: true
system_command '/usr/libexec/PlistBuddy',
args: ['-c', 'Add :JavaVM:JVMCapabilities: string WebStart', "/Library/Java/JavaVirtualMachines/jdk#{version.split('-')[0]}.jdk/Contents/Info.plist"],
sudo: true
system_command '/usr/libexec/PlistBuddy',
args: ['-c', 'Add :JavaVM:JVMCapabilities: string Applets', "/Library/Java/JavaVirtualMachines/jdk#{version.split('-')[0]}.jdk/Contents/Info.plist"],
sudo: true
system_command '/bin/ln',
args: ['-nsf', '--', "/Library/Java/JavaVirtualMachines/jdk#{version.split('-')[0]}.jdk/Contents/Home", '/Library/Java/Home'],
sudo: true
system_command '/bin/mkdir',
args: ['-p', '--', "/Library/Java/JavaVirtualMachines/jdk#{version.split('-')[0]}.jdk/Contents/Home/bundle/Libraries"],
sudo: true
system_command '/bin/ln',
args: ['-nsf', '--', "/Library/Java/JavaVirtualMachines/jdk#{version.split('-')[0]}.jdk/Contents/Home/jre/lib/server/libjvm.dylib", "/Library/Java/JavaVirtualMachines/jdk#{version.split('-')[0]}.jdk/Contents/Home/bundle/Libraries/libserver.dylib"],
sudo: true
if MacOS.version <= :mavericks
system_command '/bin/rm',
args: ['-rf', '--', '/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK'],
sudo: true
system_command '/bin/ln',
args: ['-nsf', '--', "/Library/Java/JavaVirtualMachines/jdk#{version.split('-')[0]}.jdk/Contents", '/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK'],
sudo: true
end
end
uninstall pkgutil: [
"com.oracle.jdk#{version.minor}u#{java_update}",
'com.oracle.jre',
],
launchctl: [
'com.oracle.java.Helper-Tool',
'com.oracle.java.Java-Updater',
],
quit: [
'com.oracle.java.Java-Updater',
'net.java.openjdk.cmd', # Java Control Panel
],
delete: [
'/Library/Internet Plug-Ins/JavaAppletPlugin.plugin',
"/Library/Java/JavaVirtualMachines/jdk#{version.split('-')[0]}.jdk/Contents",
'/Library/PreferencePanes/JavaControlPanel.prefPane',
'/Library/Java/Home',
if MacOS.version <= :mavericks
[
'/usr/lib/java/libjdns_sd.jnilib',
'/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK',
]
end,
].keep_if { |v| !v.nil? }
zap trash: [
'~/Library/Application Support/Java/',
'~/Library/Application Support/Oracle/Java',
'~/Library/Caches/com.oracle.java.Java-Updater',
'~/Library/Caches/Oracle.MacJREInstaller',
'~/Library/Caches/net.java.openjdk.cmd',
'~/Library/Preferences/com.oracle.java.Java-Updater.plist',
'~/Library/Preferences/com.oracle.java.JavaAppletPlugin.plist',
'~/Library/Preferences/com.oracle.javadeployment.plist',
],
rmdir: '~/Library/Application Support/Oracle/'
caveats <<~EOS
This Cask makes minor modifications to the JRE to prevent issues with
packaged applications, as discussed here:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=411361
If your Java application still asks for JRE installation, you might need
to reboot or logout/login.
Installing this Cask means you have AGREED to the Oracle Binary Code
License Agreement for Java SE at
https://www.oracle.com/technetwork/java/javase/terms/license/index.html
EOS
end