Gretty version 1.1.5+ extends farms mechanism with composite farms - farms consisting of other farms.

The syntax:

// in ProjectA:
farm {
  webapp project // ProjectA
  webapp ':ProjectB'
}

// in ProjectC:
farm {
  webapp project // ProjectC
  webapp ':ProjectD'
}

// in ProjectE:
farm {
  include ':ProjectA'
  include ':ProjectC'
}
// Farm of ProjectE effectively includes webapps ProjectA, ProjectB, ProjectC and ProjectD.

The farms referred by composite farm can themselves be composite farms. Gretty provides runtime mechanism that detects (and reports as an error) any cyclic includes between composite farms.

You can arbitrarily combine composite farms and named farms:

// in ProjectA:
farms {
  farm 'X', {
    webapp project // ProjectA
  }
  farm 'Y', {
    webapp ':ProjectB'
  }
}

// in ProjectC:
farm {
  farm 'P', {
    webapp project // ProjectC
  }
  farm 'Q', {
    webapp ':ProjectD'
  }
}

// in ProjectE:
farms {
  farm 'R', {
    include ':ProjectA', 'X'
    include ':ProjectC', 'Q'
  }
  farm 'S', {
    include ':ProjectA', 'Y'
    include ':ProjectC', 'P'
  }
}
// Farm 'R' of ProjectE effectively includes webapps ProjectA and ProjectD.
// Farm 'S' of ProjectE effectively includes webapps ProjectB and ProjectC.

Gretty sources contain complete working example of composite farm: