Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/development/build-overview-and-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
Currently, the build uses a mix of Gradle tasks and bash scripts.
Gradle plugins used by the build are located in `/gradle/build-logic`.

The build uses the Gradle Kotlin DSL.
This make the build easier to maintain by increasing the completion and refactoring assistance the IDE is able to provide.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"makes"


## Convention Plugins

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.
Expand All @@ -24,8 +27,6 @@ The fixture in `:game-app:game-core` includes map data present in `/game-app/gam

To continue to improve build speeds and make the build structure more idiomatic, some near future work should:

- Convert all build scripts to Kotlin (IN PROGRESS).
This will make the build easier to maintain by increasing the completion and refactoring assistance the IDE is able to provide.
- Remove the use of `subprojects` and `allprojects` and replace these with Gradle [Convention Plugins](https://docs.gradle.org/current/userguide/implementing_gradle_plugins_convention.html#header).
This will make the build easier to maintain by avoiding the pitfalls of cross-project configuration, it will prevent difficulties updating to future Gradle versions, and it will prepare the build to take advantage of future Gradle features like [Isolated Projects](https://docs.gradle.org/current/userguide/isolated_projects.html#header) that will further increase build speed.
- Avoid creating empty projects in folders such as `game-app`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ version = System.getenv("JAR_VERSION")

publishing {
publications {
maven(MavenPublication) {
artifact(tasks.named(sourceSets.main.jarTaskName)) {
extension 'jar'
create<MavenPublication>("maven") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we work with constants here for which their names can help to understand better what this is?

artifact(tasks.named(sourceSets.main.get().jarTaskName)) {
extension = "jar"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't we have a constant for that already?

}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
plugins {
id("triplea-java-library")
id 'java-test-fixtures'
id("java-test-fixtures")
}

dependencies {
implementation project(":game-app:domain-data")
implementation project(":game-app:map-data")
implementation project(":game-app:game-relay-server")
implementation project(":http-clients:lobby-client")
implementation project(":lib:java-extras")
implementation project(":lib:swing-lib")
implementation project(":lib:websocket-client")
implementation project(":lib:xml-reader")
testImplementation project(":lib:swing-lib-test-support")
testImplementation project(":lib:test-common")
implementation(project(":game-app:domain-data"))
implementation(project(":game-app:map-data"))
implementation(project(":game-app:game-relay-server"))
implementation(project(":http-clients:lobby-client"))
implementation(project(":lib:java-extras"))
implementation(project(":lib:swing-lib"))
implementation(project(":lib:websocket-client"))
implementation(project(":lib:xml-reader"))
testImplementation(project(":lib:swing-lib-test-support"))
testImplementation(project(":lib:test-common"))
// Configures mockito to use the legacy "subclass mock maker"
// see https://github.com/mockito/mockito/releases/tag/v5.0.0 for more information

Expand Down
127 changes: 0 additions & 127 deletions game-app/game-headed/build.gradle

This file was deleted.

130 changes: 130 additions & 0 deletions game-app/game-headed/build.gradle.kts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is just a copy of the previous build.gradle, right?
Should we try to declare constants there as well with another commit or another PR?
I'd suggest to have at least constants for what is "TripleA configuration" like paths even though we keep strings for what is "Kotlin configuration" like plugins. What do you think?

Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
import com.install4j.gradle.Install4jTask
import de.undercouch.gradle.tasks.download.Download

plugins {
id("triplea-java-library")
id("application")
alias(libs.plugins.shadow)
alias(libs.plugins.install4j)
alias(libs.plugins.download)
}

application {
mainClass.set("org.triplea.game.client.HeadedGameRunner")
applicationDefaultJvmArgs = listOf(
//This flag fixes touch gestures in Java-21;Technical Reference: https://stackoverflow.com/questions/48535595/what-replaces-gestureutilities-in-java-9
"--add-opens=java.desktop/com.apple.eawt.event=ALL-UNNAMED"
)
}

val releasesDir = project.layout.buildDirectory.file("releases").get().asFile

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

fun getCommitNumber(): String {
return providers.exec {
commandLine("git", "rev-list", "--count", "HEAD")
}.standardOutput.asText.get().trim()
}

val releaseVersion = getProductVersion() + "+" + getCommitNumber()

dependencies {
implementation(project(":game-app:ai"))
implementation(project(":game-app:domain-data"))
implementation(project(":game-app:game-core"))
implementation(project(":game-app:map-data"))
implementation(project(":http-clients:lobby-client"))
implementation(project(":lib:feign-common"))
implementation(project(":lib:java-extras"))
implementation(project(":lib:swing-lib"))
implementation(project(":lib:websocket-client"))
testImplementation(project(":lib:test-common"))
}

tasks.named<Jar>("jar") {
archiveBaseName.set("$group-$name")
manifest {
attributes("Main-Class" to application.mainClass.get())
}
}

val assetsZipFileName = "game_headed_assets.zip"
val downloadAssets = tasks.register<Download>("downloadAssets") {
src("https://github.com/triplea-game/assets/releases/download/47/$assetsZipFileName")
dest(project.layout.buildDirectory.dir("downloads/assets-zip"))
overwrite(false)
onlyIfModified(true)
quiet(true)
}

val unzipAssets = tasks.register<Copy>("unzipAssets") {
from(zipTree(downloadAssets.map { it.outputs.files.singleFile }))
into(project.layout.buildDirectory.dir("assets"))
}

tasks.named<ProcessResources>("processResources") {
from(unzipAssets) {
into("assets")
}
}

val platformInstallers = tasks.register<Install4jTask>("platformInstallers") {
group = "release"
description = "creates installer files using install4j (eg: install.exe)"
dependsOn(tasks.named("shadowJar"))

projectFile = file("build.install4j")
release = releaseVersion
license = System.getenv("INSTALL4J_LICENSE_KEY")
doLast {
ant.withGroovyBuilder {
"chmod"("dir" to releasesDir, "perm" to "+x", "includes" to "*.sh")
}
}
}

val portableInstaller = tasks.register<Zip>("portableInstaller") {
group = "release"

from(file(".triplea-root"))
from(unzipAssets) {
into("assets")
}
from(file("dice_servers")) {
into("dice_servers")
}
from(tasks.named("shadowJar")) {
into("bin")
}
}

tasks.register<Copy>("release") {
group = "release"
dependsOn(platformInstallers)

from(portableInstaller)
from(file("$releasesDir/TripleA_${releaseVersion}_macos.dmg"))
from(file("$releasesDir/TripleA_${releaseVersion}_unix.sh"))
from(file("$releasesDir/TripleA_${releaseVersion}_windows-64bit.exe"))
into(file(project.layout.buildDirectory.dir("artifacts")))

doFirst {
inputs.files.forEach {
if (!it.exists()) {
throw GradleException("artifact '$it' does not exist")
}
}
}
}

tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
dependsOn(unzipAssets)

// "archiveVersion" sets the version number on packaged jar files
// eg: "2.6+105234" in "lobby-server-2.6+50370c.jar"
archiveVersion.set(releaseVersion)
archiveClassifier.set("")
}
73 changes: 0 additions & 73 deletions game-app/game-headless/build.gradle

This file was deleted.

Loading