Introduction:-
OOTB Liferay IDE/SDK comes with ANT but Maven has some advantages over ANT. You may google more for the differences or a why?? to go for MAVEN.
Anyways, for Liferay we need to follow a bit out of the way procedure. Lets see, how it goes....
Pre-requisites:-
1. Download Liferay maven sdk zip (https://github.com/azzazzel/liferay-maven-sdk)
(1.1 Extract this
1.2 go to terminal/command prompt
1.3 liferay-maven-sdk> mvn install
1.4 liferay-maven-sdk> mvn archetype:generate)
2. Install maven on eclipse http://download.eclipse.org/technology/m2e/releases
Steps:-
1. Create a new Maven Project
2. Click Next
3. Select liferay-portlet-archetype for creating a portlet.
4. Set GroupId(your package), artifact Id(your portlet name), version(1.1) and package
5. Following is the project structure
6. Set values in demoMaven project pom.xml
<configuration>
<autoDeployDir>\home\priyanka\pfiles\bundles\deploy</autoDeployDir>
<appServerDeployDir>\home\priyanka\pfiles\bundles\tomcat-7.0.27\webapps</appServerDeployDir>
<appServerLibGlobalDir>\home\priyanka\pfiles\bundles\tomcat-7.0.27\lib\ext</appServerLibGlobalDir>
<appServerPortalDir>\home\priyanka\pfiles\bundles\tomcat-7.0.27\webapps\ROOT</appServerPortalDir>
<liferayVersion>6.1.1</liferayVersion>
<pluginType>portlet</pluginType>
</configuration>
Change the values with your existing configuration of portal.(This is the path to your liferay-portal)
7. In your pom.xml replace
${liferay.version} with your liferay version, I am using 6.1.1 so I replaced with the same. So, finally pom.xml looks something like the following
<?xml version="1.0"?>
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>me.pd.test.portlet</groupId>
<artifactId>demoMaven</artifactId>
<packaging>war</packaging>
<name>demoMaven Portlet</name>
<version>1.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>com.liferay.maven.plugins</groupId>
<artifactId>liferay-maven-plugin</artifactId>
<version>6.1.1</version>
<configuration>
<autoDeployDir>\home\priyanka\pfiles\bundles\deploy</autoDeployDir>
<appServerDeployDir>\home\priyanka\pfiles\bundles\tomcat-7.0.27\webapps</appServerDeployDir>
<appServerLibGlobalDir>\home\priyanka\pfiles\bundles\tomcat-7.0.27\lib\ext</appServerLibGlobalDir>
<appServerPortalDir>\home\priyanka\pfiles\bundles\tomcat-7.0.27\webapps\ROOT</appServerPortalDir>
<liferayVersion>6.1.1</liferayVersion>
<pluginType>portlet</pluginType>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-service</artifactId>
<version>6.1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-bridges</artifactId>
<version>6.1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-taglib</artifactId>
<version>6.1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-java</artifactId>
<version>6.1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.portlet</groupId>
<artifactId>portlet-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
8. Go to your command prompt or Terminal(Linux)
Type:-
mvn clean install liferay:deploy
Your first portlet is deployed with maven :)
OOTB Liferay IDE/SDK comes with ANT but Maven has some advantages over ANT. You may google more for the differences or a why?? to go for MAVEN.
Anyways, for Liferay we need to follow a bit out of the way procedure. Lets see, how it goes....
Pre-requisites:-
1. Download Liferay maven sdk zip (https://github.com/azzazzel/liferay-maven-sdk)
(1.1 Extract this
1.2 go to terminal/command prompt
1.3 liferay-maven-sdk> mvn install
1.4 liferay-maven-sdk> mvn archetype:generate)
2. Install maven on eclipse http://download.eclipse.org/technology/m2e/releases
Steps:-
1. Create a new Maven Project
2. Click Next
3. Select liferay-portlet-archetype for creating a portlet.
4. Set GroupId(your package), artifact Id(your portlet name), version(1.1) and package
5. Following is the project structure
6. Set values in demoMaven project pom.xml
<configuration>
<autoDeployDir>\home\priyanka\pfiles\bundles\deploy</autoDeployDir>
<appServerDeployDir>\home\priyanka\pfiles\bundles\tomcat-7.0.27\webapps</appServerDeployDir>
<appServerLibGlobalDir>\home\priyanka\pfiles\bundles\tomcat-7.0.27\lib\ext</appServerLibGlobalDir>
<appServerPortalDir>\home\priyanka\pfiles\bundles\tomcat-7.0.27\webapps\ROOT</appServerPortalDir>
<liferayVersion>6.1.1</liferayVersion>
<pluginType>portlet</pluginType>
</configuration>
Change the values with your existing configuration of portal.(This is the path to your liferay-portal)
7. In your pom.xml replace
${liferay.version} with your liferay version, I am using 6.1.1 so I replaced with the same. So, finally pom.xml looks something like the following
<?xml version="1.0"?>
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>me.pd.test.portlet</groupId>
<artifactId>demoMaven</artifactId>
<packaging>war</packaging>
<name>demoMaven Portlet</name>
<version>1.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>com.liferay.maven.plugins</groupId>
<artifactId>liferay-maven-plugin</artifactId>
<version>6.1.1</version>
<configuration>
<autoDeployDir>\home\priyanka\pfiles\bundles\deploy</autoDeployDir>
<appServerDeployDir>\home\priyanka\pfiles\bundles\tomcat-7.0.27\webapps</appServerDeployDir>
<appServerLibGlobalDir>\home\priyanka\pfiles\bundles\tomcat-7.0.27\lib\ext</appServerLibGlobalDir>
<appServerPortalDir>\home\priyanka\pfiles\bundles\tomcat-7.0.27\webapps\ROOT</appServerPortalDir>
<liferayVersion>6.1.1</liferayVersion>
<pluginType>portlet</pluginType>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-service</artifactId>
<version>6.1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-bridges</artifactId>
<version>6.1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-taglib</artifactId>
<version>6.1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-java</artifactId>
<version>6.1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.portlet</groupId>
<artifactId>portlet-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
8. Go to your command prompt or Terminal(Linux)
Type:-
mvn clean install liferay:deploy
Your first portlet is deployed with maven :)
No comments:
Post a Comment