build.gradle - Execute gradle task on sub projects -



build.gradle - Execute gradle task on sub projects -

i have multimodule gradle project trying configure.

root proja projb other projc projd proje ...

want want able have task in root build.gradle execute buildjar task in each of projects in other directory.

i know can

configure(subprojects.findall {it.name != 'tropicalfish'}) { task hello << { task -> println "$task.project.name"} }

but proja , projb, want run task on c,d,e... please allow me know best way accomplish this.

not exclusively sure of these you're after, should cover bases.

1. calling tasks directly

you should able call

gradle :other/projc:hello :other/projd:hello

i tested with:

# root/build.gradle allprojects { task hello << { task -> println "$task.project.name" } }

and

# root/settings.gradle include 'proja' include 'projb' include 'other/projc' include 'other/projd'

2. creating tasks in sub projects

or want task created on other/* projects?

if latter, next works:

# root/build.gradle allprojects { if (project.name.startswith("other/")) { task hello << { task -> println "$task.project.name" } } }

and can called with:

$ gradle hello :other/projc:hello other/projc :other/projd:hello other/projd

3. creating task runs tasks in subprojects only

this version matches reading of question meaning there's task on subprojects (buildjar), , creating task in root phone call subprojects other/*:buildjar

allprojects { task buildjar << { task -> println "$task.project.name" } if (project.name.startswith("other/")) { task runbuildjar(dependson: buildjar) {} } }

this creates task "buildjar" on every project, , "runbuildjar" on other/* projects only, can call:

$ gradle runbuildjar :other/projc:buildjar other/projc :other/projc:runbuildjar :other/projd:buildjar other/projd :other/projd:runbuildjar

your question can read many ways, hope covers them :)

gradle build.gradle multi-module

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -