-
Notifications
You must be signed in to change notification settings - Fork 88
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
System Java now works on macOS #142
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,10 +16,10 @@ jobs: | |
TERM: dumb | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: mstksg/get-package@v1 | ||
- uses: delgurth/get-package@v3 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any specific reason the replace the GitHub Action here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, there was a specific reason, v1 installed packages twice on newer Ubuntu images, once via brew and once via the normal apt-get. mstksg/get-package#5 |
||
with: | ||
brew: bash coreutils jq shellcheck | ||
apt-get: jq shellcheck | ||
brew: bash coreutils jq shellcheck fish xonsh zsh | ||
apt-get: jq shellcheck zsh fish xonsh bash | ||
- name: Run ShellCheck | ||
run: | | ||
shellcheck -V | ||
|
@@ -34,14 +34,116 @@ jobs: | |
env: | ||
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
. asdf/asdf.sh | ||
. $PWD/asdf/asdf.sh | ||
asdf plugin-test java "$GITHUB_WORKSPACE" --asdf-plugin-gitref "$GITHUB_SHA" --asdf-tool-version adoptopenjdk-8.0.252+9.1.openj9-0.20.0 java -version | ||
- name: macOS Check java_home integration | ||
if: matrix.os == 'macOS-latest' | ||
env: | ||
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
export ASDF_CONFIG_FILE=${HOME}"/.asdfrc" | ||
echo "java_macos_integration_enable = yes" > "${ASDF_CONFIG_FILE}" | ||
. asdf/asdf.sh | ||
. $PWD/asdf/asdf.sh | ||
asdf plugin-test java "$GITHUB_WORKSPACE" --asdf-plugin-gitref "$GITHUB_SHA" --asdf-tool-version zulu-8.52.0.23 /usr/libexec/java_home -V 2>&1 | grep "Zulu 8.52.0.23" | ||
- name: Setup JAVA_HOME setting | ||
env: | ||
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
export ASDF_CONFIG_FILE=${HOME}"/.asdfrc" | ||
echo "java_macos_integration_enable = yes" > "${ASDF_CONFIG_FILE}" | ||
. $PWD/asdf/asdf.sh | ||
asdf plugin add java "$GITHUB_WORKSPACE" | ||
asdf install java adoptopenjdk-8.0.252+9.1.openj9-0.20.0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After the changes in #140, this (and all subsequent usages of this identifier in this file) should probably be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will see what is needed now to get things to work again properly. Been a long time since I last worked on this... |
||
asdf global java adoptopenjdk-8.0.252+9.1.openj9-0.20.0 | ||
echo ". $PWD/asdf/asdf.sh" >> $HOME/.zshrc | ||
echo ". $HOME/.asdf/plugins/java/set-java-home.zsh" >> $HOME/.zshrc | ||
mkdir -p $HOME/.config/fish/functions/ | ||
ln -s $HOME/.asdf/plugins/java/set-java-home.fish $HOME/.config/fish/functions/asdf_update_java_home.fish | ||
echo "source $PWD/asdf/asdf.fish" >> $HOME/.config/fish/config.fish | ||
echo "asdf_update_java_home" >> $HOME/.config/fish/config.fish | ||
- name: Run JAVA_HOME setting test fish | ||
env: | ||
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
echo $JAVA_HOME | grep adoptopenjdk-8.0.252+9.1.openj9-0.20.0 | ||
shell: fish {0} | ||
- name: Run JAVA_HOME setting test bash | ||
env: | ||
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
. $PWD/asdf/asdf.sh | ||
. set-java-home.bash | ||
_asdf_java_prompt_command | ||
echo $JAVA_HOME | grep -q adoptopenjdk-8.0.252+9.1.openj9-0.20.0 | ||
shell: bash {0} | ||
- name: Run JAVA_HOME setting test xonsh | ||
env: | ||
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
$RAISE_SUBPROC_ERROR = True | ||
source-bash $PWD/asdf/asdf.sh | ||
source set-java-home.xsh | ||
echo $JAVA_HOME | grep -q adoptopenjdk-8.0.252+9.1.openj9-0.20.0 | ||
shell: xonsh {0} | ||
- name: Run JAVA_HOME setting test zsh | ||
env: | ||
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
source $HOME/.zshrc | ||
asdf_update_java_home | ||
echo $JAVA_HOME | grep -q adoptopenjdk-8.0.252+9.1.openj9-0.20.0 | ||
shell: zsh {0} | ||
- name: Setup system tool-version test on macOS | ||
if: matrix.os == 'macOS-latest' | ||
env: | ||
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
export ASDF_CONFIG_FILE=${HOME}"/.asdfrc" | ||
echo "java_macos_integration_enable = yes" > "${ASDF_CONFIG_FILE}" | ||
. $PWD/asdf/asdf.sh | ||
. set-java-home.bash | ||
asdf install java zulu-16.28.11 | ||
mkdir system | ||
cd system | ||
echo "java system" > .tool-versions | ||
- name: Run system tool-version test on macOS with fish | ||
if: matrix.os == 'macOS-latest' | ||
env: | ||
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
cd system | ||
asdf_update_java_home | ||
echo $JAVA_HOME | grep -q "/Library/Java/JavaVirtualMachines/" | ||
shell: fish {0} | ||
- name: Run system tool-version test on macOS with bash | ||
if: matrix.os == 'macOS-latest' | ||
env: | ||
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
. $PWD/asdf/asdf.sh | ||
. set-java-home.bash | ||
cd system | ||
_asdf_java_prompt_command | ||
echo $JAVA_HOME | grep -q "/Library/Java/JavaVirtualMachines/" | ||
shell: bash {0} | ||
- name: Run system tool-version test on macOS with xonsh | ||
if: matrix.os == 'macOS-latest' | ||
env: | ||
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
$RAISE_SUBPROC_ERROR = True | ||
source-bash $PWD/asdf/asdf.sh | ||
source set-java-home.xsh | ||
cd system | ||
echo $JAVA_HOME | grep -q "/Library/Java/JavaVirtualMachines/" | ||
shell: xonsh {0} | ||
- name: Run system tool-version test on macOS with zsh | ||
if: matrix.os == 'macOS-latest' | ||
env: | ||
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
source $HOME/.zshrc | ||
cd system | ||
asdf_update_java_home | ||
echo $JAVA_HOME | grep -q "/Library/Java/JavaVirtualMachines/" | ||
shell: zsh {0} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.idea/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we remove this file again? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added this since I'm working from IntelliJ IDEA. This way I prevent my IDEA setup to be checked in, which I think is preferable? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be in your own global |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,46 +11,51 @@ | |
- [unzip](http://infozip.sourceforge.net/UnZip.html) | ||
- [jq](https://stedolan.github.io/jq/) (only for updating the release data) | ||
|
||
_Besides bash (the shell used by the maintainer) this plugin **should** work on Fish, Zsh and Xonsh_ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tests in the GitHub workflows should show that it's working. 😉 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True, but I wanted to make clear what was guaranteed. Getting the Xonsh part to work properly took me quite some time, which annoyed me a bit. That's what made me add this line. |
||
|
||
## Install | ||
|
||
``` | ||
asdf plugin-add java https://github.com/halcyon/asdf-java.git | ||
asdf plugin add java | ||
``` | ||
|
||
## Use | ||
|
||
Check [asdf](https://asdf-vm.github.io/asdf/) for instructions on how to install & manage versions of Java. | ||
|
||
## Install | ||
## Install new Java version | ||
|
||
List candidate JDKs: | ||
|
||
`asdf list-all java` | ||
|
||
Install a candidate listed from the previous command like this: | ||
|
||
`asdf install java adopt-openjdk-12.0.2+10.2` | ||
`asdf install java adoptopenjdk-12.0.2+10.1` | ||
|
||
Select an installed candidate for use like this: | ||
|
||
`asdf global java adopt-openjdk-12.0.2+10.2` | ||
`asdf global java adoptopenjdk-12.0.2+10.1` | ||
|
||
## JAVA_HOME | ||
To set JAVA_HOME in your shell's initialization add the following: | ||
|
||
`. ~/.asdf/plugins/java/set-java-home.bash` | ||
|
||
For zsh shell, instead use: | ||
|
||
`. ~/.asdf/plugins/java/set-java-home.zsh` | ||
### Bash | ||
`echo ". ~/.asdf/plugins/java/set-java-home.bash" >> ~/.bashrc` | ||
|
||
For fish shell, instead use: | ||
### Zsh | ||
`echo ". ~/.asdf/plugins/java/set-java-home.zsh" >> ~/.zshrc` | ||
|
||
`. ~/.asdf/plugins/java/set-java-home.fish` | ||
|
||
For xonsh shell, instead use: | ||
### Fish | ||
``` | ||
mkdir -p ~/.config/fish/functions/ | ||
ln -s ~/.asdf/plugins/java/set-java-home.fish ~/.config/fish/functions/asdf_update_java_home.fish | ||
echo "asdf_update_java_home" >> ~/.config/fish/config.fish | ||
``` | ||
_the mkdir is only needed in case you didn't add any functions yet_ | ||
|
||
`source ~/.asdf/plugins/java/set-java-home.xsh` | ||
### Xonsh | ||
`echo "source ~/.asdf/plugins/java/set-java-home.xsh" >> ~/.xonshrc` | ||
|
||
## macOS Integration | ||
Some applications in macOS use `/usr/libexec/java_home` to set java home. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@delgurth Could you please either update the
indent_size
in.editorconfig
to match the existing code or remove the file altogether, and revert the whitespace related changes in this PR?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll remove all formatting changes. I've tried to align it, but if I recall correctly the formatting was different in different parts of the codebase.