• Liferay 7 Module Projects Using Maven

    Maven is a famous Build tool used in Java World to Create, Build and Manage the Projects, An archetype is nothing but a project Template which creates the project in a defined file and folder hierarchy as required by the specific technology.

    Liferay IDE 3.1.2 GA3
    Liferay CE Portal Tomcat 7 GA5/Liferay 7 DXP
    JDK 8
    MySql 5.7
    Maven 3.5.2

    Liferay have provided many Maven archetypes to generate different Liferay Module Projects
    using which we can create portlets, service builder, themes, layouts and all the Module Projects supported in Liferay. In This Post i will brief you the steps to create a Service Builder and Liferay Portlet using Maven.

    Step 1 : Setup Maven The Machine

    I will be not covering this part as number tutorials are available on the web to setup maven in the machine, please refer the below links to setup maven in your machine.

    Step 2 : Creating Liferay 7 Service Builder In Maven

    Open Command line in the desired folder where you want to create the service builder module project and enter the following command.
    mvn archetype:generate -Dfilter=liferay

    this will give you list of all the archetype available for Liferay as shown below.

    Step 3 : Select The Liferay Maven archetype

    In my case i will be selecting 27 as i am creating service builder module project, give 27 in the interactive command line interface and provide the artifacts details as shown below.

    and hit enter, this will generate a maven service builder project with the name "vehicle" and it will be having to two folders named "vehicle-api" and "vehicle-service" as shown below.

    Step 4 : Building Liferay Service In Maven

    Goto vehicle-service folder you can find the service.xml file, i have defined a entity named "vehicle",  you can define your entities the service.xml and build the service using the below command.
    mvn service-builder:build

    it will take some time to download all the dependencies to download the dependencies mentioned in the pom.xml, wait till the jars gets downloaded, after downloading the dependencies you must be able see the build success message in the console as shown below.

    Step 5 : Creating Liferay MVC Portlet In Maven

    I am going to create the portlet inside the parent folder of the vehicle service, as liferay follows the same portlet and service builder directory structure, if you want to create in any other folder you can create it.
    Now lets open the commandline in the folder "vehicle" and execute the following command.
    mvn archetype:generate -Dfilter=liferay
    fill the portlet artifacts details as shown below and hit enter.

    Step 6 : Build The Service Builder and Portlet Modules.

    just run mvn install command on the parent folder "vehicle" that will build the vehicle service and vehicle-portlet module as shown below.

    Similarly we can create theme, layout, fragment modules etc using the different archetypes.

    Don't forget to like and share our work.