<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Custom Gradle Task and running dependent Liferay Tasks</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=112163985" />
  <subtitle>Custom Gradle Task and running dependent Liferay Tasks</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=112163985</id>
  <updated>2026-04-04T05:39:46Z</updated>
  <dc:date>2026-04-04T05:39:46Z</dc:date>
  <entry>
    <title>RE: Custom Gradle Task and running dependent Liferay Tasks</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112180540" />
    <author>
      <name>Kevin Neibarger</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112180540</id>
    <updated>2019-01-30T13:05:32Z</updated>
    <published>2019-01-30T13:05:32Z</published>
    <summary type="html">For those having similar problems, I figured out my issue. Using the call &lt;strong&gt;getTasksByName&lt;/strong&gt; will retrieve the tasks created by Liferay. Below is a snippet of my &lt;strong&gt;build.gradle&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;ext {&lt;/strong&gt;&lt;strong&gt;    deployDir = &amp;#34;$buildDir/../../../../bundles/liferay-ce-portal-7.1.0-ga1/osgi/modules&amp;#34;&lt;/strong&gt;&lt;strong&gt;    jarsDir = &amp;#34;$buildDir/../../bundles/osgi/modules/&amp;#34;&lt;/strong&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;strong&gt;task deployJars() {&lt;/strong&gt;&lt;strong&gt; &lt;/strong&gt;&lt;strong&gt;  group = &amp;#39;build&amp;#39;&lt;/strong&gt;&lt;strong&gt;    description = &amp;#39;Moves the portlet and service jars to the osgi modules directory on your Tomcat server&amp;#39;&lt;/strong&gt;&lt;strong&gt;    &lt;/strong&gt;&lt;strong&gt;  doLast {&lt;/strong&gt;&lt;strong&gt;copy {&lt;/strong&gt;&lt;strong&gt;    // Delete files from Deploy Dir&lt;/strong&gt;&lt;strong&gt;    fileTree(&amp;#34;$deployDir&amp;#34;).each { file -&amp;gt; &lt;/strong&gt;&lt;strong&gt;    if (file.isFile()) {&lt;/strong&gt;&lt;strong&gt;    delete file&lt;/strong&gt;&lt;strong&gt;    }&lt;/strong&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;strong&gt;// Copy files to deployDir&lt;/strong&gt;&lt;strong&gt;fileTree(&amp;#34;$jarsDir&amp;#34;).each { file -&amp;gt; &lt;/strong&gt;&lt;strong&gt;    if (file.isFile()){&lt;/strong&gt;&lt;strong&gt;    println &amp;#34;COPY $file.path To $deployDir&amp;#34;&lt;/strong&gt;&lt;strong&gt;    sleep(2 * 1000)&lt;/strong&gt;&lt;strong&gt;    from file &lt;/strong&gt;&lt;strong&gt;    into deployDir&lt;/strong&gt;&lt;strong&gt;    }&lt;/strong&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;strong&gt;}&lt;/strong&gt;&lt;strong&gt;deployJars.dependsOn getTasksByName(&amp;#39;clean&amp;#39;, true)&lt;/strong&gt;&lt;strong&gt;deployJars.dependsOn getTasksByName(&amp;#39;deploy&amp;#39;, true)&lt;/strong&gt;</summary>
    <dc:creator>Kevin Neibarger</dc:creator>
    <dc:date>2019-01-30T13:05:32Z</dc:date>
  </entry>
  <entry>
    <title>Custom Gradle Task and running dependent Liferay Tasks</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112163984" />
    <author>
      <name>Kevin Neibarger</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112163984</id>
    <updated>2019-01-29T13:04:47Z</updated>
    <published>2019-01-29T13:04:47Z</published>
    <summary type="html">&lt;p&gt;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 &amp;quot;build&amp;quot; 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 &lt;strong&gt;deploy&lt;/strong&gt; 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.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;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 &lt;strong&gt;dependsOn(':deploy') &lt;/strong&gt;it's telling me
  the &lt;strong&gt;deploy&lt;/strong&gt; task isn't found. Is there a way to run
  the &lt;strong&gt;deploy &lt;/strong&gt;task automatically before this custom task?&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;
  &lt;span style="color: rgb(255,0,0);"&gt;FAILURE: Build failed with an exception.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;
  &lt;span style="color: rgb(255,0,0);"&gt;
    &lt;strong&gt;* What went wrong:&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;
  &lt;span style="color: rgb(255,0,0);"&gt;
    &lt;strong&gt;Could not determine the dependencies of task ':moveJarsToDeploy'.&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;
  &lt;span style="color: rgb(255,0,0);"&gt;
    &lt;strong&gt;&amp;gt; Task with path 'deploy' not found in root project 'KHM-portlet-v71'.&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;
  &lt;span style="color: rgb(255,0,0);"&gt;
    &lt;strong&gt;* Try:&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;
  &lt;span style="color: rgb(255,0,0);"&gt;
    &lt;strong&gt;Run with --stacktrace option to get the stack trace. Run
      with --info or --debug option to get more log output.&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Here is the custom task&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;
  &lt;strong&gt;task moveJarsToDeploy (type: Copy){&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;
  &lt;strong&gt; &lt;span style="background-color: rgb(255,255,0);"&gt;   dependsOn('deploy')&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;
  &lt;strong&gt;    group = 'build'&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;
  &lt;strong&gt;    description = 'Moves the portlet and service jars to the
    osgi modules directory on your Tomcat server'&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;
  &lt;strong&gt;   &lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;
  &lt;strong&gt;    // Delete files from Deploy Dir&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;
  &lt;strong&gt;    fileTree(&amp;quot;$deployDir&amp;quot;).each { file -&amp;gt; &lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;
  &lt;strong&gt;    if (file.isFile()) {&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;
  &lt;strong&gt;    delete file&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;
  &lt;strong&gt;    }&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;
  &lt;strong&gt;}&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;
  &lt;strong&gt;// Copy files to deployDir&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;
  &lt;strong&gt;fileTree(&amp;quot;$jarsDir&amp;quot;).each { file -&amp;gt; &lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;
  &lt;strong&gt;    if (file.isFile()){&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;
  &lt;strong&gt;    println &amp;quot;COPY $file.path To $deployDir&amp;quot;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;
  &lt;strong&gt;    sleep(2 * 1000)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;
  &lt;strong&gt;    from file &lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;
  &lt;strong&gt;    into deployDir&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;
  &lt;strong&gt;    }&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;
  &lt;strong&gt;}&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;
  &lt;strong&gt;}&lt;/strong&gt;&lt;/p&gt;</summary>
    <dc:creator>Kevin Neibarger</dc:creator>
    <dc:date>2019-01-29T13:04:47Z</dc:date>
  </entry>
</feed>
