# Ordering tasks on the command line versus using "mustRunAfter"

**URL:** <https://discuss.gradle.org/t/ordering-tasks-on-the-command-line-versus-using-mustrunafter/12017>\
**Category:** Help/Discuss\
**Created:** [October 4, 2015, 6:59pm UTC](https://discuss.gradle.org/t/ordering-tasks-on-the-command-line-versus-using-mustrunafter/12017 "2015-10-04T18:59:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Don\_Henry](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/don_henry/32/6132_2.png) [@Don\_Henry](https://discuss.gradle.org/u/Don_Henry)\
**Post date:** [October 4, 2015, 6:59pm UTC](https://discuss.gradle.org/t/ordering-tasks-on-the-command-line-versus-using-mustrunafter/12017/1 "2015-10-04T18:59:51Z")

</div>

To me, it looks like these accomplish the same thing. Am I correct and is there a preference between the two. Personally, the former seems clearer.

---

<div class="post-metadata">

**Author:** ![mark\_vieira](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/mark_vieira/32/5396_2.png) [@mark\_vieira](https://discuss.gradle.org/u/mark_vieira)\
**Post date:** [October 4, 2015, 7:05pm UTC](https://discuss.gradle.org/t/ordering-tasks-on-the-command-line-versus-using-mustrunafter/12017/2 "2015-10-04T19:05:50Z")

</div>

Command line ordering is essentially the same as `shouldRunAfter` in that if Gradle cannot enforce the order (due to another dependency) then the build will still execute. Consider the following:

```
gradle test classes

```

In this case the `test` task actually depends on `classes` so Gradle cannot execute these tasks in the order specified on the command line. Gradle will still execute the build but in the proper order, effectively ignoring the command line ordering.

So to answer your question, no, they are not the same. Even if they were, the latter would still be preferred. The reason is that we should not rely on the user to construct the command line in a certain way in order for the build to execute in the correct order. Task ordering and dependencies should _always_ be specified in the build script.
