How can I detect if my subproject is a war project?

I did try to detect if ‘war’ namespace is defined but I also have no clue how to do this.

if (plugins.hasPlugin('war')) {
    println "war!"
}

If you are declaring this in the root project, you might want to wait until all of your subprojects have been evaluated with ‘gradle.projectsEvaluated’.