# Composite build lifecycle question

**URL:** <https://discuss.gradle.org/t/composite-build-lifecycle-question/22126>\
**Category:** Help/Discuss\
**Created:** [March 28, 2017, 1:09am UTC](https://discuss.gradle.org/t/composite-build-lifecycle-question/22126 "2017-03-28T01:09:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oraculo](https://avatars.discourse-cdn.com/v4/letter/o/d2c977/32.png) [@Oraculo](https://discuss.gradle.org/u/Oraculo)\
**Post date:** [March 28, 2017, 1:09am UTC](https://discuss.gradle.org/t/composite-build-lifecycle-question/22126/1 "2017-03-28T01:09:35Z")

</div>

We have a huge number of builds and composite build was a great solution to create virtual projects to save developers’ time. Though I faced few annoying things. I decided not to include other modules into existing builds, but rather develop umbrella projects, which include all needed modules and can be submitted into separate Git repository.  
Layout:  
Project A (umbrella) includes two modules, depends on them and has a dependency substitution  
Project B simple library project  
Project C multi module project which depends on B  
in one of the B’s submodules I am building fat jar, which filters runtime configuration and includes certain number of jar from it, i.e:

> ```
> def validJars = ['a-*', 'b-*', 'c-*']
> task fatJar(type: Jar) {
> dependsOn configurations.runtime
> zip64 = true
> from (configurations.runtime.collect{ zipTree(it) }) {
> include validJars
> }
> from sourceSets.main.output
> from (fileTree("$projectDir/data"){ includes = dataFiles }.files)
> destinationDir file("$projectStage")
> archiveName "fatjar.jar"
> }
> 
> ```

This list “validJars” includes project B. Thus when Gradle configures project C, it resolves runtime configuration and actually runs project B (binary dependency is substituted with project). It also builds it during execution phase, which is very annoying. I am trying to debug sources to understand to avoid building substituted dependency during configuration phase, but piece of advice would be appreciated.

---

<div class="post-metadata">

**Author:** ![Oraculo](https://avatars.discourse-cdn.com/v4/letter/o/d2c977/32.png) [@Oraculo](https://discuss.gradle.org/u/Oraculo)\
**Post date:** [March 30, 2017, 4:00pm UTC](https://discuss.gradle.org/t/composite-build-lifecycle-question/22126/2 "2017-03-30T16:00:20Z")

</div>

OK, found solution myself. Not very elegant one, but working.  
Move jar task into execution phase of an empty task, thus Gradle resolves configuration only while executing it.

> ```
> task fatJar {
> doLast {
> jar {}
> }
> }
> 
> ```
