Introduction:
Starting with maven brings another pivotal feature implementation i.e. Hooks. Let us do with the easier Login-hook and change the login.jsp
Prerequisites:-
1. Download maven-support.zip from here.
In your command prompt/Terminal window, type mvn archetype:generate
2. Install maven on eclipse http://m2eclipse.sonatype.org/sites/m2e
Steps:-
1. Create a new Maven Project
2. Click Next
3.Select liferay-hook-archetype for creating a portlet.
4. Set GroupId(your package), artifact Id(your hook name), version(1.1) and package
5. Following is the project structure
6. Inside /src/main/webapp/WEB-INF/liferay-hook.xml add the following:-
<hook>
<custom-jsp-dir>/META-INF/custom_jsps</custom-jsp-dir>
</hook>
7. Copy the login.jsp following the folder structure, and make the changes in login.jsp as per your requirement.
8. 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>mylogin</artifactId>
<packaging>war</packaging>
<name>mylogin Hook</name>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>com.liferay.maven.plugins</groupId>
<artifactId>liferay-maven-plugin</artifactId>
<version>${liferay.maven.plugin.version}</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>hook</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-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>
9. Go to your command prompt or Terminal(Linux)
Type:-
mvn clean install liferay:deploy
Your hook is finally deployed successfully :)
Starting with maven brings another pivotal feature implementation i.e. Hooks. Let us do with the easier Login-hook and change the login.jsp
Prerequisites:-
1. Download maven-support.zip from here.
In your command prompt/Terminal window, type mvn archetype:generate
2. Install maven on eclipse http://m2eclipse.sonatype.org/sites/m2e
Steps:-
1. Create a new Maven Project
2. Click Next
3.Select liferay-hook-archetype for creating a portlet.
4. Set GroupId(your package), artifact Id(your hook name), version(1.1) and package
5. Following is the project structure
6. Inside /src/main/webapp/WEB-INF/liferay-hook.xml add the following:-
<hook>
<custom-jsp-dir>/META-INF/custom_jsps</custom-jsp-dir>
</hook>
7. Copy the login.jsp following the folder structure, and make the changes in login.jsp as per your requirement.
8. 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>mylogin</artifactId>
<packaging>war</packaging>
<name>mylogin Hook</name>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>com.liferay.maven.plugins</groupId>
<artifactId>liferay-maven-plugin</artifactId>
<version>${liferay.maven.plugin.version}</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>hook</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-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>
9. Go to your command prompt or Terminal(Linux)
Type:-
mvn clean install liferay:deploy
Your hook is finally deployed successfully :)
No comments:
Post a Comment