11import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2+ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
23
34plugins {
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-
1411allprojects {
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}
0 commit comments