Are multiple afterEvaluate {} executed in the sequence on how they are defined

Suppose I have:

afterEvaluate {
    println "AfterEvaluate 1"
afterEvaluate {
    println "AfterEvaluate 2"

Is it always guaranteed that the first closure would be executed first, the output would always be:

AfterEvaluate 1
AfterEvaluate 2

By looking at the implementation, seems gradle is using a LinkeHashMap to hold those closures when defined, so the sequence is guaranteed - am I right? and could I rely on this behavior (which means this is not just an implementation detail)?

I’m not aware of any docs for this, in which case it’s not part of the public contract. So you can either not rely on this, or accept a certain risk that it’s going to change. Typically, such changes won’t be made without good reason.

Then maybe we can make it a public contract? there are cases for complex project, we have multiple afterEvaluate, like one in a plugin, and another one in build.gradle - actually I think this is quite common, so the order really matters here.

It would be best to discuss your proposal and use cases on the dev list.