# Best practice for multi application project

**URL:** <https://discuss.gradle.org/t/best-practice-for-multi-application-project/39003>\
**Category:** Help/Discuss\
**Created:** [February 10, 2021, 10:51am UTC](https://discuss.gradle.org/t/best-practice-for-multi-application-project/39003 "2021-02-10T10:51:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Swas](https://avatars.discourse-cdn.com/v4/letter/s/df788c/32.png) [@Swas](https://discuss.gradle.org/u/Swas)\
**Post date:** [February 10, 2021, 10:51am UTC](https://discuss.gradle.org/t/best-practice-for-multi-application-project/39003/1 "2021-02-10T10:51:03Z")

</div>

Hello,

I’m a new Gradle user and I’d like to discuss my plan and get some feedback from you. I feel like I’m currently having a wrong understandment of Gradle regarding my idea.

I’d like to develop a software application which consists of multiple standalone applications. I found that Gradle supports multi-project builds but if I understand it correctly the multi-project build has only one “Main application”. The other subprojects can only be libraries. Is that correct?

My application consists of e.g. 3 standalone modules. I’d like to use gradle for the automatic testing etc. and when I use the run task I’ve imagined that Gradle will start up all 3 applications. Another reason is to only maintain one Git repository which contains the gradle root project with all it’s subprojects.

I appreciate your feedback and hints.

Thanks!

Edit: I forgot to mention that I’m trying to build a Java Application.

---

<div class="post-metadata">

**Author:** ![Chris\_Dore](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/chris_dore/32/7592_2.png) [@Chris\_Dore](https://discuss.gradle.org/u/Chris_Dore)\
**Post date:** [February 11, 2021, 2:49am UTC](https://discuss.gradle.org/t/best-practice-for-multi-application-project/39003/2 "2021-02-11T02:49:19Z")

</div>

> [@Swas](#):
>
> The other subprojects can only be libraries. Is that correct?

That is incorrect. You can have as many application or library subprojects as you need.

> [@Swas](#):
>
> when I use the run task I’ve imagined that Gradle will start up all 3 applications

FYI, the standard Gradle `application` plugin’s `run` task is blocking. If you want to start all 3 in parallel, you’ll probably want to create your own startup script that executes/manages them as background processes. This startup script could certainly be written in groovy/java/etc as a Gradle task.

---

<div class="post-metadata">

**Author:** ![Swas](https://avatars.discourse-cdn.com/v4/letter/s/df788c/32.png) [@Swas](https://discuss.gradle.org/u/Swas)\
**Post date:** [February 11, 2021, 7:10am UTC](https://discuss.gradle.org/t/best-practice-for-multi-application-project/39003/3 "2021-02-11T07:10:28Z")

</div>

Thank you for your reply.  
You are correct. I keep reading and reading but somehow (as a new user) I’m overwhelmed by the informations I’m reading.

Reading your answer it feels like i need to understand the plugins and tasks better.

Could you tell me, what’s the best way to add new subprojects to a multi-project?  
First I thought using `gradle init` is a good way e.g. First create a multi-project build and to add another subproject create a directory inside the root and inside the new folder do another `gradle init` (and then configure the settings etc.).  
Now I feel like simply adding a new folder with the predefined structure and simply placing a build.gradle is the better / correct way?

What are your thoughts on that?

---

<div class="post-metadata">

**Author:** ![Chris\_Dore](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/chris_dore/32/7592_2.png) [@Chris\_Dore](https://discuss.gradle.org/u/Chris_Dore)\
**Post date:** [February 11, 2021, 6:47pm UTC](https://discuss.gradle.org/t/best-practice-for-multi-application-project/39003/4 "2021-02-11T18:47:21Z")

</div>

> [@Swas](#):
>
> I’m overwhelmed

This is a common issue I hear from new Gradle users. Gradle is very flexible and with that comes complexity and a reasonably steep learning curve IMO. Just know that you’re not alone, many others have struggled as well 🙂

> [@Swas](#):
>
> what’s the best way to add new subprojects to a multi-project?

I have never used `gradle init`, I always manually create the necessary directory structure and files. Some people may find `gradIe init` useful, but since I have no experience I cannot recommend whether or not to use it.

---

<div class="post-metadata">

**Author:** ![Swas](https://avatars.discourse-cdn.com/v4/letter/s/df788c/32.png) [@Swas](https://discuss.gradle.org/u/Swas)\
**Post date:** [February 12, 2021, 1:15pm UTC](https://discuss.gradle.org/t/best-practice-for-multi-application-project/39003/5 "2021-02-12T13:15:44Z")

</div>

Thank you for your kind words.

> [@Chris\_Dore](#):
>
> I have never used `gradle init` , I always manually create the necessary directory structure and files.

I kinda had the same feeling about this. And think I’ll use the manual way aswell.

Appreciate your answers.  
Have a nice day!
