Skip to content

Commit 45f5b9d

Browse files
committed
chore(gradle): do not require git for running the project
The :server:dockerImage task used to execute git during the configuration phase, which meant git was required for using gradle.
1 parent b1ca1c8 commit 45f5b9d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

server/build.gradle.kts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ tasks {
6161
archiveBaseName.set("software-challenge-server")
6262
from(project(":test-client").buildDir.resolve("libs"), project(":player").buildDir.resolve("libs"), runnableDir)
6363
doFirst {
64-
runnableDir.resolve("version").writeText(Scanner(Runtime.getRuntime().exec("git rev-parse HEAD").inputStream).next())
64+
Runtime.getRuntime().exec(arrayOf("git", "rev-parse", "HEAD")).inputStream.copyTo(runnableDir.resolve("version").outputStream())
6565
}
6666
}
6767

@@ -75,9 +75,11 @@ tasks {
7575

7676
val dockerImage by creating(Exec::class) {
7777
dependsOn(makeRunnable)
78-
val tag = Runtime.getRuntime().exec(arrayOf("git", "rev-parse", "--short", "--verify", "HEAD")).inputStream.reader().readText().trim()
79-
val relativeRunnable = runnableDir.relativeTo(project.projectDir)
80-
commandLine("docker", "build", "--no-cache", "-t", "swc_game-server:latest", "-t", "swc_game-server:$tag", "--build-arg", "game_server_dir=$relativeRunnable", ".")
78+
doFirst {
79+
val tag = Runtime.getRuntime().exec(arrayOf("git", "rev-parse", "--short", "--verify", "HEAD")).inputStream.reader().readText().trim()
80+
val relativeRunnable = runnableDir.relativeTo(project.projectDir)
81+
commandLine("docker", "build", "--no-cache", "-t", "swc_game-server:latest", "-t", "swc_game-server:$tag", "--build-arg", "game_server_dir=$relativeRunnable", ".")
82+
}
8183
}
8284

8385
jar {

0 commit comments

Comments
 (0)