Liferay workspace is used to group various Liferay 7 specific modules and applications at one single place. It is first setup a Liferay developer should know before starting development in Liferay 7
In the previous post, we have seen how to setup Liferay 7 development environment. Starting from version 7, Liferay brings the concept of workspace. You can relate it with eclipse workspace. Liferay workspace is the place where you can create and manage all your Liferay 7 specific development artifacts. In other words, it holds a set of Liferay applications and modules. Internally it uses Blade CLI and Gradle (by default) to build and deploy Liferay bundles (modules) and WAR files.
The benefit of Liferay workspace is, you can move the source code from one platform or environment to another in a more controlled manner. If you are new to Liferay 7 (DXP), I would recommend reading the below articles. I have mentioned a few essential steps that you need to follow before starting any development activity in Liferay 7 (DXP).
You need to install Liferay 7 server and make the development environment ready before move further. The above two links will help you in this regard. If you already installed the Liferay 7 server and completed the development environment setup, then you are ready for the next step of creating the Liferay workspace.
Liferay Workspace
We will first see how to create a Liferay workspace in Liferay IDE. Since it is an eclipse-based IDE, it has a Liferay workspace perspective as a part of the Liferay plugin.
Start Liferay IDE (or developer studio). By default, it opens the Liferay Workspace perspective. If not, you can set it with the below steps.
- Open Window menu and click on Perspective –> Open Perspective –> Others. It opens Perspective windows in eclipse.
- Scroll down and check the entry for Liferay Workspace (default) perspective as per the below screenshot
- Select it and click on the Open button to activate the Liferay workspace perspective.
Liferay workspace (eclipse) perspective
Once you select this perspective, Liferay IDE looks like the below screenshot.
Let us understand the main area of Liferay’s workspace perspective as below.
Project Explorer:– This is the area where Liferay workspace is visible with a tree-like structure, showing all development artifacts. You can change project explorer, package explorer, or navigator based on your preference to see the workspace.
Server Window:- This section shows the Liferay 7 server that you have integrated into Liferay IDE. We will see how to configure this in a short while.
Gradle Task:- For each OSGI module, this section shows a set of Gradle tasks to perform various operations like clean, build, deploy, etc., in a hierarchical manner. If you execute a particular task at the parent level, it will execute the same task for all children.
Gradle Execution:- Whenever you execute any task for a module, this section shows the execution stack.
Create Liferay workspace
After getting a basic understanding of the Liferay 7 workspace, let us create it. Below are the steps
- Right-click at the Package Explorer section and choose the New –> Liferay Workspace Project option from the context menu. This will open the following window.
- There are few inputs you need to give in this form. Below are the details.
- Project Name:- Every single thing that we create in eclipse is in the form of an eclipse project. In our case, we are going to create an eclipse project of type Liferay workspace. You need to give the name of the project in the Project name field, which is nothing but your Liferay Workspace name. Give some appropriate names like test-ws.
- Use default location:- This checkbox allows you to set the location of the Liferay workspace project. By default, it is selected and creates the Liferay workspace within the eclipse workspace you are working in. For the custom location, just uncheck it and give the path to the Location field where you want to place your Liferay workspace.
- Bundle Type:- Liferay 7 allows you to build modules with either Gradle(default) or Maven. Keep the Gradle option selected.
- Liferay version:- At the time of writing this, the current version of Liferay is 7.1. Therefore you will see two options as 7.0 and 7.1. Choose an appropriate version. I am keeping it 7.1 because I already configured it.
Now click on the Finish button to create Liferay 7 workspace. If you are creating it first time, this may take some time (based on your internet connectivity and system configuration) because Liferay IDE will download all necessary artifacts required to start work with it.
Liferay workspace structure
Once created, you will see the project structure of the Liferay workspace as per the below screenshot.
Let us get some brief about it. At this point, we will only see the details which are important to start the development with Liferay 7
- modules folder:- Whenever you create any new OSGI modules, it resides in this folder.
- themes folder:- Themes in Liferay 7 can be in the form of a traditional plugin, so they reside in this folder. Liferay does not support the OSGI module for the theme.
- gradle.properties:- This file contains all Gradle specific properties like Liferay server path in local, memory parameters, etc.
If you look at the Gradle Task section, you will see workspace-specific tasks as per the below screenshot.
All modules and plugins are visible here as a tree structure. Since we have not created any module yet, it only shows the Gradle tasks for the workspace.
Kudos …!!!. Basic work for setting up the Liferay workspace is done at this moment. However, you need to make sure the JDK folder is correctly configured with the Installed JRE variable in Liferay IDE. By default, it is pointing to JRE. You need to change it to the JDK folder. You can refer to the below steps for the same.
- Open the Windows menu and click on Preferences. Find Java–>Installed JREs option (scroll if required) as per the below screenshot.
- By default, it showing JRE in the JRE home variable. Select it and click on the Edit button. It shows below screen.
- Click on the Directory button and point to the JDK folder.
- Click on OK and then the Finish button. You will see the Installed JREs path is updated. Click on Apply and Close button.
This is a one-time setting, but without doing it, you will get errors like Could not find tools.jar while creating or building the module as per the below screenshot.
Configure Liferay 7 server in Liferay IDE
The next thing is to plug the Liferay server in Liferay IDE. There are two options to work with Liferay IDE and Liferay server.
Independent Liferay server
In this mode, both Liferay IDE and Liferay server runs separately. We saw how to install the Liferay server independently in my previous blog on Liferay 7 Installation. If required, you can start the Liferay server in debug mode separately.
Liferay server withing Liferay IDE
Liferay IDE allows configuring the existing Liferay server within Liferay IDE. Below are the steps.
- Right-click in the Server section of the eclipse workspace and choose New –> Server from the context menu as per the below screenshot.
- This will open the New Server configuration wizard as per the below screenshot.
- Choose Liferay. Inc –> Liferay 7.x and click on the Next button. This will open the following screen.
- Point your Liferay 7 server directory in the Liferay Portal Bundle Directory field by clicking the Browse button.
- Click on Finish, and you will see Liferay 7 server in the Server section of Liferay IDE as per the below screenshot.
You can now start (normal or debug mode) and stop the server from Liferay IDE.
Great work …!!! Finally, the Liferay workspace is ready, and you are now ready to create various modules and applications.
Hi,
After the passage “Choose Liferay. Inc –> Liferay 7.x and click on the Next button. ”
there is no “Liferay Portal Bundle Directory”
but “Modify the resources that are configured on the server”.
what’s the problem?