kyuubi/build
Cheng Pan 90a7d1921a
[KYUUBI #3619] Enhance JAVA_HOME detection to support RPM
### _Why are the changes needed?_

By default, on CentOS 7 w/ openJDK 8 installed via YUM/RPM, the `/usr/bin/java` links to `/usr/lib/jvm/java-1.8.0-openjdk/jre/bin/java`, the current detection logic will think the `JAVA_HOME` is `/usr/lib/jvm/java-1.8.0-openjdk/jre`, and then cause the issue.

```
[ERROR] Failed to execute goal net.alchim31.maven:scala-maven-plugin:4.6.1:compile (scala-compile-first) on project kyuubi-common_2.12: wrap: java.io.IOException: Cannot run program "/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64/jre/bin/javac" (in directory "/home/pancheng/apache-kyuubi"): error=2, No such file or directory -> [Help 1]
```

### _How was this patch tested?_
- [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible

- [x] Add screenshots for manual tests if appropriate

w/ this patch, the `build/dist` works expected on CentOS w/ openJDK 8 installed via `yum`, the debug info shows it detected the right `JAVA_HOME`
```
+ [[ -z '' ]]
++ command -v rpm
+ '[' /usr/bin/rpm ']'
++ rpm -E %java_home
+ RPM_JAVA_HOME=/usr/lib/jvm/java
+ '[' /usr/lib/jvm/java '!=' %java_home ']'
+ JAVA_HOME=/usr/lib/jvm/java
+ echo 'No JAVA_HOME set, proceeding with '\''/usr/lib/jvm/java'\'' learned from rpm'
No JAVA_HOME set, proceeding with '/usr/lib/jvm/java' learned from rpm
+ '[' -z /usr/lib/jvm/java ']'
+ [[ -z /usr/lib/jvm/java ]]
+ echo 'JAVA_HOME is set to /usr/lib/jvm/java'
JAVA_HOME is set to /usr/lib/jvm/java
```

- [ ] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request

Closes #3619 from pan3793/java-home.

Closes #3619

b6e10a78 [Cheng Pan] nit
2a59d299 [Cheng Pan] [BUILD] Detect JAVA_HOME from rpm

Authored-by: Cheng Pan <chengpan@apache.org>
Signed-off-by: Cheng Pan <chengpan@apache.org>
2022-10-14 12:35:00 +08:00
..
release [KYUUBI #2873] [INFRA][DOCS] Improve release template script 2022-06-16 13:53:41 +08:00
dependency.sh [KYUUBI #1769][FOLLOWUP] Exclude log4j 12 deps from spark-hive and fix detect deps change workflow 2022-02-01 23:59:17 +08:00
dist [KYUUBI #3619] Enhance JAVA_HOME detection to support RPM 2022-10-14 12:35:00 +08:00
Dockerfile [KYUUBI #2115] Update license and enhance collect_licenses script 2022-03-14 19:45:40 +08:00
kyuubi-build-info [KYUUBI #2424] [Improvement] add Flink compile version and Trino client compile version to KyuubiServer Log 2022-04-21 15:22:10 +08:00
mvn [KYUUBI #1763] [INFRA] Remove scala installation inbuild/mvn and using warn level for the ci 2022-01-14 17:30:58 +08:00
util.sh [KYUUBI #889] [BUILD] Package release tarball 2021-08-06 13:17:51 +08:00