diff --git a/buildSrc/src/main/groovy/docker-liferay-bundle.gradle b/buildSrc/src/main/groovy/docker-liferay-bundle.gradle index 52f7756..81771d5 100644 --- a/buildSrc/src/main/groovy/docker-liferay-bundle.gradle +++ b/buildSrc/src/main/groovy/docker-liferay-bundle.gradle @@ -27,16 +27,31 @@ Closure isValidLicenseFile = { return false } + String invalidLicenseReason = null + XmlSlurper xmlSlurper = new XmlSlurper() GPathResult gPathResult = xmlSlurper.parse(licenseFile) + + if (config.useClustering) { + String licenseType = gPathResult["license-type"].text() + + if (["developer", "limited", "trial"].contains(licenseType)) { + invalidLicenseReason = "Clustering is enabled, but ${licenseType} license file ${licenseFile.absolutePath} cannot be used in a clustered environment" + } + } + String expirationDateText = gPathResult["expiration-date"].text() - if (new Date(expirationDateText).after(new Date())) { + if (new Date(expirationDateText).before(new Date())) { + invalidLicenseReason = "License file ${licenseFile.absolutePath} expired on ${expirationDateText}" + } + + if (invalidLicenseReason == null) { return true } - println "License file ${licenseFile.absolutePath} expired on ${expirationDateText}" + println invalidLicenseReason licenseFile.delete() @@ -91,7 +106,7 @@ Closure getLatestImageNameLocal = { Closure copyLiferayLicenseFromDXPImage = { String imageName, boolean pullImage = false -> - if ((imageName == null) || !(imageName.contains(".q") || imageName.contains("latest"))) { + if (config.useClustering || (imageName == null) || !(imageName.contains(".q") || imageName.contains("latest"))) { return null } @@ -166,6 +181,10 @@ tasks.register("checkForLiferayLicense") { } if (Util.isEmpty(licenseXmlFileCollection)) { + if (config.useClustering) { + throw new GradleException("Please add a non-expired license that allows for clustering to configs/common/osgi/modules/") + } + throw new GradleException("Please add a non-expired license to configs/common/osgi/modules/") } } diff --git a/scripts/cli/lec.sh b/scripts/cli/lec.sh index 750f2f6..03ef14f 100755 --- a/scripts/cli/lec.sh +++ b/scripts/cli/lec.sh @@ -194,13 +194,20 @@ _checkCWDProject() { # Download releases.json file if it is missing or out of date # -RELEASES_JSON_FILE="$HOME/.liferay/workspace/releases.json" +LIFERAY_WORKSPACE_HOME="$HOME/.liferay/workspace" + +RELEASES_JSON_FILE="${LIFERAY_WORKSPACE_HOME}/releases.json" + _checkReleasesJsonFile() { local curl_cmd local etag_status_code - local releases_json_etag_file="$HOME/.liferay/workspace/releases-json.etag" + local releases_json_etag_file="${LIFERAY_WORKSPACE_HOME}/releases-json.etag" local releases_json_url="https://releases-cdn.liferay.com/releases.json" + if [[ ! -d "${LIFERAY_WORKSPACE_HOME}" ]]; then + mkdir -p "${LIFERAY_WORKSPACE_HOME}" + fi + curl_cmd=(curl --silent --output "${RELEASES_JSON_FILE}" --etag-save "${releases_json_etag_file}" "${releases_json_url}") if [[ ! -f "${RELEASES_JSON_FILE}" ]]; then @@ -220,8 +227,23 @@ _checkReleasesJsonFile() { # Helper functions to list information # -_listCommands() { - compgen -c | grep "^cmd_" | sed "s/^cmd_//g" +_listFunctions() { + local prefix="${1}" + + compgen -A function "${prefix}" +} + +_listPrefixedFunctions() { + local prefix="${1:?Prefix required}" + + _listFunctions "${prefix}" | sed "s/^${prefix}//g" +} + +_listPrivateCommands() { + _listPrefixedFunctions "_cmd_" +} +_listPublicCommands() { + _listPrefixedFunctions "cmd_" } _listReleases() { _checkReleasesJsonFile @@ -229,7 +251,7 @@ _listReleases() { jq '.[].releaseKey' -r "${RELEASES_JSON_FILE}" } _listRunningProjects() { - docker compose ls --format=json | jq -r '.[] | .ConfigFiles' | sed 's@,@\n@g' | grep compose-recipes | sed 's,/compose-recipes/.*,,g' + docker compose ls --format=json | jq -r '.[] | .ConfigFiles' | sed 's@,@\n@g' | grep compose-recipes | sed 's,/compose-recipes/.*,,g' | sort -u } _listWorktrees() { _git worktree list --porcelain | grep worktree | awk '{print $2}' @@ -242,12 +264,12 @@ _listWorktrees() { _getClosestCommand() { local command="${1}" - _listCommands | fzf --bind="load:accept" --exit-0 --height 30% --reverse --select-1 --query "${command}" + _listPublicCommands | fzf --bind="load:accept" --exit-0 --height 30% --reverse --select-1 --query "${command}" } _verifyCommand() { local command="${1}" - _listCommands | grep -q "^${command}$" + _listPublicCommands | grep -q "^${command}$" } # @@ -310,13 +332,13 @@ _cmd_commands() { _bold "Public Commands" echo - _listCommands + _listPublicCommands echo _bold "Private Commands" echo - compgen -c | grep "^_cmd_" | sed "s/^_cmd_//g" + _listPrivateCommands } _cmd_gw() { _checkCWDProject @@ -327,6 +349,9 @@ _cmd_gw() { ./gradlew "${@}" ) } +_cmd_fn() { + "${1}" "${@:2}" +} _cmd_list() { _listWorktrees } @@ -354,6 +379,9 @@ _cmd_setVersion() { # cmd_clean() { + _print_step "Removing manually deleted worktrees" + _git worktree prune + _checkCWDProject ( @@ -375,7 +403,7 @@ cmd_init() { local worktree_name if [[ -z "${ticket}" ]]; then - _prompt "LPP ticket number: " ticket + _prompt "Ticket number: " ticket fi _cancelIfEmpty "${ticket}"