Lukas Grygar's

Personal enterprise Java web development blog.

Liferay Theme: How to put version information from Maven's POM.xml to header meta tag

In case you developing Liferay 6.2 Theme for 3rd party it’s useful to check if correct version of theme is deployed in case you want to be sure if everything works correctly and correct version is deployed.

Directory structure of files mentioned in this tutorial is following:

fooBar-theme
├── src/main/resources
|   └── portal.properties
├── src
|   └── main
|   	└── webapp
|   	    └── templates
|  	            └── portal_normal.vm
└─ pom.xml

First create file portal.properties in src/main/resources and put property theme.version and assign value ${project.version} to it:

portal.properties

theme.version=${project.version}

Than put version tag to POM.xml and enable filtering for directory /src/main/resources (due to fact that file portal.properties resides here):

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

	<!-- rest of POM ommited -->

	<version>1.0.1-SNAPSHOT</version>

	<!-- rest of POM ommited -->

	<build>

		<!-- rest of POM ommited -->

        <resources>

			<!-- rest of POM ommited -->

	        <resource>
	          <directory>src/main/resources</directory>
	          <filtering>true</filtering>
	        </resource>

			<!-- rest of POM ommited -->

        </resources> 

		<!-- rest of POM ommited -->

    </build>

    <!-- rest of POM ommited -->

</project>

Finally put meta tag with name theme-version to portal_normal.vm and load content through propsUtil.get():

portal_normal.vm

1 <head>
2 <!-- rest of head ommited -->
3 <meta name="theme-version" content="$propsUtil.get("theme.version")" />
4 <!-- rest of head ommited -->
5 </head>

During build Maven injects that version and after theme deployment you should be able to read theme version specified at POM.xml in generated HTML code.


Tags: liferay  liferay-portal 

Share on: Twitter  Facebook  Google+ 


Previous post: Liferay Theme localization without Hook

Next post: Liferay Portlet: How to get version information from Maven's POM.xml

Related posts: