Do you want to develop Liferay Portal themes without having to redeploy to see your modifications? Use Liferay Portal’s Developer Mode! In Developer Mode, all caches are removed, so any changes you make are visible right away. Also, you don’t have to reboot the server as often in Developer Mode.
How does Developer Mode let you see your changes more quickly? By default, Liferay Portal is optimized for performance. Developer mode optimizes your configuration for development instead. Here is a list of Developer Mode’s key behavior changes and the Portal Property override settings that trigger them (if applicable):
- CSS files are loaded individually rather than being combined and loaded as a single CSS file (
- Layout template caching is disabled (
- The server does not launch a browser when starting (
- FreeMarker Templates for themes and web content are not cached, so changes are applied immediately (via the system setting in your Liferay Portal instance).
Individual file loading of your styling and behaviors, combined with disabled caching for layout and FreeMarker templates, lets you see your changes more quickly.
These developer settings are defined in the
portal-developer.properties file. To use these settings, you can include them in your
portal-ext.properties file or copy them over to your
portal-ext.properties file and override specific properties as needed. These configurations are covered in this tutorial.
First, you can explore how it’s done in IDE.
Setting Developer Mode for Your Server in IDE
To enable Developer Mode for your server in IDE, follow these steps:
Double-click on your server in the Servers window and open the Liferay Launch section.
Select Custom Launch Settings and check the Use developer mode option.
Save the changes and start your server.
For Liferay Portal servers below version 6.2 (e.g., Liferay v6.1 CE Server, Liferay v6.0 CE Server), IDE enables Developer Mode by default. When starting your Liferay Portal server for the first time, it creates a
portal-ext.properties file in your server’s directory. This properties file contains the property setting
include-and-override=portal-developer.properties, which enables Developer Mode.
Most of the configuration is provided by the
portal-developer.properties file, but you still have to configure the FreeMarker template setting. Follow the steps in the Configuring FreeMarker System Settings section to configure the FreeMarker template cache.
If you’re not using IDE, manual configuration for Developer Mode is covered next.
Setting Developer Mode for Your Server Using portal-developer.properties
To set Developer Mode manually, you must point to
portal-developer.properties as shown in the last section. Add the
portal-ext.properties file to the root folder of your app server’s bundle and add the following line:
Developer Mode is enabled upon starting your app server.
portal-developer.properties provides the majority of the settings you’ll need for smooth development. To disable the cache for FreeMarker templates, you must update the System Setting covered in the next section.
Configuring FreeMarker System Settings
FreeMarker Templates for themes and web content are cached by default. Therefore, any changes you make to your FreeMarker theme templates aren’t immediately displayed. You can change this behavior through System Settings. Follow these steps:
Open the Control Panel and go to Configuration → System Settings.
Click the Foundation tab and select FreeMarker Engine.
By default, the Resource modification check (the time in milliseconds that the template is cached) is set to
60. Set this value to
0to disable caching.
false in your
portal.properties, or you can disable fast loading by setting the URL parameter
Great! You’ve set up your Liferay Portal server for Developer Mode. Now, when you modify your theme’s file directly in your bundle, you can see your changes applied immediately on redeploying your theme!