Way to define project defaults based on subproject type

I have a Gradle 1.11 multi-project build in which there are more than one project types e.g. some are java projects, some are mixed java/scala, some are javascript based, etc. I would like to define defaults for each of these types of projects in my root project build. Is there an easy way to do this?

I have tried:

configure(subprojects.findAll { project -> project.has('applyJavaDefaults') && project.applyJavaDefaults }) {
  //sourceCompatibility = javaVersion
  // dependencies, etc.
    // test with a task that should show up on all projects with property applyJavaDefaults
  task hello << {
    println 'Hello world!'
    println project.name
  }
}

and in the relevant subprojects:

project.applyJavaDefaults = true

But for some reason it does not work.

I found the explanation as to why my script was not working, and a good alternative solution using the “apply from” syntax: http://stackoverflow.com/questions/9839127/dynamically-configuring-a-task-in-a-parent-build-gradle

Thanks for a great build tool!