Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
Custom Gradle Task and running dependent Liferay Tasks
Since the Gradle build scripts build and compile JARs for Liferay 7.1 service builder and associated portlets I'm looking to create a custom task under "build" that removes JARs from the osgi/modules directory in the Tomcat server bundle and copy the new JARs built from the build/deploy task. Since the deploy task creates the JARs in the Workspace/bundles/osgi/modules directory, I need to move them to the LIFERAY_HOME/bundles/liferay-ce-portal-7.1.0-ga1/osgi/modules directory.
The build/deploy tasks are somehow internal to the Liferay IDE when Gradle is used during mvc-portlet and service-builder creation. When I define my custom task in the build.gradle, the dependsOn(':deploy') it's telling me the deploy task isn't found. Is there a way to run the deploy task automatically before this custom task?
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':moveJarsToDeploy'.
> Task with path 'deploy' not found in root project 'KHM-portlet-v71'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Here is the custom task
task moveJarsToDeploy (type: Copy){
dependsOn('deploy')
group = 'build'
description = 'Moves the portlet and service jars to the osgi modules directory on your Tomcat server'
// Delete files from Deploy Dir
fileTree("$deployDir").each { file ->
if (file.isFile()) {
delete file
}
}
// Copy files to deployDir
fileTree("$jarsDir").each { file ->
if (file.isFile()){
println "COPY $file.path To $deployDir"
sleep(2 * 1000)
from file
into deployDir
}
}
}
ext { deployDir = "$buildDir/../../../../bundles/liferay-ce-portal-7.1.0-ga1/osgi/modules" jarsDir = "$buildDir/../../bundles/osgi/modules/"}
task deployJars() { group = 'build' description = 'Moves the portlet and service jars to the osgi modules directory on your Tomcat server' doLast {copy { // Delete files from Deploy Dir fileTree("$deployDir").each { file -> if (file.isFile()) { delete file }}// Copy files to deployDirfileTree("$jarsDir").each { file -> if (file.isFile()){ println "COPY $file.path To $deployDir" sleep(2 * 1000) from file into deployDir }}}}}deployJars.dependsOn getTasksByName('clean', true)deployJars.dependsOn getTasksByName('deploy', true)
Powered by Liferay™