forked from Homebrew/homebrew-cask
-
Notifications
You must be signed in to change notification settings - Fork 0
/
java.rb
109 lines (96 loc) · 5.53 KB
/
java.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
cask 'java' do
version '1.8.0_144-b01,090f390dda5b47b9b721c7dfaa008135'
sha256 '2450b35e10295ccf3fb1596bdea6f8f5670f7200ae3ac592eb6a54cc030cf94b'
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_preflight do
if File.exist?("#{HOMEBREW_PREFIX}/Caskroom/java-jdk-javadoc")
system_command 'brew', args: ['cask', 'uninstall', 'java-jdk-javadoc']
end
if File.exist?("#{HOMEBREW_PREFIX}/Caskroom/jce-unlimited-strength-policy")
system_command 'brew', args: ['cask', 'uninstall', 'jce-unlimited-strength-policy']
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 delete: [
'~/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.undent
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