# How to setup dependecy between modules to produce a fat-jar?

**URL:** <https://discuss.gradle.org/t/how-to-setup-dependecy-between-modules-to-produce-a-fat-jar/38290>\
**Category:** Help/Discuss\
**Created:** [November 18, 2020, 4:48pm UTC](https://discuss.gradle.org/t/how-to-setup-dependecy-between-modules-to-produce-a-fat-jar/38290 "2020-11-18T16:48:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![artenes](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/artenes/32/8929_2.png) [@artenes](https://discuss.gradle.org/u/artenes)\
**Post date:** [November 18, 2020, 4:48pm UTC](https://discuss.gradle.org/t/how-to-setup-dependecy-between-modules-to-produce-a-fat-jar/38290/1 "2020-11-18T16:48:27Z")

</div>

I have a multi-module build with gradle for a java library.

This is the folder structure:

```gradle
- moduleA
  - src
  - build.gradle
- moduleB
  - src
  - build.gradle
- moduleC
  - src
  - build.gradle
- mainModule
  - src
  - build.gradle
build.gradle
settings.gradle

```

I want to create a fat-jar form the `mainModule`, where all the source code from the 4 modules are included in the same jar.

In `mainModule`'s build.gradle I have this:

```gradle
apply plugin: 'java-library'

version = '0.1.0'

jar {
    manifest {
        attributes('Implementation-Title': project.name,'Implementation-Version': project.version)
    }

    from {
        configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
    }
}

dependencies {
    api project(':moduleA')
    api project(':moduleB')
    api project(':moduleC')
    api 'random.lib:vendor:1.0.0'
}

```

And this is the settings.gradle:

```gradle
rootProject.name = 'ProjectName'
include('moduleA')
include('moduleB')
include('moduleC')
include('mainModule')

```

But when I tried to build the project with `./gradlew clean build`, I got the error:

```gradle
Execution failed for task ':mainModule:jar'.
> Cannot expand ZIP 'moduleA/build/libs/moduleA-0.1.0.jar' as it does not exist.

```

Gradle it is trying to create the fat-jar without building the other modules first, probably because I did not set up something properly.

So, how can I organize these dependecies where the other modules are build first then the `mainModule`?
