Ordering tasks on the command line versus using "mustRunAfter"

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.

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.