tdiesler commented on code in PR #5440:
URL: https://github.com/apache/camel-k/pull/5440#discussion_r1584931329


##########
script/check_jdk_version.go:
##########
@@ -0,0 +1,33 @@
+package main
+
+import (
+       "fmt"
+       "os/exec"
+       "regexp"
+       "strconv"
+)
+
+func main() {
+
+       cmd := exec.Command("java", "-version")
+       output, err := cmd.CombinedOutput()
+       if err != nil {
+               panic(fmt.Sprintf("Error: %v\n", err))
+       }
+
+       versionStr := string(output)
+       versionRegex := regexp.MustCompile(`version 
"?([1-9]+)(\.([0-9]+)){2,3}"?`)
+       matches := versionRegex.FindStringSubmatch(versionStr)
+       if len(matches) < 2 {
+               panic(fmt.Sprintf("Unable to determine Java version: %s\n", 
versionStr))

Review Comment:
   ok. How about we get the java version from maven i.e.
   
   ```
   $ mvn -version
   Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae)
   Maven home: /opt/homebrew/Cellar/maven/3.9.6/libexec
   Java version: 17.0.6, vendor: Azul Systems, Inc., runtime: 
/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home
   Default locale: en_GB, platform encoding: UTF-8
   OS name: "mac os x", version: "14.4.1", arch: "aarch64", family: "mac"
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to