Skip to content

Commit 21e5afb

Browse files
committed
Explicitly state subproject location to avoid unintentionally creating empty projects
1 parent d4b5521 commit 21e5afb

22 files changed

Lines changed: 115 additions & 90 deletions

File tree

.github/workflows/build-headless-docker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- name: build headless docker container
2929
if: ${{ env.IS_MAIN_BUILD }}
3030
run: |
31-
./gradlew :game-app:game-headless:shadowJar
31+
./gradlew :game-headless:shadowJar
3232
BUILD_VERSION=$(game-app/run/.build/get-build-version)
3333
3434
docker build game-app/game-headless \

.github/workflows/upload-http-client-jars.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ jobs:
3333
BUILD_VERSION=$(game-app/run/.build/get-build-version)
3434
echo "JAR_VERSION=$BUILD_VERSION" | tee -a $GITHUB_ENV
3535
- name: Publish lobby client JAR
36-
run: ./gradlew :http-clients:lobby-client:publish :game-app:domain-data:publish :lib:java-extras:publish :lib:websocket-client:publish :lib:feign-common:publish
36+
run: ./gradlew :lobby-client:publish :domain-data:publish :java-extras:publish :websocket-client:publish :feign-common:publish
3737
env:
3838
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

docs/development/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ If you are new to Open Source & GitHub:
6868

6969
```bash
7070
# Build & Launch TripleA Game-Client
71-
./gradlew :game-app:game-headed:run
71+
./gradlew :game-headed:run
7272

7373
# Run all build checks
7474
./verify
@@ -80,21 +80,21 @@ If you are new to Open Source & GitHub:
8080
./gradlew test
8181

8282
# Run tests for a (sub)project
83-
./gradlew :game-app:game-core:test
83+
./gradlew :game-core:test
8484

8585
# Run a specific test
86-
./gradlew :game-app:game-core:test --tests games.strategy.triplea.UnitUtilsTest
86+
./gradlew :game-core:test --tests games.strategy.triplea.UnitUtilsTest
8787

8888
# Runs a specific test method
89-
./gradlew :game-app:game-core:test --tests games.strategy.triplea.UnitUtilsTest.multipleTransportedUnitsAreTransferred
89+
./gradlew :game-core:test --tests games.strategy.triplea.UnitUtilsTest.multipleTransportedUnitsAreTransferred
9090

9191
# Run specific tests using wildcard (be sure to use quotes around wildcard)
92-
./gradlew :game-app:game-core:test --tests 'games.strategy.triplea.UnitUtilsTest.*Units*'
92+
./gradlew :game-core:test --tests 'games.strategy.triplea.UnitUtilsTest.*Units*'
9393
```
9494

9595
To run tests even if there are no changes from the previous build, use the `--rerun-tasks` option:
9696
```
97-
./gradlew --rerun-tasks :game-app:game-core:test
97+
./gradlew --rerun-tasks :game-core:test
9898
```
9999

100100
## Run Formatting
@@ -137,7 +137,7 @@ save games from loading.
137137
This can be caused by missing resource files, such as images or icons.
138138

139139
The Gradle task `run` for `game-headed` will download and unzip game assets into the `game-headed` project's directory `/build/assests`.
140-
This directory will then be processed as a main resource, by the task `:game-app:game-headed:processResources`, in order to be packaged in the resulting project jar.
140+
This directory will then be processed as a main resource, by the task `:game-headed:processResources`, in order to be packaged in the resulting project jar.
141141
When the game starts, it expects to find the folder `assets` at the root of the classpath, so to load files use the class loader's method `getResourceAsStream()`.
142142
Since this is a resource file packaged in the library jar produced by this project, the working dir should **not** influence how assets are loaded.
143143

docs/development/build-overview-and-development.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ Gradle plugins used by the build are located in `/gradle/build-logic`.
66
The build uses the Gradle Kotlin DSL.
77
This make the build easier to maintain by increasing the completion and refactoring assistance the IDE is able to provide.
88

9+
## Build Structure
10+
11+
By explicitly specifying the physical location of nested subprojects in the root `settings.gradle.kts` file, the build is able to avoid [unintentionally creating empty projects](https://docs.gradle.org/current/userguide/best_practices_structuring_builds.html#avoid_empty_projects).
12+
These empty projects slow the build and make it more difficult to understand the project structure.
13+
This allows you to reference projects using non-hierarchical names, for example `:game-core` instead of `:game-app:game-core`.
14+
915
## Convention Plugins
1016

1117
The TripleA build defines Gradle [Convention Plugins](https://docs.gradle.org/current/userguide/implementing_gradle_plugins_convention.html#header) to avoid cross-project configuration and duplication of configuration.
@@ -18,10 +24,10 @@ It applies the `java-library` plugin and applies universal configuration, code c
1824

1925
## Test Fixtures
2026

21-
The `:game-app:game-core` project exposes [Test Fixtures](https://docs.gradle.org/current/userguide/java_testing.html#producing_and_using_test_fixtures_within_a_single_project) to share common testing code and resources between projects.
22-
Other projects (like `:game-app:ai`) can access these fixtures to use during testing by adding a dependency like `testImplementation(testFixtures(project(":game-app:game-core")))`.
27+
The `:game-core` project exposes [Test Fixtures](https://docs.gradle.org/current/userguide/java_testing.html#producing_and_using_test_fixtures_within_a_single_project) to share common testing code and resources between projects.
28+
Other projects (like `:ai`) can access these fixtures to use during testing by adding a dependency like `testImplementation(testFixtures(project(":game-core")))`.
2329

24-
The fixture in `:game-app:game-core` includes map data present in `/game-app/game-core/src/testFixtures/resources`, that can be loaded by tests via the `TestMapGameDataLoader` class and the `TestMapGameData` enum.
30+
The fixture in `:game-core` includes map data present in `/game-app/game-core/src/testFixtures/resources`, that can be loaded by tests via the `TestMapGameDataLoader` class and the `TestMapGameData` enum.
2531

2632
# Future Work
2733

game-app/ai/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ plugins {
33
}
44

55
dependencies {
6-
implementation(project(":game-app:game-core"))
7-
implementation(project(":lib:java-extras"))
6+
implementation(project(":game-core"))
7+
implementation(project(":java-extras"))
88

9-
testImplementation(testFixtures(project(":game-app:game-core")))
9+
testImplementation(testFixtures(project(":game-core")))
1010
}

game-app/game-core/build.gradle.kts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ plugins {
44
}
55

66
dependencies {
7-
implementation(project(":game-app:domain-data"))
8-
implementation(project(":game-app:map-data"))
9-
implementation(project(":game-app:game-relay-server"))
10-
implementation(project(":http-clients:lobby-client"))
11-
implementation(project(":lib:java-extras"))
12-
implementation(project(":lib:swing-lib"))
13-
implementation(project(":lib:websocket-client"))
14-
implementation(project(":lib:xml-reader"))
15-
testImplementation(project(":lib:swing-lib-test-support"))
16-
testImplementation(project(":lib:test-common"))
7+
implementation(project(":domain-data"))
8+
implementation(project(":map-data"))
9+
implementation(project(":game-relay-server"))
10+
implementation(project(":lobby-client"))
11+
implementation(project(":java-extras"))
12+
implementation(project(":swing-lib"))
13+
implementation(project(":websocket-client"))
14+
implementation(project(":xml-reader"))
15+
testImplementation(project(":swing-lib-test-support"))
16+
testImplementation(project(":test-common"))
1717
// Configures mockito to use the legacy "subclass mock maker"
1818
// see https://github.com/mockito/mockito/releases/tag/v5.0.0 for more information
1919

20-
testFixturesImplementation(project(":lib:java-extras"))
20+
testFixturesImplementation(project(":java-extras"))
2121
testFixturesImplementation(libs.bundles.junit)
2222
testFixturesImplementation(libs.bundles.mockito)
2323
testFixturesImplementation(libs.jsr305) {

game-app/game-headed/build.gradle.kts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ application {
2020
val releasesDir = project.layout.buildDirectory.file("releases").get().asFile
2121

2222
fun getProductVersion(): String {
23-
return project(":game-app").file("../game-app/run/.build/product-version.txt").readText().trim()
23+
return rootProject.file("game-app/run/.build/product-version.txt").readText().trim()
2424
}
2525

2626
fun getCommitNumber(): String {
@@ -32,16 +32,16 @@ fun getCommitNumber(): String {
3232
val releaseVersion = getProductVersion() + "+" + getCommitNumber()
3333

3434
dependencies {
35-
implementation(project(":game-app:ai"))
36-
implementation(project(":game-app:domain-data"))
37-
implementation(project(":game-app:game-core"))
38-
implementation(project(":game-app:map-data"))
39-
implementation(project(":http-clients:lobby-client"))
40-
implementation(project(":lib:feign-common"))
41-
implementation(project(":lib:java-extras"))
42-
implementation(project(":lib:swing-lib"))
43-
implementation(project(":lib:websocket-client"))
44-
testImplementation(project(":lib:test-common"))
35+
implementation(project(":ai"))
36+
implementation(project(":domain-data"))
37+
implementation(project(":game-core"))
38+
implementation(project(":map-data"))
39+
implementation(project(":lobby-client"))
40+
implementation(project(":feign-common"))
41+
implementation(project(":java-extras"))
42+
implementation(project(":swing-lib"))
43+
implementation(project(":websocket-client"))
44+
testImplementation(project(":test-common"))
4545
}
4646

4747
tasks.named<Jar>("jar") {

game-app/game-headless/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ docker compose-up
3131

3232
Example command to run a new headless game server from Gradle:
3333
```
34-
$ MAPS_FOLDER=/home/$USER/triplea/downloadedMaps ./gradlew :game-app:game-headless:run
34+
$ MAPS_FOLDER=/home/$USER/triplea/downloadedMaps ./gradlew :game-headless:run
3535
```
3636
See 'build.gradle' file to change things like lobby URI & bot port number.
3737

game-app/game-headless/build.gradle.kts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ application {
1212
}
1313

1414
dependencies {
15-
implementation(project(":http-clients:lobby-client"))
16-
implementation(project(":game-app:ai"))
17-
implementation(project(":game-app:domain-data"))
18-
implementation(project(":game-app:game-core"))
19-
implementation(project(":lib:java-extras"))
15+
implementation(project(":lobby-client"))
16+
implementation(project(":ai"))
17+
implementation(project(":domain-data"))
18+
implementation(project(":game-core"))
19+
implementation(project(":java-extras"))
2020
}
2121

2222
tasks.named<Jar>("jar") {

game-app/game-relay-server/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
}
44

55
dependencies {
6-
implementation(project(":lib:websocket-client"))
7-
implementation(project(":lib:websocket-server"))
8-
testImplementation(project(":lib:test-common"))
6+
implementation(project(":websocket-client"))
7+
implementation(project(":websocket-server"))
8+
testImplementation(project(":test-common"))
99
}

0 commit comments

Comments
 (0)