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 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 the set of liferay applications and modules. Internally it uses Blade CLI and Gradle (by default) to build an 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 other in more controlled manner. If you are new to Liferay 7 (DXP), I would recommend to read below articles. I have mentioned few essential steps that you need to follow before you start any development activity in Liferay 7 (DXP).
You need to install Liferay 7 server and make the development environment ready before move further. Above two links will help you in this regards. If you already installed the Liferay 7 server and completed development environment setup then you are ready for the next step of creating Liferay workspace.
We will first see how to create Liferay workspce in Liferay IDE. Since it is an eclipse based IDE, it has Liferay workspace perspective as a part of Liferay plugin.
Start Liferay IDE (or developer studio). By default it opens the Liferay Workspace perspective. If not, you can set it with 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 below screenshot
- Select it and click on Open button to activate Liferay workspace perspective.
Liferay workspace (eclipse) perspective
Once you select this perspective, Liferay IDE looks like below screenshot.
Let us understand the main area of Liferay workspace perspective as below.
Project Explorer :– This is the area where Liferay workspace is visible with 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 set of gradle task to perform various operation like clean, build, deploy etc in hierarchical manner. If you execute particular task at parent level, it will execute same task for all children.
Gradle Execution :- Whenever you execute any task for module, this section shows the execution stack.
Create Liferay workspace
After getting basic understanding of Liferay 7 workspace, let us create it. Below are the steps
- Right click at Package Explorer section and choose New –> Liferay Workspace Project option from context menu. This will open following window.
- There are few inputs you need to give in this form. Below are the details.
- Project Name :- Every single thing that we creates in eclipse is in form of eclipse project. In our case, we are going to create eclipse project of type Liferay workspace. You need to give name of the project in Project name field, which is nothing but your Liferay Workspace name. Give some appropriate name like test-ws.
- Use default location :- This checkbox allows you to set the location of Liferay workspace project. By default it is selected and creates the Liferay workspace withing eclipse workspace you are working in. For custom location, just uncheck it and give the path to Location field where you want to place your Liferay workspce.
- 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. Therefor you will see two options as 7.0 and 7.1. Choose appropriate version. I am keeping it 7.1 because I already configured it.
Now click on 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 which are required to start work with it.
Liferay workspace structure
Once created, you will see the project structure of Liferay workspace as per 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 creates any new OSGI modules, it resides in this folder.
- themes folder :- Themes in Liferay 7 can be in form of tradition plugin so they reside in this folder. Liferay does not support OSGI module for theme.
- gradle.properties :- This file contains all gradle specific properties like, liferay server path in local, memory parameters etc.
If you look at Gradle Task section, you will see workspace specific task as per 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 workspace.
Kudos …!!!. Basic work for setting up Liferay workspace is done at this moment. However you need to make sure the JDK folder is correctly configured with Installed JRE variable in Liferay IDE. By default it is pointing to JRE. You need to change it to JDK folder. You can refer below steps for the same.
- Open Windows menu and click on Preferences. Find Java–>Installed JREs option (scroll if required) as per below screenshot.
- By default it showing JRE in JRE home variable. Select it and click on Edit button. It shows below screen.
- Click on Directory button and point the JDK folder.
- Click on OK and then Finish button. You will see the Installed JREs path is updated. Click on Apply and Close button.
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 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 to configure existing Liferay server within Liferay IDE. Below are the steps.
- Right click in Server section of the eclipse workspace and choose New –> Server from context menu as per below screenshot.
- This will open New Server configuration wizard as per below screenshot.
- Choose Liferay. Inc –> Liferay 7.x and click on Next button. This will open following screen.
- Point your Liferay 7 server directory in Liferay Portal Bundle Directory field by clicking Browse button.
- Click on Finish and you will see Liferay 7 server in Server section of Liferay IDE as per below screenshot.
You can now start (normal or debug mode) and stop the server from Liferay IDE.
Great work …!!! Finally Liferay workspace is ready and you are now ready to create various modules and application.