Decoupled projects & configuration injection in 1.5rc?

(x1000) #1


I don’t fully get the current status of COD in 1.5 RC: Can I use configuration injection (subprojects {} and allprojects {}) in the root project or has this still the effect of coupling all projects ?

(Szczepan Faber) #2

At the moment, COD always configures the root project. This means that anything you have in root project (including allprojects {} and subprojects {} will get executed).

Here’re some examples that might be useful. Bear in mind that CoD will be improved in the coming releases and some of the examples might be out of date. In future, CoD will not automatically configure root project and will have better handling of allprojects {} and friends.

//root project
allprojects {
  //applying plugin directly is no good because we lose some benefits of CoD
  apply plugin: 'java'
  //adding a plugin rule is nice, taking full advantage of CoD
  plugins.withType(JavaPlugin) {
//before project hook plays nicely with CoD, even for plugin appliance
gradle.beforeProject {
  apply plugin: 'java'

Hope that helps!