Showing posts with label Create Portlet in Liferay7. Show all posts
Showing posts with label Create Portlet in Liferay7. Show all posts

Friday, 5 August 2016

How to create a liferay Workspace using Liferay IDE

How to create a liferay Workspace using Liferay IDE

So What is liferay workspace, A liferay workspace project is a project that is intended to generate and hold up all of the  liferay module and projects. This helps out the developer by providing Gradel scripts and the configuration properties, so that the user is not suppose create and configure the properties required to develop and build the projects.
The Liferay workspace even had the support for legacy WAR based projects using the Plugins SDK. The developer can configure the workspace to develop the projects in the same way.

Before creating a workspace please go through the tutorial on how to install blade. Blade installation is required in order to use the Liferay Workspace.

So now How to create your first Liferay Workspace -:
Click on New -> Liferay Workspace Project
Enter the desired name in this case FirstWorkspace. Click on Finish. This will create a new Workspace.
If you want to configure the liferay server automatically and want to download liferay portal. click on the Download liferay bundle, this will download a new liferay bundle and will configure a new server with the downloaded bundle. This is one of the sample of power that liferay workspace provides to the user.


Once the liferay workspace is created it will generate a folder structure as shown below.


Following are the details of the folder structure created in the project.
Configs -> This folder holds the configuration files for different environments. For example in the above folder structure we can see that there are DEV, LOCAL, UAT and PROD environment. Each environment is having its own properties file. These files will be picked up depending upon the environment upon which the build is being deployed.  The current environment is controlled from the gradle.properties.
Gradel -> It holds the Gradel Wrappers that are used by the workspace
Modules-> It holds the custom modules that are being developed in this Liferay Workspace project .
Themes -> It holds the themes that has been generated by using the Theme Generator.
gradel.properties ->  This file contains the liferay and envirment specific properties that would be used by gradel to build up this module.  Folowing are some of the properties that are by default available to the gradel.
#liferay.workspace.bundle.url=https://sourceforge.net/projects/lportal/files/Liferay Portal/7.0.1 GA2/liferay-ce-portal-tomcat-7.0-ga2-20160610113014153.zip
#liferay.workspace.environment=local
#liferay.workspace.home.dir=bundles
#liferay.workspace.modules.default.repository.enabled=false
#liferay.workspace.modules.dir=modules
#liferay.workspace.plugins.sdk.dir=plugins-sdk
#liferay.workspace.themes.dir=themes


microsoft.translator.client.id=
microsoft.translator.client.secret=


One of the feature of using the liferay workspace project is that it will hide the complexities of gradel by adding multiple sub project in the setting.gradel file. you need not to worry about them.
In other case if you want to configure a pre existing Liferay server to the Liferay Workspace you need to specify the Liefray Home of the server in the gradel.properties.

liferay.workspace.home.dir=PATH_TO_LIFERAY_HOME

Once we are done with the development and want to share this workspace to someone else, we can go ahead and bundle the complete workspace into a single file using the following command -:
.\gradlew distBundle[Zip|Tar]
This will generate a Tar|Zip file and that can be distributed to the users.
gradlew initBundle
Is used to test the current build on the liferay instance. The liferay instance is taken
from the gradel.properties file as described above.

It’s important to note that an Eclipse workspace can only have one Liferay Workspace project.




For more details on the above topic please go through the below video on my youtube channel.      

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

 

Copyright @ 2016 LiferayRevisited.