Gradle 2.9: "Unexpected afterEvaluate event received without beforeEvaluate"

I’m receiving %SUBJ% message in the environment as described here

This seems to be internal bug. After commenting/un-commenting my build scripts line by line I’ve traced that presense of ‘project.getTasksByName’ within '‘gradle.beforeProject()’ causes recursive re-evaluation of the same project - and that follows either to StackOverflow or to above mentioned exception.

Steps to reproduce:

minimal project structure

root
    p1 - empty build.gradle
    p2 - empty build.gradle

in the root folder

settings.gradle

    include "p1"
    include "p2"

build.gradle

    gradle.beforeProject { prj ->
        println "before ${prj.name}"
        if( !prj.ext.has('initialized') || !prj.ext.initialized ) {
            prj.ext.initialized = true;
            prj.task('clean', {})
            prj.getTasksByName('build', false)
        }
    }

in following implementation execution falls into StackOverflow exception - because no other exception occur on the way

    gradle.beforeProject { prj ->
        println "before ${prj.name}"
        //if( !prj.ext.has('initialized') || !prj.ext.initialized ) {
            prj.ext.initialized = true;
            //prj.task('clean', {})
            prj.getTasksByName('build', false)
        //}
    }

BTW, this was supposed to be publish in ‘bugs’ section. If there are moderators here - please move to the right forum.