Showing posts with label liferay IDE. Show all posts
Showing posts with label liferay IDE. Show all posts

Wednesday, December 10, 2014

Liferay Hook Plugin Development with Liferay IDE

Liferay hook Plugin is one of the Plugin type in liferay to customize liferay portal.
Hook have many capabilities so that we can customize liferay portal and its hot deployable plugins. Liferay Plugins SDK have support to develop hook plugins.

Please follow the articles before start this development.



We have many choices to start liferay development




In this article we are going to see hook development with Liferay IDE. Before start development we need to be ready with development environment that is using Liferay IDE.

Please follow the below articles to setup Liferay Development Environment with Liferay IDE



Liferay Hook Plugin Project Creation

Start your eclipse

go to File-->New-->Liferay Plugin Project

Once we click on new project it will open New Liferay Project Plugin Dialog window

Provides the Information as follows

Project Name: Sample

Project Display Name: Sample Hook

Check the Use Default Location Check box.

Build Type: ANT

Plugins SDK: Select your Plugins SDK( you already configured this when you setup development environment)

Liferay Runtime: Select your run time ( you already configured this when you setup development environment)

Plugin Type: Hook

The following screen shows the New Liferay Project Dialog



Once you fill the all the above information then click on Finish button then your Sample-hook project will be created.

The following screen shows Sample-hook project in the project explorer


Note:

Project Name always appended with Plugin type when we create any liferay project. In our case we just given Sample but finally project will be created with name Sample-hook. Now we just created Liferay Hook project and its just have project skeleton.

Deployment of Hook Plugin

As soon as we created hook project then respective build file will be appeared in the Eclipse ANT view. There we can see many ANT targets. Simply we have to double click on deploy target or we can simply double click on Project Name in the ANT view then it will execute deploy target then hook Plugin will be deployed into server. deploy is the default ant target for hook Plugin.

The following screen shows sample-hook ant targets in the Eclipse ANT view


Once we deploy the hook Plugin then we can see following message in server log view. When we see below message then hook is successfully deployed.

10:11:20,647 INFO [localhost-startStop-2][HookHotDeployListener:687] Registering hook for Sample-hook
10:11:20,651 INFO [localhost-startStop-2][HookHotDeployListener:814] Hook for Sample-hook is available for use

Note:

In General ant deploy is target for deploy the hook project.

Each liferay hook Plugin project have it own project ANT build file called build.xml in the root directory of project there all build process will be defined.

Anatomy of the Liferay Hook Project

When we created hook plugin through Liferay IDE it will create hook project with all required configuration files and its folder sturcture from here we can start our development as for our needs.

The following is general liferay hook plugin files and its structure.

Sample-hook/
   docroot/WEB-INF/src/
   docroot/
      META-INF/
        MANIFEST.MF
     WEB-INF/
       lib/
       liferay-hook.xml
       liferay-plugin-package.properties
       web.xml
build.xml

The following is Liferay Hook Project In the Liferay IDE project explorer


docroot/WEB-INF/src/ :

consist all Java source files and related resource files such as language properties and portal properties.

lib/ :

consist required libraries for project.

liferay-hook.xml :

This is hook configuration file and its consist all predefined configuration tags and it will be available in liferay-hook_6_x_x.dtd file. Here we will define what we should customize in the portal.

A sample “liferay-hook.xml ” with some configuration


liferay-plugin-package.properties :

its common to all liferay plugins projects and here we will defined all properties related to project such as build number, version ant many which we can find from liferay-plugin-package_6_2_0.dtd file.

Example “liferay-plugin-package.properties” file


web.xml :

Its general deployment description for liferay hook project.

buil.xml:

This is ant build file to defined project build process its internally called another build files from plugins SDK to provide different ANT targets.

Example build.xml file as Follows



Liferay Hook Project Development with ANT+Plugins SDK

In the above we have created liferay hook project using Liferay IDE now we will create same project with ANT command line interface.

Liferay Plugins SDK provides ANT command line interface to create liferay Plugin projects.

Before start this we need to be ready with Liferay Plugins SDK+ANT development environment.


Once you ready with Plugins SDK+ANT environment then open command prompt or Linux terminal based on your Operating System.

From command prompt/terminal navigate to hooks directory( /liferay-plugins-sdk-6.2/hooks )

Now issue the following command

Linux and Mac OS X

./create.sh Sample "Sample"

In Windows

create.bat Sample "Sample"

A BUILD SUCCESSFUL message from ANT tells you there’s a new folder named Sample-hook inside the Plugins SDK’s hooks folder.

Project Name always appended with Plugin type when create any liferay project. In our case we just given Sample but finally project will be created with name Sample-hook

Once project is created then navigate to project root directory(/liferay-plugins-sdk-6.2/hooks/Sample-hook) then issue following ANT target then project will be deployed in the server.

ant deploy

Once we deploy the hook then we can see following message ,then hook is successfully deployed.

Hook for Sample-hook is available for use

Note:

well we have successfully created liferay hook Plugin project and here still we did not customize anything of portal. We will see how to customize liferay portal with this hook project in future articles. We simply do some configuration in liferay-hook.xml then it will change the portal behavior as for our need.

Follow the below articles to know more about Different Liferay Hook Plugins


Author

Saturday, November 22, 2014

Liferay Plugins Development with MAVEN


Liferay Offers many ways to develop Plugin applications development we already much aware of Liferay IDE and ANT based plugins development



Liferay plugins development with MAVEN is also great choice for liferay developers.

What is MAVEN?

MAVEN is project build tool like ANT but its has more features than ANT when we build projects using MAVEN.

Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information.


Each Maven project consist pom.xml in project root directory where we will defined project build process.

POM is project object model is one of the build process system which describes about software project and POM will be specified as xml tag notation in pom.xml file.

pom.xml is blueprint of the project and it describes your project’s directories, required plugins, build sequence, and dependencies. The POM is your project’s sole descriptive declaration. Once you create the pom.xml file and invoke the build process.

Entire project structure defined in pom.xml so that we can manage entire project from single point and it is easy when we compare with ANT because ANT build process will be defined in different build.xml files. MAVEN projects are very easy to understand by developers

Maven provides an easy way to share artifacts (e.g., JARs, WARs, etc.) across projects via public repositories.

Liferay plugins SDK provides project templates to build sample Plugin applications in the same way Liferay provides maven archetypes from which we can create different sample liferay plugins applications.

Archetypes are the template of project structure and it consist of all required configurations,its files and directory structure.

We can have different archetypes like spring archetypes,struts archetypes and web application archetypes from this we can create basic project structure from there we can start development.

Same way liferay also have created different archetypes for each Plugin type so that we can create basic Plugin projects very easy.

Liferay Plugin Development with MAVEN

The following are are the required steps

Install JAVA
Install MAVEN
Install Liferay Portal Server Bundle
Install Liferay MAVEN Archetypes
Download Eclipse+Liferay IDE
Create Liferay Plugin Maven Project from Liferay IDE

Install JAVA

Liferay Java based portal so first we need to install Java in our machine download JDK 1.6 or later version and install.

we need to set important environment variables such as JAVA_HOME and need to edit path system variable and add java bin path(;%JAVA_HOME%/bin;). We need Java 6.0 JRE or greater.

Java Installation follow below link look into section “Install JDK and setting required environment variables (JAVA_HOME, path)


Install MAVEN

We are using MAVEN based project building so first we need install MAVEN in machine and we also need to set environment variable like MAVEN_HOME/M2_HOME and edit the path then append MAVEN bin path.

Install MAVEN in Windows.

Download latest version of MAVEN archive file from apache maven download site


Download Maven 3.2.3 (Binary zip) archive file from above link

Extract zip file in any of desired location assume we have extracted in C drive then our maven home path will be C:\apache-maven-3.2.3

Now need to add M2_HOME and MAVEN_HOME system variables in the Windows environment, and point it to your Maven folder (C:\apache-maven-3.2.3)

Select Start, then right-select Computer --> Properties.

In the Advanced tab, click Environment Variables….

In the System variables section, click New

variable : M2_HOME

variable : MAVEN_HOME

Once we created two maven environment variables now we need to edit windows PATH variable then append Maven bin folder like ;%M2_HOME%\bin; so that you can run the Maven’s command everywhere.

In the System variables section, select your PATH variable and click Edit….

Append ;%M2_HOME%\bin; end of the existed path.

Now open windows command prompt then type following command then will shows maven version message otherwise there is problem in installation so need to recheck all steps.

mvn –version

Note:

semicolon in the path will separate the different path values so we should not forget to use semicolon.

Install MAVEN in Ubuntu

Open Ubuntu terminal

Run command sudo apt-get install maven, to install the latest Apache Maven.

It will take time to install all maven packages once it successfully done Run command mvn -version to verify your installation.

Manual Installation in Linux

Go apache MAVEN download site and download apache-maven-3.2.3-bin.tar.gz archive file


Extract in your desired location assume in opt directory then maven home path will be /opt/apache-maven-3.2.3

Now we need to configure maven environment variables in bash.bashrc or “/etc/profile”

bash.bashrc file will be available in /etc/bash.bashrc folder open in editor and add following configurations.

M2_HOME=/opt/apache-maven-3.2.3
PATH=$PATH:$M2_HOME/bin
export M2_HOME
export PATH

Run command mvn -version in the terminal to verify your installation

Install Liferay Portal Server Bundle

First we need to download portal server bundle based on developer choice. Once we downloaded bundle archive file then extract it in you desired location then you can see portal server bundle that consist application server with deployed liferay portal.


Liferay Portal Server is actual environment to run liferay Plugin applications. Liferay Portal Run time come up with different application servers such as tomcat,jboss,glashfish, jetty, geromino, JOnAS and resin.

Liferay provided these run time bundle with different server so that we can use any one based on developer choice.

Assume we will use tomcat bundle so download liferay-portal-tomcat-6.2-ce-ga2.zip from above location.

Now extract zip file in of your desired location now we are ready with liferay portal tomcat server.

Liferay Server Bundle Consist Application server and Deployed Liferay Portal Application. When we observed server deployment directory(for tomcat/webapps) we can see deployed Liferay Portal application with name ROOT.

Install Liferay MAVEN Archetypes

We are developing plugins with maven so we need to install liferay maven archetypes. Liferay maven archetypes are like project templates consist all required configurations and its files.

Download Liferay Portal Maven archive file(liferay-portal-maven-6.2-ce-ga2.zip) from following location


Now extract file on any of your desired location now we need to install liferay maven archetypes.

To install maven archetypes first we need to install ANT tool in our machine because maven archetypes used ANT build mechanism that is why we should install ANT tool

Install maven archetypes is nothing but we will place all requires liferay maven plugins and jar files in the local maven repositories that is (${USER_HOME}/.m2/repository)

Install ANT

Go to Apache ant site and download latest ANT (.zip archive: apache-ant-1.9.4-bin.zip)


Once you downloaded zip file extract in your desired location and we need to set ANT system environment variable in our machine.

We need to create ANT_HOME and we need to append ANT bin path in “path” environment variable.

Set ANT Environment Variable in Linux

Assume We have extracted ANT in the location “/opt/apache-ant-1.9.4”
Now ANT_HOME is “/opt/apache-ant-1.9.4” and ANT bin path is “$ ANT_HOME/bin”

Generally in the Linux we will use “.profile” or “bash.bashrc” file to set all environment variables. Now open .bash_profile file in editor and add following configuration then save it.

export ANT_HOME=/opt/apache-ant-1.9.4
export PATH=$PATH:$ANT_HOME/bin

Now open Linux Terminal type “ant -version” then it show ant version now you have successfully installed ANT.

Set ANT Environment Variable in Windows

Select Start, then right-select Computer --> Properties.

In the Advanced tab, click Environment Variables.

In the System variables section, click New

Set the ANT_HOME variable:

Variable name: ANT_HOME
Variable value: [Ant installation path] (e.g., C:\apache-ant-[version])

Click OK.

Also in the System variables section, select your path variable and click Edit….

Insert ;%ANT_HOME%\bin; end of the existed path value and click OK.

Click OK to close all system property windows.

Open a new command prompt “ant -version” then it show ant version now you have successfully installed ANT.

Now we are ready with ANT tool

Now Install Liferay MAVEN Archetypes into Local Maven Repository(${USER_HOME}/.m2/repository)

Open command prompt/terminal based on your OS issue the following command
Navigate to liferay-portal-maven-6.2-ce-ga2 then issue following command

ant install

Console shows output from the artifacts being installed from the Liferay Maven package into your local repository, typically located in your ${USER_HOME}/.m2/repository directory. Local repository now contains the Liferay artifacts required to build Liferay plugins

Download Eclipse+Liferay IDE

Well as of now we are ready with MAVEN archetypes installed in maven local repository and Liferay Portal Server now we need a development IDE to create Liferay MAVEN Project.

Generally we need eclipse , Liferay IDE ,MAVEN Eclipse Plugin,Liferay IDE MAVEN Plugin.

The following are the required eclipse plugins to support Liferay MAVEN Environment in Eclipse.

m2e-core (Maven integration for Eclipse)
m2e-wtp (Maven integration for WTP)
m2e-liferay plugin

All together will be available in single package when we download Eclipse Liferay IDE from Liferay downloads.

Go through following link


Select Other download drop-down select Eclipse Luna + Liferay IDE 2.2.0-ga1 option based on your OS and its Bits

Now extract archive file in desired location then you can see root directory that is eclipse if you go to root directory then you can see eclipse icon when we double click on icon then eclipse will be started.

Create Liferay Plugin Maven Project from Liferay IDE

before start development now we will notice following things

Assume as follows

Create directory give name LiferayMaven in “/opt” then workspace path /opt/ LiferayMaven

Auto Deploy Directory: “/opt/LiferayMaven/liferay-portal-6.2-ce-ga2/deploy ”

App Server Deploy Directory:”/opt/LiferayMaven/liferay-portal-6.2-ce-ga2/tomcat-7.0.42/webapps ”

App Server Lib Global Directory:”/opt/LiferayMaven/liferay-portal-6.2-ce-ga2/tomcat-7.0.42/lib/ext ”

App Server Portal Directory:”/opt/LiferayMaven/liferay-portal-6.2-ce-ga2/tomcat-7.0.42/webapps/ROOT ”

Liferay Version: 6.2.1

Start eclipse and select LiferayMaven is default work space.

Configure Liferay Portal Run Time In Liferay IDE

Eclipse Window → Preferences → Server → Runtime Environments.

Click Add to add a new Liferay runtime; find Liferay v6.2 (Tomcat 7) under the Liferay, Inc. category and click Next.

Click Browse and select your liferay-portal-6.2.x/tomcat-7.x (/opt/LiferayMaven/liferay-portal-6.2-ce-ga2/tomcat-7.0.42)directory.

Select Run Time JRE
Click Finish; you should see your Liferay portal runtime listed in Preferences → Server → Runtime Environments.
Click OK to save your runtime preferences

Create Liferay Plugin Maven Project

Go liferay IDE icon and Click on “Create New Liferay Plugin Project

Now it will launch Liferay Plugin Project Dialog window

Now fill all the fileds with appropriate values as follows

Project Name: liferay-sample-portlet

Project Display Name : Liferay Sample Portlet

Tick the check box “use default location” for Location

Build Type: Maven(liferay-maven-plugin)

Artifact version: keep default one

Gropuid: com.liferay.sample

Active Profile:

Click the icon “Create New Maven Profile Based on Liferay Run Time

it will open another dialog window ask information as follows
Liferay Run Time: Liferay v6.2 CE(Tomcat)
Liferay Version: 6.2.1
Check the profile location radio button as “project pom.xml

The following is Maven Profile Dialog


Then click on OK it will create maven profile with given values in project pom.xml

Now finally Liferay Plugin Project Dialog Look like as follows after fill all the thing



Now click on Next then you can move to next step there check the radio button Liferay MVC portlet then click on finish


Once we finish then it will prompt another Liferay Portlet dialog window and fill the details as follows

source folder: use default
check the Create New Portlet Radio button
Portlet class: you choice
Java Package : your choice
Super Class: MVC portlet


Once we provided the information click on finish button then Plugin portlet project will be created.

The following is created Liferay Maven Plugin Portlet Project




In the project explorer you can see the project and every maven project have one xml file called pom.xml file there all build process will be defined.

Now click on pom.xml file then you can see default all build configuration like plugins definitions, configuration and dependencies information.

Now do the following changes in project pom.xml file

Comment/remove following lines

<execution>
<phase>generate-sources</phase>
<goals>
<goal>build-css</goal>
</goals>
</execution>

Find the following configuration

<configuration>
<autoDeployDir>${liferay.auto.deploy.dir}</autoDeployDir>
<appServerDeployDir>${liferay.app.server.deploy.dir}</appServerDeployDir>
<appServerLibGlobalDir>${liferay.app.server.lib.global.dir}</appServerLibGlobalDir>
<appServerPortalDir>${liferay.app.server.portal.dir}</appServerPortalDir>
<liferayVersion>${liferay.version}</liferayVersion>
<pluginType>portlet</pluginType>
</configuration>

Now replace above configuration with below configuration

<configuration>
<autoDeployDir>/opt/LiferayMaven/liferay-portal-6.2-ce-ga2/deploy</autoDeployDir>
<appServerDeployDir>/opt/LiferayMaven/liferay-portal-6.2-ce-ga2/tomcat-7.0.42/webapps</appServerDeployDir>
<appServerLibGlobalDir>/opt/LiferayMaven/liferay-portal-6.2-ce-ga2/tomcat-7.0.42/lib/ext</appServerLibGlobalDir>
<appServerPortalDir>/opt/LiferayMaven/liferay-portal-6.2-ce-ga2/tomcat-7.0.42/webapps/ROOT</appServerPortalDir>
<liferayVersion>6.2.1</liferayVersion>
<pluginType>portlet</pluginType>
</configuration>

Note:

the above details are based on where your portal server resided.

find following tag and replace with version number

<version>${liferay.maven.plugin.version}</version>

Replace as

<version>6.2.1<version>

Change following tag in all dependencies from <version>${liferay.version}</version> to <version>6.2.1</version>

Add Other important liferay dependencies

<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-client</artifactId>
<version>6.2.1</version>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-impl</artifactId>
<version>6.2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-pacl</artifactId>
<version>6.2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-service</artifactId>
<version>6.2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-web</artifactId>
<version>6.2.1</version>
<type>war</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-bridges</artifactId>
<version>6.2.1</version>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-java</artifactId>
<version>6.2.1</version>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-slf4j</artifactId>
<version>6.2.1</version>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-taglib</artifactId>
<version>6.2.1</version>
</dependency>

Note:

Above all dependencies should enclose by <dependencies></dependencies> tag.

Finally liferay Plugin portlet project pom.xml as follows

<?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>com.liferay.sample</groupId>
<artifactId>liferay-sample-portlet</artifactId>
<packaging>war</packaging>
<name>liferay-sample-portlet Portlet</name>
<version>1.0.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>com.liferay.maven.plugins</groupId>
<artifactId>liferay-maven-plugin</artifactId>
<version>6.2.1</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>build-css</goal>
</goals>
</execution>
</executions>
<configuration>
<autoDeployDir>/opt/LiferayMaven/liferay-portal-6.2-ce-ga2/deploy</autoDeployDir>
<appServerDeployDir>/opt/LiferayMaven/liferay-portal-6.2-ce-ga2/tomcat-7.0.42/webapps</appServerDeployDir>
<appServerLibGlobalDir>/opt/LiferayMaven/liferay-portal-6.2-ce-ga2/tomcat-7.0.42/lib/ext</appServerLibGlobalDir>
<appServerPortalDir>/opt/LiferayMaven/liferay-portal-6.2-ce-ga2/tomcat-7.0.42/webapps/ROOT</appServerPortalDir>
<liferayVersion>6.2.1</liferayVersion>
<pluginType>portlet</pluginType>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.6</source>
<target>1.6</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.2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-bridges</artifactId>
<version>6.2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-taglib</artifactId>
<version>6.2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-java</artifactId>
<version>6.2.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>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-client</artifactId>
<version>6.2.1</version>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-impl</artifactId>
<version>6.2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-pacl</artifactId>
<version>6.2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-service</artifactId>
<version>6.2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-web</artifactId>
<version>6.2.1</version>
<type>war</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-bridges</artifactId>
<version>6.2.1</version>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-java</artifactId>
<version>6.2.1</version>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-slf4j</artifactId>
<version>6.2.1</version>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-taglib</artifactId>
<version>6.2.1</version>
</dependency>
</dependencies>
</project>

Now we have done all the required configuration in project pom.xml now we can deploy project.

Deploy Liferay Plugin Maven Project

Open command prompt or terminal and go to newly created liferay Plugin project location its generally in eclipse work space(LiferayMaven) then issue following command.

mvn package


once build was successful then issue following command to deploy into portal server

mvn liferay:deploy

now portlet will be deployed into portal and you can see build success message in the console


If portal already start then you can see Plugin deployment information in server log file.

Download sample liferay maven Plugin from below link when you use this project please make sure you should installed Liferay Maven Archetypes in your local and you have to change server configuration and versions information in the pom.xml file.

https://sourceforge.net/projects/meeralferay/files/SampleLiferayMaven/

The following pom.xml for liferay maven plugin portlet with liferay-portal-maven-6.2-ce-ga4

<?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>com.liferay.sample</groupId>
<artifactId>liferay-sample-portlet</artifactId>
<packaging>war</packaging>
<name>liferay-sample-portlet Portlet</name>
<version>1.0.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>com.liferay.maven.plugins</groupId>
<artifactId>liferay-maven-plugin</artifactId>
<version>${liferay.maven.plugin.version}</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>build-css</goal>
</goals>
</execution>
</executions>
<configuration>
<autoDeployDir>${liferay.auto.deploy.dir}</autoDeployDir>
<appServerDeployDir>${liferay.app.server.deploy.dir}</appServerDeployDir>
<appServerLibGlobalDir>${liferay.app.server.lib.global.dir}</appServerLibGlobalDir>
<appServerPortalDir>${liferay.app.server.portal.dir}</appServerPortalDir>
<liferayVersion>${liferay.version}</liferayVersion>
<pluginType>portlet</pluginType>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.6</source>
<target>1.6</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>${liferay.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-bridges</artifactId>
<version>${liferay.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-taglib</artifactId>
<version>${liferay.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-java</artifactId>
<version>${liferay.version}</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>
<profiles>
<profile>
<id>Liferay-v6.2-CE-(Tomcat-7)</id>
<properties>
<liferay.version>6.2.3</liferay.version>
<liferay.maven.plugin.version>6.2.2</liferay.maven.plugin.version>
<liferay.auto.deploy.dir>C:\MeerPrince\LiferayWorkSpace\bundles\deploy</liferay.auto.deploy.dir>
<liferay.app.server.deploy.dir>C:\MeerPrince\LiferayWorkSpace\bundles\tomcat-7.0.42\webapps</liferay.app.server.deploy.dir>
<liferay.app.server.lib.global.dir>C:\MeerPrince\LiferayWorkSpace\bundles\tomcat-7.0.42\lib\ext</liferay.app.server.lib.global.dir>
<liferay.app.server.portal.dir>C:\MeerPrince\LiferayWorkSpace\bundles\tomcat-7.0.42\webapps\ROOT</liferay.app.server.portal.dir>
</properties>
</profile>
</profiles>

</project>

Important Points

The configuration in pom.xml will be changed based on your environment like version number, server configuration and dependencies versions.

The above maven setup we have installed maven archetypes in our local repository that is /.m2/repository.

http://sourceforge.net/projects/lportal/files/Liferay%20Portal/6.2.1%20GA2/We have created liferay maven project from Liferay IDE tool without Liferay IDE also we can create liferay plugins from command prompt/terminal.

We have create Pluginv portlet project apart from that we can also create all liferay plugins like hook,web,ext,theme and layouttpl from liferay maven archetypes.

Author

Recent Posts

Recent Posts Widget

Popular Posts