cask 'zulu7' do version '1.7.0_154,7.20.0.3' sha256 '2022731d584aa124077b9e2d0823c092151dee7412dfb8b601cf652dc750abce' url "https://cdn.azul.com/zulu/bin/zulu#{version.after_comma}-jdk#{version.minor}.#{version.patch}.#{version.before_comma.sub(%r{.*_}, '')}-macosx_x64.dmg", referer: 'http://www.azul.com/downloads/zulu/zulu-mac/' name 'Azul Zulu Java Standard Edition Development Kit' homepage 'https://www.azul.com/products/zulu-and-zulu-enterprise/' pkg "Double-Click to Install Zulu #{version.minor}.pkg" postflight do system_command '/bin/mv', args: ['-f', '--', "/Library/Java/JavaVirtualMachines/zulu-#{version.minor}.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.minor}.jdk"], sudo: true system_command '/bin/ln', args: ['-nsf', '--', "/Library/Java/JavaVirtualMachines/zulu#{version.before_comma}.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.before_comma}.jdk/Contents/Info.plist"], 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/zulu#{version.before_comma}.jdk/Contents", '/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK'], sudo: true end end uninstall pkgutil: [ "com.azulsystems.zulu.#{version.minor}", ], delete: [ "/Library/Java/JavaVirtualMachines/zulu#{version.before_comma}.jdk", "/Library/Java/JavaVirtualMachines/zulu-#{version.minor}.jdk", '/Library/Java/Home', if MacOS.version <= :mavericks [ '/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK', ] end, ].keep_if { |v| !v.nil? } end