Skip to content

Commit

Permalink
feat: add diagnose info on workspace creation
Browse files Browse the repository at this point in the history
  • Loading branch information
lgdd committed Aug 2, 2024
1 parent 5d06f4c commit 43c5a7e
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions internal/cmd/create/create_workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ package create
import (
"fmt"
"os"
"strings"

"github.com/lgdd/lfr-cli/internal/cmd/exec"
"github.com/lgdd/lfr-cli/internal/conf"
"github.com/lgdd/lfr-cli/pkg/metadata"
"github.com/lgdd/lfr-cli/pkg/scaffold"
"github.com/lgdd/lfr-cli/pkg/util/fileutil"
"github.com/lgdd/lfr-cli/pkg/util/logger"
"github.com/lgdd/lfr-cli/pkg/util/procutil"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down Expand Up @@ -82,4 +84,29 @@ func runInit(name, build string) {
func printInitCmd(name string) {
logger.Println("\nInitialize your Liferay bundle:")
logger.PrintlnInfo(fmt.Sprintf("cd %s && lfr init\n", name))
major, version, err := procutil.GetCurrentJavaVersion()

if err != nil {
logger.PrintError("[✗] ")
logger.Print("Liferay requires Java 8, 11, 17 or 21.\n")
}

if major == "8" {
logger.PrintWarn("[!] ")
logger.Printf("Java %s is used\n", strings.Split(version, "\n")[0])
logger.PrintWarn("Liferay DXP 2024.Q1 and Liferay Portal 7.4 GA112 will be the last version to support Java 8.")
} else if major == "11" {
logger.PrintWarn("[!] ")
logger.Printf("Java %s is used\n", strings.Split(version, "\n")[0])
logger.PrintWarn("Liferay DXP DXP 2024.Q2 and Liferay Portal 7.4 GA120 will be the last version to support Java 11.")
} else if major == "17" || major == "21" {
logger.PrintSuccess("[✓] ")
logger.Printf("Java %s is used\n", strings.Split(version, "\n")[0])
logger.PrintlnBold("Liferay DXP 2024.Q2+ and Liferay Portal CE 7.4 GA120+ are fully certified to run on both Java JDK 17 and 21.")
logger.PrintfBold("Building with Java %s requires Gradle 8.5 and Liferay Gradle Workspace Plugin v10.1+.", major)
} else {
logger.PrintWarn("[!] ")
logger.Printf("Java %s is used\n", strings.Split(version, "\n")[0])
logger.PrintlnBold("Liferay only supports Java 8, 11, 17 and 21. See https://www.liferay.com/compatibility-matrix.")
}
}

0 comments on commit 43c5a7e

Please sign in to comment.