# Multiple projects building

**URL:** <https://discuss.gradle.org/t/multiple-projects-building/11204>\
**Category:** Help/Discuss\
**Created:** [August 17, 2015, 6:57am UTC](https://discuss.gradle.org/t/multiple-projects-building/11204 "2015-08-17T06:57:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rusbik91](https://avatars.discourse-cdn.com/v4/letter/r/4bbf92/32.png) [@rusbik91](https://discuss.gradle.org/u/rusbik91)\
**Post date:** [August 17, 2015, 6:57am UTC](https://discuss.gradle.org/t/multiple-projects-building/11204/1 "2015-08-17T06:57:28Z")

</div>

Hello, i have and issue about multiple project building. My project structure is:  
Project  
\lib  
\jar1  
\jar2

jar1 and jar2 are depends from lib. What i want to do:

1. Building jar1 must output lib.jar and jar1.jar in \build folder of jar1 project (and accordingly for jar2).
2. Building Project must output lib.jar, jar1.jar, jar2.jar in \build folder of Project.

How it could be done?

---

<div class="post-metadata">

**Author:** ![kkarlberg](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/kkarlberg/32/5203_2.png) [@kkarlberg](https://discuss.gradle.org/u/kkarlberg)\
**Post date:** [August 17, 2015, 9:28pm UTC](https://discuss.gradle.org/t/multiple-projects-building/11204/2 "2015-08-17T21:28:16Z")

</div>

> [@rusbik91](#):
>
> jar1 and jar2 are depends from lib

Does this mean jar1 and jar2 **depend** on lib or are jar1 and jar2 **dependants of** lib?

Assuming jar1 and 2 depend on lib…  
We have something similar going on to this.

settings.gradle:

```
include 'jar1', 'jar2','Project','lib'

```

build.gradle

```
project(':jar1') {
  dependencies {
    compile project(':lib')
  }
}

project(':Project') {
  dependencies {
    compile project(':jar1')
    compile project(':jar2')
  }
}

```

This only says that Project need jar1 and 2 to compile, and I guess you want to produce some complete binary from Project. If so you can dowload all your runtime deps into Project/build/lib with something like:

```
task myTask( type: Copy) {
  into("lib") {
    from(jar)
    from(configurations.runtime)
  }
}

```

This is just a gist of things, and I might have misunderstood you

---

<div class="post-metadata">

**Author:** ![rusbik91](https://avatars.discourse-cdn.com/v4/letter/r/4bbf92/32.png) [@rusbik91](https://discuss.gradle.org/u/rusbik91)\
**Post date:** [August 18, 2015, 7:57am UTC](https://discuss.gradle.org/t/multiple-projects-building/11204/3 "2015-08-18T07:57:52Z")

</div>

Thanks for response. I tried to use your suggestion:

> [@kkarlberg](#):
>
> project(‘:Project’) {  
> dependencies {  
> compile project(‘:jar1’)  
> compile project(‘:jar2’)  
> }  
> }

with gradlew Project:build, but gradle generated only Project.jar. The point is that i dont need Project.jar at all, I want i want is to split all of my projects to separate files. Expected files after build:  
Project\build\lib  
lib.jar  
jar1.jar  
jar2.jar

To be honest with you i came to java world from the c# and trying to repeat things that works there: if i build whole project consist of N subprojects in c# i will get N .dll-files on output. I dont really need to build one mega .dll file with all of my dependencies. How can i perform such scenario?

---

<div class="post-metadata">

**Author:** ![kkarlberg](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/kkarlberg/32/5203_2.png) [@kkarlberg](https://discuss.gradle.org/u/kkarlberg)\
**Post date:** [August 18, 2015, 8:18am UTC](https://discuss.gradle.org/t/multiple-projects-building/11204/4 "2015-08-18T08:18:34Z")

</div>

Sure, that’s the way it’s supposed to work… The .java files in Project/src/main/java (or whereever) is compiled using classes from jar1 project and jar2 project.

If you then want to run some main class in Project _all_ required jars will have to be provided as classpath to the java command (this is always slightly messy).

Let’s say “Project” is a _standard_ java application (aka something with a main-class) that you wish to run at some point I would suggest using the “application” plugin on the “Project” project. That will take care of all this for you…
