GoogleChromeLabs / bubblewrap

Bubblewrap is a Command Line Interface (CLI) that helps developers to create a Project for an Android application that launches an existing Progressive Web App (PWAs) using a Trusted Web Activity.
Apache License 2.0
2.34k stars 161 forks source link

Find JDK automatically in common places #792

Open christianhujer opened 1 year ago

christianhujer commented 1 year ago
$ which javac
/home/christian.hujer/.sdkman/candidates/java/current/bin/javac
$ javac --version
javac 19.0.2
$ bubblewrap init --manifest https://chatncharge.nelkinda.com/manifest.json
,-----.        ,--.  ,--.  ,--.
|  |) /_,--.,--|  |-.|  |-.|  |,---.,--.   ,--,--.--.,--,--.,---.
|  .-.  |  ||  | .-. | .-. |  | .-. |  |.'.|  |  .--' ,-.  | .-. |
|  '--' '  ''  | `-' | `-' |  \   --|   .'.   |  |  \ '-'  | '-' '
`------' `----' `---' `---'`--'`----'--'   '--`--'   `--`--|  |-'
                                                           `--'    
? Do you want Bubblewrap to install JDK?
  (Enter "No" to use your JDK installation) No
? Path to your existing JDK: 

Bubblewrap should offer to pick up what's in PATH. Supporting SDKMAN! would be best, but at least pickup what's on PATH.

Is your feature request related to a problem? Please describe. It's frustrating that a tool like bubblewrap can't pickup where my JDK is, especially when my JDKs are in standard locations like ~/.sdkman/candidates/java/ and /usr/lib/jvm/.

Describe the solution you'd like I would like Bubblewrap to try to pick up Java by itself, in this sequence:

  1. Try to find java from $PATH.
  2. Try to find a suitable version from SDKMAN! using $SDKMAN_CANDIDATES_DIR if defined, otherwise $SDKMAN_DIR/candidates.
  3. Try to find a suitable version from /usr/lib/jvm. If a version is found, ask the user if that version should be used. If yes, use it, if no, keep on looking. If no version found, give up and ask the user.
andreban commented 1 year ago

This should be possible, but we have to guarantee suggesting a compatible JDK (this method can help)