@@ -10,10 +10,12 @@ plugins {
1010 id(" org.jetbrains.dokka" ) version " 0.9.17"
1111}
1212
13- val year: String by project
14- val gameName: String by project
13+ val gameName by extra { property(" socha.gameName" ) as String }
14+ val versions = arrayOf(" year" , " minor" , " patch" ).map { property(" socha.version.$it " ).toString().toInt() }
15+ val versionObject = KotlinVersion (versions[0 ], versions[1 ], versions[2 ])
16+ version = versions.joinToString(" ." ) { it.toString() }
17+ val year by extra { " 20${versionObject.major} " }
1518val game by extra { " ${gameName} _$year " }
16- version = year.substring(2 ) + " ." + property(" socha.version" )
1719println (" Current version: $version Game: $game " )
1820
1921val deployDir by extra { buildDir.resolve(" deploy" ) }
@@ -32,7 +34,7 @@ tasks {
3234 dependsOn(" :server:run" )
3335 group = mainGroup
3436 }
35-
37+
3638 val doc by creating(DokkaTask ::class ) {
3739 val includedProjects = arrayOf(" sdk" , " plugin" )
3840 mustRunAfter(includedProjects.map { " $it :classes" })
@@ -46,62 +48,61 @@ tasks {
4648 classpath = files(sourceSets.map { it.runtimeClasspath }.flatMap { it.files }.filter { it.exists() })
4749 }
4850 }
49-
51+
5052 val deploy by creating {
5153 dependsOn(doc)
5254 dependOnSubprojects()
5355 group = mainGroup
54- description = " Zips everything up for release into ./ build/deploy"
56+ description = " Zips everything up for release into build/deploy/ "
5557 }
56-
58+
5759 val release by creating {
5860 dependsOn(deploy)
5961 group = mainGroup
6062 description = " Prepares a new Release by bumping the version and creating a commit and a git tag"
6163 doLast {
62- val v = project.properties[" v" ]?.toString()?.takeIf { it.count { char -> char == ' .' } == 1 }
63- ? : throw InvalidUserDataException (" Die Flag -Pv=\" Version\" wird im Format X.X benötigt" )
64+ fun edit (original : String , version : String , new : Int ) =
65+ if (original.startsWith(" socha.version.$version " ))
66+ " socha.version.$version =${new.toString().padStart(2 , ' 0' )} "
67+ else original
68+
69+ var newVersion = version
70+ val filter: (String ) -> String = when {
71+ project.hasProperty(" manual" ) -> ({ it })
72+ project.hasProperty(" minor" ) -> ({
73+ newVersion = " ${versionObject.major} .${versionObject.minor + 1 } .0"
74+ edit(edit(it, " minor" , versionObject.minor + 1 ), " patch" , 0 )
75+ })
76+ project.hasProperty(" patch" ) -> ({
77+ newVersion = " ${versionObject.major} .${versionObject.minor} .${versionObject.patch + 1 } "
78+ edit(it, " patch" , versionObject.patch + 1 )
79+ })
80+ else -> throw InvalidUserDataException (" Gib entweder -Ppatch oder -Pminor an, um die Versionsnummer automatisch zu inkrementieren, oder ändere sie selbst in gradle.properties und gib dann -Pmanual an!" )
81+ }
6482 val desc = project.properties[" desc" ]?.toString()
65- ? : throw InvalidUserDataException (" Die Flag -Pdesc=\" Beschreibung dieser Version\" wird benötigt" )
66- val version = " ${year.substring(2 )} .$v "
67- println (" Version: $version " )
83+ ? : throw InvalidUserDataException (" Das Argument -Pdesc=\" Beschreibung dieser Version\" wird benötigt" )
84+
85+ val propsFile = file(" gradle.properties" )
86+ propsFile.writeText(
87+ propsFile.readLines().joinToString(" \n " ) { filter(it) }
88+ )
89+
90+ println (" Version: $newVersion " )
6891 println (" Beschreibung: $desc " )
69- file(" gradle.properties" ).writeText(file(" gradle.properties" ).readText()
70- .replace(Regex (" socha.version.*" ), " socha.version = $v " ))
7192 exec { commandLine(" git" , " add" , " gradle.properties" ) }
72- exec { commandLine(" git" , " commit" , " -m" , version , " --no-verify" ) }
73- exec { commandLine(" git" , " tag" , version , " -m" , desc) }
93+ exec { commandLine(" git" , " commit" , " -m" , newVersion , " --no-verify" ) }
94+ exec { commandLine(" git" , " tag" , newVersion , " -m" , desc) }
7495 exec { commandLine(" git" , " push" , " --follow-tags" ) }
75- println ("""
76- ===================================================
77- Fertig! Jetzt noch folgende Schritte ausfuehren:
78-
79- 1. Ein Release für die GUI erstellen
80-
81- 2. Auf der Wettkampfseite (http://contest.software-challenge.de) was unter Aktuelles schreiben:
82-
83- Eine neue Version der Software ist verfügbar: $desc
84- Dafür gibt es einen neuen Server und Simpleclient im [Download-Bereich der Website][1].
85-
86- [1]: http://www.software-challenge.de/downloads/
87-
88- 3. Etwas im Discord-Server in #news schreiben:
89- Good news @everyone! Neue Version der Software: http://www.software-challenge.de/downloads/
90- Highlights: $desc
91-
92- Siehe auch https://www.notion.so/softwarechallenge/Creating-a-Release-1732217fb0234469b3d5653436f357db
93- ===================================================""" .trimIndent())
9496 }
9597 }
96-
98+
9799 val maxGameLength = 150L
98-
100+
99101 val clearTestLogs by creating(Delete ::class ) {
100102 delete(testLogDir)
101103 }
102-
104+
103105 val testGame by creating {
104- enabled = false
105106 dependsOn(clearTestLogs, " :server:deploy" , " :player:deploy" )
106107 doFirst {
107108 testLogDir.mkdirs()
@@ -147,17 +148,16 @@ tasks {
147148 println (" Successfully played a game using the deployed server & client!" )
148149 }
149150 }
150-
151+
151152 val testTestClient by creating {
152- enabled = false
153153 dependsOn(clearTestLogs, " :server:deploy" )
154154 val testClientGames = 3
155155 doFirst {
156156 testLogDir.mkdirs()
157157 val unzipped = testLogDir.resolve(" software-challenge-server" )
158158 unzipped.deleteRecursively()
159159 Runtime .getRuntime().exec(" unzip software-challenge-server.zip -d $unzipped " , null , deployDir).waitFor()
160-
160+
161161 println (" Testing TestClient..." )
162162 val testClient = ProcessBuilder (
163163 project(" test-client" ).tasks.getByName<ScriptsTask >(" createScripts" ).content.split(" " ) +
@@ -175,12 +175,14 @@ tasks {
175175 }
176176 }
177177 }
178-
178+
179179 val integrationTest by creating {
180- dependsOn(testGame, testTestClient)
180+ enabled = versionObject.minor > 0
181+ if (enabled)
182+ dependsOn(testGame, testTestClient)
181183 group = mainGroup
182184 }
183-
185+
184186 clean {
185187 dependOnSubprojects()
186188 group = mainGroup
@@ -255,13 +257,13 @@ allprojects {
255257
256258project(" sdk" ) {
257259 sourceSets.main.get().java.srcDirs(" src/framework" , " src/server-api" )
258-
260+
259261 dependencies {
260262 api(kotlin(" stdlib" ))
261263 api(" com.thoughtworks.xstream" , " xstream" , " 1.4.11.1" )
262264 api(" jargs" , " jargs" , " 1.0" )
263265 api(" ch.qos.logback" , " logback-classic" , " 1.2.3" )
264-
266+
265267 implementation(" org.hamcrest" , " hamcrest-core" , " 2.1" )
266268 implementation(" net.sf.kxml" , " kxml2" , " 2.3.0" )
267269 implementation(" xmlpull" , " xmlpull" , " 1.1.3.1" )
@@ -273,14 +275,14 @@ project("plugin") {
273275 main.get().java.srcDirs(" src/client" , " src/server" , " src/shared" )
274276 test.get().java.srcDir(" src/test" )
275277 }
276-
278+
277279 dependencies {
278280 api(project(" :sdk" ))
279-
281+
280282 testImplementation(" junit" , " junit" , " 4.12" )
281283 testImplementation(" io.kotlintest" , " kotlintest-runner-junit5" , " 3.3.2" )
282284 }
283-
285+
284286 tasks.jar.get().archiveBaseName.set(game)
285287}
286288
0 commit comments