Hi Taher,

the configuration in your patch is executed correctly, I logged it with this code enhancement:

        if (!(taskName ==~ /^ofbiz.*(--shutdown|-d).*/)) {
            println taskName + ' dependsOn classes'
            dependsOn classes
        } else {
            println taskName + ' NO dependsOn classes'
        }

./gradlew "ofbiz --shutdown" --dry-run

> Configure project :
executeLoadAdminUser dependsOn classes
executeLoadTenant dependsOn classes
loadTenantOnMasterTenantDb dependsOn classes
loadTenantData dependsOn classes
loadTenantAdminUserLogin dependsOn classes
ofbiz --shutdown NO dependsOn classes
:compileJava SKIPPED
:compileGroovy SKIPPED
:processResources SKIPPED
:classes SKIPPED
:ofbiz --shutdown SKIPPED

but it still seems to execute the whole task dependencies:

> Task :compileJava UP-TO-DATE
> Task :compileGroovy UP-TO-DATE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE

> Task :ofbiz --shutdown


The plugin https://github.com/dorongold/gradle-task-tree shows the following task dependencies:

:ofbiz --shutdown
\--- :classes
     +--- :compileGroovy
     |    \--- :compileJava
     +--- :compileJava
     \--- :processResources


Not sure why...

Thanks,

Michael


Am 26.02.20 um 13:53 schrieb Taher Alkhateeb:
Hi Michael,

I could be mistaken, but I think perhaps you're trying to remove the
dependency during the execution phase instead of the configuration
phase?

Would a patch like the below not work?

diff --git a/build.gradle b/build.gradle
index e5bfb3e9c9..96dcb53a01 100644
--- a/build.gradle
+++ b/build.gradle
@@ -976,11 +976,14 @@ tasks.addRule('Pattern: ofbizBackground
<Commands>: Execute OFBiz startup comman
   * ======================================================== */

  def createOfbizCommandTask(taskName, arguments) {
-    task(type: JavaExec, dependsOn: classes, taskName) {
+    task(taskName, type: JavaExec) {
          jvmArgs(application.applicationDefaultJvmArgs)
          classpath = sourceSets.main.runtimeClasspath
          main = application.mainClassName
          args arguments
+        if (!(taskName ==~ /^ofbiz.*(--shutdown|-d).*/)) {
+            dependsOn classes
+        }
          if (taskName ==~ /^ofbiz.*(--test|-t).*/) {
              finalizedBy(createTestReports)
          }

On Tue, Feb 25, 2020 at 8:48 PM Michael Brohl <[email protected]> wrote:
Hi Taher,

thanks for your feedback!

It seems that removing a dependency from a task is deprecated and should
not be used:

"Do not remove a task dependency from a Task instance. This behaviour
has been deprecated and is scheduled to be removed in Gradle 6.0."

Given this depracation, do you think there is another way to reduce the
code added?

Thanks!


Am 25.02.20 um 12:14 schrieb Taher Alkhateeb:
Hi Michael,

The idea is fine but I think we can improve the implementation. All that
you need is to remove the dependsOn declaration if it is a shutdown command
which would probably result in less code than in the proposed patch.

Cheers

On Tue, Feb 25, 2020, 1:32 PM Michael Brohl <[email protected]>
wrote:

Oops, just realized I already asked in

https://lists.apache.org/thread.html/rf88ce5eb1a3842471ddb8239bb5f08b71c107c4b0d3863b3c13e54fe%40%3Cdev.ofbiz.apache.org%3E

Better respond there, thanks!

Michael


Am 25.02.20 um 11:29 schrieb Michael Brohl:
Hi devs,

any objections to get this into the codebase (and backporting to
17.12./18.12)?

See https://issues.apache.org/jira/browse/OFBIZ-10168

Thanks for your feedback,

Michael Brohl

ecomify GmbH - www.ecomify.de




Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to