Monday 1 August 2016

Creating portlet in Liferay7 using blade - OSGI

How to Create and Deploy a new Portlet using Blade


To create modules using blade is quite simple. It is as good as creating the portlets using the command line tool of liferay SDK. To create the modules using the Blade you need to first install Blade. For knowing how to install blade please refer to my previous blog post on blade-installation-for-liferay7.  

Once you had installed blade on your machine, you need to navigate to the directory where you need to create the portlet.

To create a module/portlet using blade, following the minimal command

blade create [OPTIONS] <NAME>

blade create My-Sample-Portlet

The above command will create a new portlet with default configurations and a controller with the name MySamplePortlet.
blade create -t mvcportlet -p com.liferay.docs.mvcportlet.portlet -c MyMvcPortlet my-mvc-portlet-project
The above command will create a new project in the current with the name my-mvc-portlet-project. Because we are using the template mvcportlet this project will be created as a MVCPortlet Project, and the module will be having the Controller which will extend the MVCPortlet.java. The controller class will be in the package com.liferay.docs.mvcportlet.portlet and the name of the controller will be MyMvcPortlet.
Once the above command is punched in cmd, the below screen will come up. This will initially download the Gradel distribution as the build process will be using gradle.

Once completed the below screen will come up with a message that Create the project my-mvc-portlet-project using the mvcportlet template in <DIRECTORY>

Once created we can import the above project into eclipse using the import of eclipse. Click on Import->Liferay Module Projects
Click on the browse and provide the location of project.
Once imported the project will come up in the below shown structure. This verifies that the project has been created successfully.

Blade deploy
Now the next step is how to deploy the module/portlet into liferay. To do that it is easy, we just need to write the blade deploy command. This will search for the running instance of liferay on that machineand will deploy this module into the same.
blade deploy
blade deploy <PORT> - Will deploy in a liferay instance running on an specific port.
Below the image that shows that the Build is successfull and Portlet/module has been Started.
We can also see in the eclipse Console as shown below that the portlet/module is available for use. Here STARTED means available for use.

How to create portlet Using Blade in Liferay7

How to deploy portlet in Liferay7

j\

5 comments:

  1. Creating portlet in Liferay7 using blade - OSGI
    How to Create and Deploy a new Portlet using Blade

    To create modules using blade is quite simple. It is as good as creating the portlets using the command line tool of liferay SDK. To create the modules using the Blade you need to first install Blade. For knowing how to install blade please refer to my previous blog post on blade-installation-for-liferay7.

    ReplyDelete
  2. Can you please provide few more information about blade? what exactly it is?
    Is is any kind of shell command like program?

    ReplyDelete
    Replies
    1. Hi Himanshu,

      Blade or Blade CLI is a command line java tool that can be used to help bootstrap Liferay 7 module development.

      For further information you can goto this link https://github.com/liferay/liferay-blade-cli.

      Thanks

      Delete
    2. And stay tuned to this blog. I will be publishing more information on Liferay7

      Delete
  3. Hi Danish,

    Am getting error while running command " blade deploy"
    Error
    0. deploy: Unable to connect to gogo shell on localhost:11311

    Can you please help in resolving this issue

    Thank you

    ReplyDelete

 

Copyright @ 2016 LiferayRevisited.