Adding task dependency to a plugin task

I’ve tried to find an answer for this for several days and it’s driving me crazy. Here’s my problem:

I have a build.gradle file that includes the play plugin, which defines a task called processPlayBinaryPlayResources. I created a task foo that I creates some resource files dynamically and want to make sure it is called by the plugin task by addin

However, gradle build results in the following error message:
Could not get unknown property 'processPlayBinaryPlayResources' for root project 'GradleTestBed' of type org.gradle.api.Project.

However, 'gradle tasks --all` show that processPlayBinaryPlayResources exists.

Here’s a sample build file that reproduces the problem:
plugins {
id ‘play’
}

ext {
name = "XXX"
organization = "YYYY"
version = "1.0"
}

model {
components {
    play {
        platform play: '2.5.6', scala: '2.11'
        injectedRoutesGenerator = true
    }
}
}

model {
distributions {
    playBinary {
        baseName = project.ext.name + '-' + project.ext.version
        contents {
            from("build.properties")
        }
    }
}
}

repositories {
jcenter()
maven {
    name "typesafe-maven-release"
    url "https://repo.typesafe.com/typesafe/maven-releases"
}
maven {
    name "confluent"
    url "http://packages.confluent.io/maven/"
}
maven {
    name "binrepo.target.com-promo-release"
    url "https://binrepo.target.com/artifactory/libs-release-local"
}
}


task foo << {
println("Create dynamic properties")
}

processPlayBinaryPlayResources.dependsOn foo // this is where it fails

What am I doing wrong? How can I get my build file to see this task?