Blog Post

...

Liferay 7: deploy module using gradle script

In Liferay 7 the task of automatic module deployment can be very useful, especially if you continuously develop your code on daily basis. Starting from 7 version of Liferay, project build framework switched mainly from Maven to Gradle. Gradle’s build procedure consists of subsequent tasks execution, these tasks are defined and generated during new Liferay module creation. But there’s no ‘deploy’ task – a common task that speeds up the dev-process. In this post we’ll get to know how to solve that.

First of all we should navigate to build.gradle file – the one that was generated at module creation time. It already includes build task, which designates assembling all outputs and running all checks. We need this task since it generates the resulting jar-file for deployment. Let’s create new hotDeploy task, appending it to build.gradle file:

task hotDeploy(type: Copy){
    dependsOn build
    from(file('build/libs/tool-1.0.0.jar'))
    into('/opt/liferay/deploy')
}

What we can say about this script:

  1. It’s executed after build task (see 2 line dependsOn)
  2. A module (jar-file) that was built during the build task is taken from build/libs path – a common path for Gradle building process
  3. Jar-file is copied in to deploy dir of the Liferay

After the hotDeploy task is introduced it can be run from, e.g. IDE:

gradle

After the task is run, the compiled module will be placed to deploy dir and after the moment the module is redeployed.

In this post we’ve discussed how the process of module deployment can be enhanced by means of dev-process speed up. The deployment procedure is automated and that is always helpful.


Comments (0)

Tags: liferay


0 comments

Leave a Comment