Hi, I’ve seen multiple times recommendation to avoid resolving dependencies at the configuration phase. And I understand why. It slows down my build considerably. But I struggle to be able to resolve any dependencies at execution time.
Consider this for example, in one of my tasks I do at configuration phase:
This does not trigger resolution at config time anymore but since it is task of type JavaExec it is failing to run with “no main class specified” as configuration isn’t ready at execution time.
And more generally, is there any documentation regarding recommendations around what should be done during configuration vs execution phase, and how? There’s some documentation explaining the lifecycle but would be good to have some more around good practices…
Thanks Stefan. Is there a similar way to resolve classpath for all subprojects in a multiproject setup? I’m looking for a way to concatenate all subproject’s classpaths as they are needed for this JavaExec task.
Tried this but getting “File collection does not allow modification”
You are just adding to a file collection, if for instance two projects had different versions of log4j then your classpath would have both log4j jars. Mine would use dependency resolution to choose one
> Could not find property 'javaExec' on configuration container.
The only way I made this whole thing work was resolving dependencies at configuration time, and using getFiles. Which Stefan suggested I didn’t have to…
This is wrong, it.configurations and configurations are the same thing in this closure. Getters in the closure are invoked on the subproject. This is different from my mySubProjects().each { ... } suggestion
You could probably just do it like this in the root project