Skip to content

Commit 440dbae

Browse files
committed
fix(player): update buildscripts
1 parent aff6075 commit 440dbae

File tree

5 files changed

+33
-30
lines changed

5 files changed

+33
-30
lines changed

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ The version should always be in sync with the [GUI](https://github.com/software-
77

88
- The major version `x` corresponds to the year of the contest and thus only changes once a year
99
- `y` is bumped for any major updates or backwards-incompatible changes.
10-
A `y` version of 0 marks the beta of the current year.
10+
A `y` version of 0 marks the beta of the current year
11+
and likely contains breaking changes between patches.
1112

12-
## [22.1.0](https://github.com/software-challenge/backend/commits/22.1.0) - 2021-09
13+
## [22.1.0](https://github.com/software-challenge/backend/commits/22.1.0) - 2021-08
14+
- Fix player buildscripts
1315

1416
## [22.0.2](https://github.com/software-challenge/backend/commits/22.0.2) - 2021-07-16
1517
- Update documentation links

player/build.gradle.kts

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import java.time.Duration
12
import org.gradle.internal.os.OperatingSystem
23

34
plugins {
@@ -61,7 +62,8 @@ tasks {
6162
from("src")
6263
into("src")
6364
}, copySpec {
64-
from(configurations.default, arrayOf("sdk", "plugin").map { project(":$it").getTasksByName("sourcesJar", false).single().outputs.files })
65+
from(configurations.default, arrayOf("sdk", "plugin")
66+
.map { project(":$it").getTasksByName("sourcesJar", false) })
6567
into("lib")
6668
})
6769
}
@@ -86,35 +88,30 @@ tasks {
8688
archiveFileName.set("simpleclient-$gameName-src.zip")
8789
}
8890

89-
val playerTest by creating(Copy::class) {
91+
val playerTest by creating(Exec::class) {
9092
group = "verification"
91-
from(prepareZip)
93+
dependsOn(prepareZip)
9294
val execDir = testingDir.resolve("player")
93-
into(execDir)
9495
doFirst {
95-
execDir.deleteRecursively()
96-
execDir.mkdirs()
96+
delete { delete(execDir) }
97+
copy {
98+
from(prepareZip)
99+
into(execDir)
100+
}
101+
// required by gradle to distinguish the test build
102+
execDir.resolve("settings.gradle").createNewFile()
97103
}
98104

105+
timeout.set(Duration.ofMinutes(1))
106+
workingDir(execDir)
107+
executable = "./gradlew${if (OperatingSystem.current().isWindows) ".bat" else ""}"
108+
args("shadowJar", "--quiet", "--offline")
109+
99110
doLast {
100-
// required by gradle to distinguish the test build from
101-
execDir.resolve("settings.gradle").createNewFile()
102-
val command = arrayListOf(
103-
"./gradlew${if(OperatingSystem.current().isWindows) ".bat" else ""}",
104-
"shadowJar", "--quiet", "--offline")
105-
val process = ProcessBuilder(command).directory(execDir)
106-
.redirectOutput(execDir.resolve("player-shadowJar-build.log"))
107-
.redirectError(execDir.resolve("player-shadowJar-err.log"))
108-
.start()
109-
val timeout = 5L
110-
if(process.waitFor(timeout, TimeUnit.MINUTES)) {
111-
val result = process.exitValue()
112-
if(result != 0 || !execDir.resolve("${game}_client.jar").exists())
113-
throw Exception("Player was not generated by shipped gradlew script!")
114-
} else {
115-
throw Exception("Gradlew shadowJar for player did not finish within $timeout minutes!")
111+
exec {
112+
commandLine("java", "-jar", execDir.resolve("${game}_client.jar"), "--verify")
113+
standardOutput = org.apache.commons.io.output.NullOutputStream.NULL_OUTPUT_STREAM
116114
}
117-
println("Successfully generated client jar from shipped source")
118115
}
119116
}
120117

player/configuration/build.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
<target name="build-jar" depends="compile">
5656
<jar destfile="${jar.dir}/${ant.project.name}.jar"
5757
basedir="${classes.dir}">
58+
<fileset dir="src/resources" includes="**" />
5859
<manifest>
5960
<attribute name="Main-Class" value="${main-class}"/>
6061
<attribute name="Class-Path" value="${jar.classpath}"/>
@@ -63,8 +64,6 @@
6364
<copy todir="${jar.dir}/lib" >
6465
<path refid="classpath.libs" />
6566
</copy>
66-
<copy file="src/logback.xml"
67-
tofile="${jar.dir}/logback.xml"/>
6867
</target>
6968

7069
<target name="build" depends="build-jar" description="Build only"/>

player/src/main/sc/player2021/Starter.java renamed to player/src/main/sc/player2022/Starter.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package sc.player2021;
1+
package sc.player2022;
22

33
import jargs.gnu.CmdLineParser;
44
import org.slf4j.Logger;
@@ -7,7 +7,8 @@
77
import sc.networking.clients.LobbyClient;
88
import sc.player.IGameHandler;
99
import sc.player.IPlayerClient;
10-
import sc.player2021.logic.Logic;
10+
import sc.player2022.logic.Logic;
11+
import sc.plugin2022.util.Constants;
1112
import sc.shared.SharedConfiguration;
1213

1314
import java.io.File;
@@ -44,6 +45,7 @@ public static void main(String[] args) {
4445
CmdLineParser.Option portOption = parser.addIntegerOption('p', "port");
4546
CmdLineParser.Option reservationOption = parser.addStringOption('r', "reservation");
4647
CmdLineParser.Option roomOption = parser.addStringOption("room");
48+
CmdLineParser.Option verifyOption = parser.addBooleanOption("verify");
4749

4850
try {
4951
// Parameter auslesen
@@ -54,6 +56,9 @@ public static void main(String[] args) {
5456
System.exit(2);
5557
}
5658

59+
if(parser.getOptionValue(verifyOption) == Boolean.TRUE)
60+
System.exit(0);
61+
5762
// Parameter laden
5863
String host = (String) parser.getOptionValue(hostOption, "localhost");
5964
int port = (Integer) parser.getOptionValue(portOption, SharedConfiguration.DEFAULT_PORT);

player/src/main/sc/player2021/logic/Logic.java renamed to player/src/main/sc/player2022/logic/Logic.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package sc.player2021.logic;
1+
package sc.player2022.logic;
22

33
import org.slf4j.Logger;
44
import org.slf4j.LoggerFactory;

0 commit comments

Comments
 (0)