---
# System prepended metadata

title: Gradle Multiple Subject

---

# Gradle Multiple Subject
## Setup Goal
To create three subprojects, `server`, `client`, `shared`, your structure would look like this:
```
- risk (root directory)
--- shared
-------- .....
-------- build.gradle
--- client
--------- .....
--------- app
--------- build.gradle
--- server
---------- .....
---------- app
---------- build.gradle
------- settings.gradle
```

## How to Setup
1. `gradle init` to setup project
2. choose the options exactly as Drew's walkthrough, also remember to copy the right gradle.build to the right directory as Drew suggest
3. create two new directory: `mkdir server` and `mkdir client`
4. go in to `server` and `client` and do `gradle init` on each of the directory, and also choose the option according to Drew's walkthrough, and place the right gradle.build in right place
5. include subprojects to /risk/settings.gradle as the following
```
/risk/settings.gradle
rootProject.name = 'ece651-sp22-grp8-risk'
include 'shared', 'client:app', 'server:app'
```
6. cp root directory `/risk/build.gradle` to `client` and `server`
7. go to `server` directory remove `settings.gradle` and go to `client` to remove `settings.gradle`
8. go to `/client/app/gradle.build` and change your dependency closure to:
```
dependencies {
    // Use JUnit Jupiter for testing.
    testImplementation 'org.junit.jupiter:junit-jupiter:5.7.2'

    // This dependency is used by the application.
    implementation 'com.google.guava:guava:30.1.1-jre'
    testImplementation 'org.junit.platform:junit-platform-launcher:1.6.2'
    implementation project(':shared')
}
```
9. go to `/server/app/gradle.build` and change your dependency closure to:
```
dependencies {
    // Use JUnit Jupiter for testing.
    testImplementation 'org.junit.jupiter:junit-jupiter:5.7.2'

    // This dependency is used by the application.
    implementation 'com.google.guava:guava:30.1.1-jre'
    testImplementation 'org.junit.platform:junit-platform-launcher:1.6.2'
    implementation project(':shared')
}
```