Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,8 @@ lec init # No args
lec init LPP-12345 # Pass in the LPP ticket number

lec init LPP-12345 dxp-2025.q3.0 # Pass in the LPP ticket number and the Liferay version

lec init LPP-12345 abc1prd # Pass in the LPP ticket number and the SaaS environment name
```

Start the workspace:
Expand Down
29 changes: 29 additions & 0 deletions buildSrc/src/main/groovy/docker-database-saas.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ ext {
return
}

File lcpJsonFile = new File(config.lxcRepositoryPath, "liferay/LCP.json")

if (!lcpJsonFile.exists()) {
println "Unable to copy configurations from LXC repository, because ${config.lxcRepositoryPath} is not the liferay-lxc repository"

return
}

File environmentFolder = null

if (config.lxcEnvironmentName == null) {
Expand Down Expand Up @@ -112,6 +120,27 @@ ext {
return
}

JsonSlurper jsonSlurper = new JsonSlurper()

Map<String, String> environmentVariables = jsonSlurper.parse(lcpJsonFile)["environments"][config.lxcEnvironmentName]

String jdbcURL = environmentVariables["LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_URL"]

if (jdbcURL != null && jdbcURL.startsWith("jdbc:postgresql://")) {
config.useDatabasePostgreSQL = true

updateGradleLocalProperties([
"lr.docker.environment.service.enabled[postgres]": "true"
])
}
else {
config.useDatabaseMySQL = true

updateGradleLocalProperties([
"lr.docker.environment.service.enabled[mysql]": "true"
])
}

if (!config.databasePartitioningEnabled) {
config.databasePartitioningEnabled = true

Expand Down
40 changes: 34 additions & 6 deletions scripts/cli/lec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ if [[ -z "${LEC_WORKSPACES_DIR}" ]]; then
LEC_WORKSPACES_DIR="${LEC_REPO_ROOT}/../lec-workspaces"
fi

if [ "" == "${LXC_REPOSITORY_PATH}" ] && [ -d "${HOME}/dev/projects/liferay-lxc" ]; then
LXC_REPOSITORY_PATH="${HOME}/dev/projects/liferay-lxc"
fi

#
# Git helper functions
#
Expand Down Expand Up @@ -280,6 +284,13 @@ _listReleases() {
_listRunningProjects() {
docker compose ls --format=json | jq -r '.[] | .ConfigFiles' | sed 's@,@\n@g' | grep compose-recipes | sed 's,/compose-recipes/.*,,g' | sort -u
}
_listSaaSEnvironments() {
if [ ! -d "${LXC_REPOSITORY_PATH}/automation/environment-descriptors/" ]; then
return 0
fi

ls -1 "${LXC_REPOSITORY_PATH}/automation/environment-descriptors/" | grep '\.json$' | sed 's/\.json$//g'
}
_listWorktrees() {
_git worktree list --porcelain | grep worktree | awk '{print $2}'
}
Expand Down Expand Up @@ -327,17 +338,26 @@ _getWorktreeDir() {
_listWorktrees | grep "/${worktree_name}$"
}
_selectLiferayRelease() {
_listReleases | _select "Choose a Liferay version"
(
_listReleases
_listSaaSEnvironments
) | fzf --height=50% --reverse
}
_selectWorktree() {
_listWorktrees | _select "Choose a project"
}
_verifyLiferayVersion() {
local liferay_version="${1}"

if ! _listReleases | grep -q "${liferay_version}"; then
_errorExit "'${liferay_version}' is not a valid Liferay version"
if test -f "${LXC_REPOSITORY_PATH}/automation/environment-descriptors/${liferay_version}.json"; then
return 0
fi

if _listReleases | grep -q "${liferay_version}"; then
return 0
fi

_errorExit "'${liferay_version}' is not a valid Liferay version"
}
_writeLiferayVersion() {
local worktree_dir="${1}"
Expand All @@ -346,10 +366,18 @@ _writeLiferayVersion() {
(
cd "${worktree_dir}" || exit

sed -E -i.bak "s/^liferay.workspace.product=.*$/liferay.workspace.product=${liferay_version}/g" gradle.properties
rm gradle.properties.bak
if [ -f "${LXC_REPOSITORY_PATH}/automation/environment-descriptors/${liferay_version}.json" ]; then
sed -E -i.bak "s/^#?lr.docker.environment.lxc.environment.name=.*$/lr.docker.environment.lxc.environment.name=${liferay_version}/g" gradle.properties
rm gradle.properties.bak

echo "Liferay version set to ${liferay_version} in gradle.properties"
echo "LXC environment set to ${liferay_version} in gradle.properties"
blade gw copyLiferayLXCRepositoryConfigurations
else
sed -E -i.bak "s/^liferay.workspace.product=.*$/liferay.workspace.product=${liferay_version}/g" gradle.properties
rm gradle.properties.bak

echo "Liferay version set to ${liferay_version} in gradle.properties"
fi
)
}

Expand Down