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

Use user home to integrate java for macOS #221

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions bin/functions
Original file line number Diff line number Diff line change
Expand Up @@ -225,18 +225,29 @@ function uninstall {
}

function java_macos_integration_remove {
printf "Removing the integration with /usr/libexec/java_home needs root permission to delete the folder at /Library/Java/JavaVirtualMachines/%s\n" "${ASDF_INSTALL_VERSION}"
sudo rm -rf "/Library/Java/JavaVirtualMachines/${ASDF_INSTALL_VERSION}"
if [ "$(get_asdf_config_value "java_macos_integration_in_home")" = "yes" ]; then
rm -rf "$HOME/Library/Java/JavaVirtualMachines/${ASDF_INSTALL_VERSION}"
else
printf "Removing the integration with /usr/libexec/java_home needs root permission to delete the folder at /Library/Java/JavaVirtualMachines/%s\n" "${ASDF_INSTALL_VERSION}"
sudo rm -rf "/Library/Java/JavaVirtualMachines/${ASDF_INSTALL_VERSION}"
fi
}

function java_macos_integration_install {
local macOS_files_path
macOS_files_path="$1"
printf "Integrating with /usr/libexec/java_home needs root permission for it to create folders under /Library/Java/JavaVirtualMachines\n"
sudo mkdir -p "/Library/Java/JavaVirtualMachines/${ASDF_INSTALL_VERSION}/Contents"
sudo cp -R "${macOS_files_path}/Contents/MacOS" "/Library/Java/JavaVirtualMachines/${ASDF_INSTALL_VERSION}/Contents/"
sudo cp -R "${macOS_files_path}/Contents/Info.plist" "/Library/Java/JavaVirtualMachines/${ASDF_INSTALL_VERSION}/Contents/"
sudo ln -s "${ASDF_INSTALL_PATH}" "/Library/Java/JavaVirtualMachines/${ASDF_INSTALL_VERSION}/Contents/Home"
if [ "$(get_asdf_config_value "java_macos_integration_in_home")" = "yes" ]; then
mkdir -p "$HOME/Library/Java/JavaVirtualMachines/${ASDF_INSTALL_VERSION}/Contents"
cp -R "${macOS_files_path}/Contents/MacOS" "$HOME/Library/Java/JavaVirtualMachines/${ASDF_INSTALL_VERSION}/Contents/"
cp -R "${macOS_files_path}/Contents/Info.plist" "$HOME/Library/Java/JavaVirtualMachines/${ASDF_INSTALL_VERSION}/Contents/"
ln -s "${ASDF_INSTALL_PATH}" "$HOME/Library/Java/JavaVirtualMachines/${ASDF_INSTALL_VERSION}/Contents/Home"
else
printf "Integrating with /usr/libexec/java_home needs root permission for it to create folders under /Library/Java/JavaVirtualMachines\n"
sudo mkdir -p "/Library/Java/JavaVirtualMachines/${ASDF_INSTALL_VERSION}/Contents"
sudo cp -R "${macOS_files_path}/Contents/MacOS" "/Library/Java/JavaVirtualMachines/${ASDF_INSTALL_VERSION}/Contents/"
sudo cp -R "${macOS_files_path}/Contents/Info.plist" "/Library/Java/JavaVirtualMachines/${ASDF_INSTALL_VERSION}/Contents/"
sudo ln -s "${ASDF_INSTALL_PATH}" "/Library/Java/JavaVirtualMachines/${ASDF_INSTALL_VERSION}/Contents/Home"
fi
}

function absolute_dir_path {
Expand Down
Loading