Skip to content

Commit 12cfc5d

Browse files
authored
Merge branch 'develop' into main
2 parents 947e8b4 + ad0341d commit 12cfc5d

File tree

10 files changed

+142
-65
lines changed

10 files changed

+142
-65
lines changed

build.gradle.kts

Lines changed: 78 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
23

34
plugins {
45
alias(libs.plugins.kotlin)
@@ -7,13 +8,9 @@ plugins {
78
`maven-publish`
89
}
910

10-
val baseVersion = "0.0.30"
11-
val commitHash = System.getenv("COMMIT_HASH")
12-
val snapshotversion = "${baseVersion}-dev.$commitHash"
13-
1411
allprojects {
1512
group = "app.simplecloud.controller"
16-
version = if (commitHash != null) snapshotversion else baseVersion
13+
version = determineVersion()
1714

1815
repositories {
1916
mavenCentral()
@@ -33,51 +30,35 @@ subprojects {
3330
implementation(rootProject.libs.kotlin.jvm)
3431
}
3532

36-
publishing {
37-
repositories {
38-
maven {
39-
name = "simplecloud"
40-
url = uri("https://repo.simplecloud.app/snapshots/")
41-
credentials {
42-
username = System.getenv("SIMPLECLOUD_USERNAME")?: (project.findProperty("simplecloudUsername") as? String)
43-
password = System.getenv("SIMPLECLOUD_PASSWORD")?: (project.findProperty("simplecloudPassword") as? String)
44-
}
45-
authentication {
46-
create<BasicAuthentication>("basic")
47-
}
48-
}
49-
}
50-
51-
publications {
52-
// Not publish controller-runtime
53-
if (project.name == "controller-runtime") {
54-
return@publications
55-
}
56-
57-
create<MavenPublication>("mavenJava") {
58-
from(components["java"])
59-
}
60-
}
61-
}
62-
6333
java {
6434
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
6535
}
6636

6737
kotlin {
6838
jvmToolchain(21)
39+
6940
compilerOptions {
41+
languageVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
7042
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
43+
jvmTarget.set(JvmTarget.JVM_21)
7144
}
7245
}
7346

74-
tasks.named("shadowJar", ShadowJar::class) {
75-
mergeServiceFiles()
76-
archiveFileName.set("${project.name}.jar")
77-
}
47+
tasks {
48+
withType<JavaCompile> {
49+
options.isFork = true
50+
options.isIncremental = true
51+
}
52+
53+
named("shadowJar", ShadowJar::class) {
54+
mergeServiceFiles()
7855

79-
tasks.test {
80-
useJUnitPlatform()
56+
archiveFileName.set("${project.name}.jar")
57+
}
58+
59+
test {
60+
useJUnitPlatform()
61+
}
8162
}
8263

8364
centralPortal {
@@ -89,7 +70,7 @@ subprojects {
8970
pom {
9071
name.set("SimpleCloud controller")
9172
description.set("The heart of SimpleCloud v3")
92-
url.set("https://github.com/theSimpleCloud/simplecloud-controller")
73+
url.set("https://github.com/simplecloudapp/simplecloud-controller")
9374

9475
developers {
9576
developer {
@@ -108,18 +89,72 @@ subprojects {
10889
}
10990
}
11091
scm {
111-
url.set("https://github.com/theSimpleCloud/simplecloud-controller.git")
112-
connection.set("git:git@github.com:theSimpleCloud/simplecloud-controller.git")
92+
url.set("https://github.com/simplecloudapp/simplecloud-controller.git")
93+
connection.set("git:git@github.com:simplecloudapp/simplecloud-controller.git")
94+
}
95+
}
96+
}
97+
98+
publishing {
99+
repositories {
100+
maven {
101+
name = "simplecloud"
102+
url = uri(determineRepositoryUrl())
103+
credentials {
104+
username = System.getenv("SIMPLECLOUD_USERNAME")
105+
?: (project.findProperty("simplecloudUsername") as? String)
106+
password = System.getenv("SIMPLECLOUD_PASSWORD")
107+
?: (project.findProperty("simplecloudPassword") as? String)
108+
}
109+
authentication {
110+
create<BasicAuthentication>("basic")
111+
}
112+
}
113+
}
114+
115+
publications {
116+
create<MavenPublication>("mavenJava") {
117+
from(components["java"])
113118
}
114119
}
115120
}
116121

117122
signing {
118-
if (commitHash != null) {
123+
val releaseType = project.findProperty("releaseType")?.toString() ?: "snapshot"
124+
if (releaseType != "release") {
119125
return@signing
120126
}
121127

128+
if (hasProperty("signingPassphrase")) {
129+
val signingKey: String? by project
130+
val signingPassphrase: String? by project
131+
useInMemoryPgpKeys(signingKey, signingPassphrase)
132+
} else {
133+
useGpgCmd()
134+
}
135+
122136
sign(publishing.publications)
123-
useGpgCmd()
137+
}
138+
}
139+
140+
fun determineVersion(): String {
141+
val baseVersion = project.findProperty("baseVersion")?.toString() ?: "0.0.0"
142+
val releaseType = project.findProperty("releaseType")?.toString() ?: "snapshot"
143+
val commitHash = System.getenv("COMMIT_HASH") ?: "local"
144+
145+
return when (releaseType) {
146+
"release" -> baseVersion
147+
"rc" -> "$baseVersion-rc.$commitHash"
148+
"snapshot" -> "$baseVersion-SNAPSHOT.$commitHash"
149+
else -> "$baseVersion-SNAPSHOT.local"
150+
}
151+
}
152+
153+
fun determineRepositoryUrl(): String {
154+
val baseUrl = "https://repo.simplecloud.app/"
155+
return when (project.findProperty("releaseType")?.toString() ?: "snapshot") {
156+
"release" -> "$baseUrl/releases"
157+
"rc" -> "$baseUrl/rc"
158+
else -> "$baseUrl/snapshots"
124159
}
125160
}

controller-api/build.gradle.kts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
1+
//import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
22

33
dependencies {
44
api(project(":controller-shared"))
55
}
66

7-
tasks.named("shadowJar", ShadowJar::class) {
8-
mergeServiceFiles()
9-
relocate("com", "app.simplecloud.external.com")
10-
relocate("google", "app.simplecloud.external.google")
11-
relocate("io", "app.simplecloud.external.io")
12-
relocate("org", "app.simplecloud.external.org")
13-
relocate("javax", "app.simplecloud.external.javax")
14-
relocate("android", "app.simplecloud.external.android")
15-
relocate("build.buf.gen.simplecloud", "app.simplecloud.buf")
16-
archiveFileName.set("${project.name}.jar")
17-
}
7+
//tasks.named("shadowJar", ShadowJar::class) {
8+
// mergeServiceFiles()
9+
//
10+
// relocate("com", "app.simplecloud.external.com")
11+
// relocate("google", "app.simplecloud.external.google")
12+
// relocate("io", "app.simplecloud.external.io")
13+
// relocate("org", "app.simplecloud.external.org")
14+
// relocate("javax", "app.simplecloud.external.javax")
15+
// relocate("android", "app.simplecloud.external.android")
16+
// relocate("build.buf.gen.simplecloud", "app.simplecloud.buf")
17+
//
18+
// archiveFileName.set("${project.name}.jar")
19+
//}

controller-api/src/main/kotlin/app/simplecloud/controller/api/ServerApi.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ interface ServerApi {
107107
stopCause: ServerStopCause = ServerStopCause.API_STOP
108108
): CompletableFuture<List<Server>>
109109

110+
/**
111+
* @param server the [Server] to update.
112+
* @return the updated [Server].
113+
*/
114+
fun updateServer(server: Server): CompletableFuture<Server>
115+
110116
/**
111117
* @param id the id of the server.
112118
* @param state the new state of the server.
@@ -218,6 +224,12 @@ interface ServerApi {
218224
stopCause: ServerStopCause = ServerStopCause.API_STOP
219225
): List<Server>
220226

227+
/**
228+
* @param server the [Server] to update.
229+
* @return the updated [Server].
230+
*/
231+
suspend fun updateServer(server: Server): Server
232+
221233
/**
222234
* @param id the id of the server.
223235
* @param state the new state of the server.

controller-api/src/main/kotlin/app/simplecloud/controller/api/impl/coroutines/ServerApiCoroutineImpl.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@ class ServerApiCoroutineImpl(
120120
}
121121
}
122122

123+
override suspend fun updateServer(server: Server): Server {
124+
return Server.fromDefinition(
125+
serverServiceStub.updateServer(updateServerRequest {
126+
this.server = server.toDefinition()
127+
})
128+
)
129+
}
130+
123131
override suspend fun updateServerState(id: String, state: ServerState): Server {
124132
return Server.fromDefinition(
125133
serverServiceStub.updateServerState(

controller-api/src/main/kotlin/app/simplecloud/controller/api/impl/future/ServerApiFutureImpl.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,16 @@ class ServerApiFutureImpl(
133133
}
134134
}
135135

136+
override fun updateServer(server: Server): CompletableFuture<Server> {
137+
return serverServiceStub.updateServer(
138+
UpdateServerRequest.newBuilder()
139+
.setServer(server.toDefinition())
140+
.build()
141+
).toCompletable().thenApply {
142+
return@thenApply Server.fromDefinition(it)
143+
}
144+
}
145+
136146
override fun updateServerState(id: String, state: ServerState): CompletableFuture<Server> {
137147
return serverServiceStub.updateServerState(
138148
UpdateServerStateRequest.newBuilder()

controller-runtime/build.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ dependencies {
88
api(project(":controller-shared"))
99
api(libs.bundles.jooq)
1010
api(libs.sqlite.jdbc)
11-
jooqCodegen(libs.jooq.meta.extensions)
11+
1212
implementation(libs.simplecloud.metrics)
1313
implementation(libs.bundles.log4j)
1414
implementation(libs.clikt)
1515
implementation(libs.spring.crypto)
1616
implementation(libs.spotify.completablefutures)
1717
implementation(libs.envoy.controlplane)
18+
19+
jooqCodegen(libs.jooq.meta.extensions)
1820
}
1921

2022
application {

controller-runtime/src/main/kotlin/app/simplecloud/controller/runtime/YamlDirectoryRepository.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ abstract class YamlDirectoryRepository<E, I>(
140140
if (entity != null) {
141141
watcherEvents.onDelete(entity)
142142
}
143-
deleteFile(resolvedPath.toFile())
144143
}
145144
}
146145
}

controller-runtime/src/main/kotlin/app/simplecloud/controller/runtime/server/ServerRepository.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@ class ServerRepository(
2222
) : LoadableRepository<Server, String> {
2323

2424
override suspend fun find(identifier: String): Server? {
25-
return database.context.selectFrom(CLOUD_SERVERS)
25+
return database.context.selectFrom(CLOUD_SERVERS)
2626
.where(CLOUD_SERVERS.UNIQUE_ID.eq(identifier))
2727
.limit(1)
2828
.awaitFirstOrNull()
2929
?.let { record -> mapCloudServersRecordToServer(record) }
3030
}
3131

32-
3332
suspend fun findServerByNumerical(group: String, id: Int): Server? {
3433
return database.context.selectFrom(CLOUD_SERVERS)
3534
.where(
@@ -121,7 +120,6 @@ class ServerRepository(
121120
}
122121
}
123122

124-
@Synchronized
125123
override fun save(element: Server) {
126124
numericalIdRepository.saveNumericalId(element.group, element.numericalId)
127125

controller-runtime/src/main/kotlin/app/simplecloud/controller/runtime/server/ServerService.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class ServerService(
6060
return stopServer(server.toDefinition(), request.stopCause)
6161
} catch (e: Exception) {
6262
throw StatusException(
63-
Status.INTERNAL.withDescription("Error occured whilest cleaning up stopped server: ").withCause(e)
63+
Status.INTERNAL.withDescription("Error occurred whilst cleaning up stopped server: ").withCause(e)
6464
)
6565
}
6666
}
@@ -216,7 +216,9 @@ class ServerService(
216216
startedServers.add(server)
217217
}
218218
} catch (e: Exception) {
219-
throw StatusException(Status.INTERNAL.withDescription("Error whilst starting multiple servers").withCause(e))
219+
throw StatusException(
220+
Status.INTERNAL.withDescription("Error whilst starting multiple servers").withCause(e)
221+
)
220222
}
221223

222224
return StartMultipleServerResponse.newBuilder()
@@ -245,7 +247,6 @@ class ServerService(
245247
val server = buildServer(group, numericalId)
246248
serverRepository.save(server)
247249
val stub = host.stub ?: throw StatusException(Status.INTERNAL.withDescription("Server host has no stub"))
248-
serverRepository.save(server)
249250
try {
250251
val result = stub.startServer(
251252
ServerHostStartServerRequest.newBuilder()
@@ -263,7 +264,7 @@ class ServerService(
263264
}
264265
}
265266

266-
private suspend fun publishServerStartEvents(server: ServerDefinition, startCause: ServerStartCause) {
267+
private fun publishServerStartEvents(server: ServerDefinition, startCause: ServerStartCause) {
267268
pubSubClient.publish(
268269
"event", ServerStartEvent.newBuilder()
269270
.setServer(server)
@@ -380,7 +381,7 @@ class ServerService(
380381

381382
try {
382383
timeout?.let {
383-
group.timeout = GroupTimeout(it);
384+
group.timeout = GroupTimeout(it)
384385
}
385386

386387
groupServers.forEach { server ->

gradle.properties

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
baseVersion=0.0.30
2+
org.gradle.parallel=true
3+
org.gradle.caching=true
4+
org.gradle.configureondemand=true
5+
org.gradle.daemon=true
6+
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError
7+
kotlin.incremental=true
8+
kotlin.incremental.js=true
9+
kotlin.caching.enabled=true
10+
kotlin.parallel.tasks.in.project=true

0 commit comments

Comments
 (0)