[GRADLE-3389] mustRunAfter not honored when used with finalizedBy Created: 01/Feb/16  Updated: 16/Jan/17  Resolved: 16/Jan/17

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Gary Hale Assignee: Unassigned
Resolution: Duplicate Votes: 1


 Description   

Reported on the forums at: https://discuss.gradle.org/t/task-ordering-problem-mustrunafter-finalizer-dependencies/14035

I have one task (let's call it "B") that is finalized by another (called "C"), but which also "must run after" a third ("A"). However, "C" also depends on "A", so calling "gradle B" invokes all three tasks to run as follows:

B --> is finalized by --> C --> which depends on --> A

However, due to the "must run after" relationship between B and A, I would expect A to execute first, but it doesn't.

Here is a sample build.gradle to reproduce the problem:

{{task A

task B

{ mustRunAfter "A" finalizedBy "C" }

task C

{ dependsOn "A" }

}}

Here is the result I would expect when calling "gradle B":

{{:A UP-TO-DATE
:B UP-TO-DATE
:C UP-TO-DATE}}

But, I actually get:

{{:B UP-TO-DATE
:A UP-TO-DATE
:C UP-TO-DATE}}

with B executing before A, even through B "must run after" A. If I run "gradle B A" instead, the tasks execute in the correct order - it seems to occur only when A's execution is invoked by a "finalizer" dependency. Interestingly, the task graph as printed with the --info flag shows the tasks in the correct order, but they are then executed differently.



 Comments   
Comment by Benjamin Muschko [ 15/Nov/16 ]

As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub.

We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to.

Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by:

  • Checking that your issues contain requisite context, impact, behaviors, and examples as described in our published guidelines.
  • Leave a comment on the JIRA issue or open a new GitHub issue confirming that the above is complete.

We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle!

Comment by Rowan Lonsdale [ 15/Nov/16 ]

This issue was raised on my behalf in response to the linked forum issue. I would appreciate it if it could be kept open and migrated to GitHub.

Comment by Benjamin Muschko [ 16/Jan/17 ]

The issue is now tracked on GitHub: https://github.com/gradle/gradle/issues/1186

Generated at Wed Jun 30 12:47:31 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.