gradle - Task with path 'build' not found in root project -


i have multiproject , after last subproject built, i'd process jars. therefore created task in root-project:

task install(dependson: 'build', type: copy) {     dolast {         println "exec install task"     } } 

upon calling ./gradlew install in root directory, i'm facing error:

failure: build failed exception.  * went wrong: not determine dependencies of task ':install'. > task path 'build' not found in root project 'foo'. 

however, calling ./gradlew tasks shows me these tasks:

:tasks  ------------------------------------------------------------ tasks runnable root project ------------------------------------------------------------  build tasks ----------- assemble - assembles outputs of project. build - assembles , tests project. ... 

how can achieve desired functionality?

i assume, root project organizes build, not define build action taken itself. build task defined language plugins (in cases via apply plugin: 'java'), if root project not use of them, won't have build task.

the description of task tasks, used, says:

displays tasks runnable root project 'projectreports' (some of displayed tasks may belong subprojects).

the task followes same logic task activation via command line. can provide task name , task name in subproject executed (thats why gradle build works).

but if define dependson dependency, given string evaluated task path single task. since each task name can used once in project, name unique tasks in root project, many tasks found, if subprojects considered. therefor, 1 can use syntax :<projectname>:<taskname> identify tasks in subprojects.

now, let's face specific problem: if install task should depend on build task of 1 single subproject, use dependson ':<mysubproject>:build'. assume want install task depend on each subproject build task, i'd propose approach:

task install(type: copy) {     dependson subprojects*.tasks*.findbyname('build').minus(null)     dolast {         println "exec install task"     } } 

this way, each registered subproject, findbyname('build') called , result (the found task or null) put list, used task dependency list. added .minus(null) part remove null entries list, because not sure how gradle handles such entries in dependency collection. if sure, each subproject provides build task, can use getbyname('build'), too.

edit: op found optionally recursive gettasksbyname method, suits case better iterating on subprojects manually:

dependson gettasksbyname('build', true) 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -