Mastering Liferay Workspaces and Tooling

Course Overview

Managing Workspace Environment Configurations

Liferay projects often require deployment across multiple environments that require their own configurations (e.g., dev, uat, prod). The configs folder within a Liferay Workspace is a dedicated directory for managing and storing configuration files for different environments in your Liferay project. It provides a structured approach to organizing environment-specific configurations, such as database connections, custom properties, and server settings. This enhances maintainability and enables teams to share configurations through source control.

The configs folder is a dedicated directory for managing and storing configuration files for different environments in your Liferay project.

Why Use the Configs Folder?

Leveraging the configs folder offers several key benefits for your Liferay projects:

Centralized Configuration Management

As your project grows, managing environment-specific configurations can become complex. Instead of scattering configurations across multiple files or hard-coding them into your project, the configs folder centralizes everything, simplifying management, updates, and troubleshooting. This minimizes the risk of inconsistencies and errors that can arise from misconfigurations in files like portal-ext.properties, database settings, or custom OSGi configurations. Also, by storing configurations in your workspace, you can track changes using version control (Git) to achieve consistency across all deployments.

Automated Configuration Switching

Liferay’s build process automatically detects which configuration files to use based on the target deployment environment. You can pre-configure the environment in your gradle.properties file or pass it as an argument to the Gradle task during execution (e.g., ./gradlew initBundle -Pliferay.workspace.environment=prd).

Separation of Concerns

By separating configuration from code, you maintain a clean and flexible codebase. Developers can focus on application logic without being burdened by environment-specific details. This also improves collaboration, as environment configurations can be adjusted independently without affecting the core code.

How to Use the Configs Folder

Liferay workspaces include several environments by default within the configs folder.

configs  
/common Store configurations shared by all environments.
/dev Store development environment configurations.
/local Store configurations for the developer's local machine.
/prd Store production environment configurations.
/uat Store user acceptance testing environment configurations.

 

You can add more environment folders as needed. For example, Clarity needs an additional systems integration testing (sit) environment due to the number of disparate systems they need to integrate. Clarity can add a sit directory under configs for storing its environment specific configurations.

Each configs sub-directory represents the environment’s LIFERAY_HOME, which is the root directory where the Liferay bundle is unpacked. Replicating the bundle's directory structure and file names enables you to add or override files within the bundle itself.

You can statically set the target environment for your server build in the gradle.properties file. Use the liferay.workspace.environment property and set its value to the name of the corresponding environment directory. By default, this property is set to local. As previously mentioned, you can dynamically specify the environment as a Gradle task argument during execution (e.g., ./gradlew initBundle -Pliferay.workspace.environment=prd).

Conclusion

The configs folder in your Liferay Workspace is a valuable tool for managing environment-specific configurations, ensuring consistency, and streamlining deployments. Next, you'll apply what you've learned with some hands-on exercises.

  • Why Use the Configs Folder?

  • How to Use the Configs Folder

  • Conclusion

Loading Knowledge

Capabilities

Product

Education

Contact Us

Connect

Powered by Liferay
© 2024 Liferay Inc. All Rights Reserved • Privacy Policy