Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(gradle): Upgrade to Gradle 8, Kotlin to 1.9.10 and move testConfig to separate subproject #421

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 10 additions & 18 deletions gradle/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import java.nio.file.Files
import java.util.concurrent.atomic.AtomicBoolean

plugins {
maven
kotlin("jvm") version "1.5.20"
kotlin("jvm") version "1.9.10"
id("org.jetbrains.dokka") version "0.10.1"
id("scripts-task")

Expand All @@ -22,21 +21,15 @@ version = versionObject.toString()
val year by extra { "20${versionObject.major}" }
val game by extra { "${gameName}_$year" }

val deployDir by extra { buildDir.resolve("deploy") }
val deployDir by extra { layout.buildDirectory.asFile.get().resolve("deploy") }
val deployedPlayer by extra { "simpleclient-$gameName-$version.jar" }
val testingDir by extra { buildDir.resolve("tests") }
val testingDir by extra { layout.buildDirectory.asFile.get().resolve("tests") }
val documentedProjects = listOf("sdk", "plugin")

val isBeta by extra { versionObject.minor == 0 }
val enableTestClient by extra { arrayOf("check", "testTestClient").any { gradle.startParameter.taskNames.contains(it) } || !isBeta }
val enableIntegrationTesting = !project.hasProperty("nointegration") && (!isBeta || enableTestClient)

val javaTargetVersion = JavaVersion.VERSION_1_8
val javaVersion = JavaVersion.current()
println("Current version: $version (Beta: $isBeta) Game: $game (Java Version: $javaVersion)")
if (javaVersion != javaTargetVersion)
System.err.println("Java version $javaTargetVersion is recommended - expect issues with generating documentation (consider '-x doc' if you don't care)")

val doAfterEvaluate = ArrayList<(Project) -> Unit>()
tasks {
val startServer by creating {
Expand Down Expand Up @@ -133,7 +126,7 @@ tasks {
)
.redirectOutput(testGameDir.resolve("server.log"))
.redirectError(testGameDir.resolve("server-err.log"))
.directory(project(":server").buildDir.resolve("runnable"))
.directory(project(":server").layout.buildDirectory.asFile.get().resolve("runnable"))
.start()
var i = 0
while(Files.size(testGameDir.resolve("server.log").toPath()) < 1000 && i++ < 50)
Expand Down Expand Up @@ -240,7 +233,7 @@ subprojects {
apply(plugin = "se.patrikerdes.use-latest-versions")

dependencies {
testImplementation(project(":sdk", "testConfig"))
testImplementation(project(":testConfig"))
}

tasks {
Expand All @@ -250,7 +243,6 @@ subprojects {

withType<KotlinCompile> {
kotlinOptions {
jvmTarget = javaTargetVersion.toString()
freeCompilerArgs = listOf("-Xjvm-default=all")
}
if(name.contains("test", true)) {
Expand All @@ -269,13 +261,13 @@ allprojects {
}

if (this.name in documentedProjects) {
apply(plugin = "maven")
// apply(plugin = "maven")
apply(plugin = "org.jetbrains.dokka")
tasks {
val doc by creating(DokkaTask::class) {
group = "documentation"
dependsOn(classes)
outputDirectory = buildDir.resolve("doc").toString()
outputDirectory = layout.buildDirectory.asFile.get().resolve("doc").toString()
outputFormat = "javadoc"
}
val docJar by creating(Jar::class) {
Expand All @@ -290,9 +282,9 @@ allprojects {
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}
install {
dependsOn(docJar, sourcesJar)
}
// install {
// dependsOn(docJar, sourcesJar)
// }
artifacts {
archives(sourcesJar.archiveFile) { classifier = "sources" }
archives(docJar.archiveFile) { classifier = "javadoc" }
Expand Down
4 changes: 2 additions & 2 deletions gradle/custom-tasks/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
plugins {
kotlin("jvm") version "1.5.20"
kotlin("jvm") version "1.9.10"
`java-gradle-plugin`
}

sourceSets.main.get().java.setSrcDirs(listOf("src"))

repositories {
jcenter()
mavenCentral()
}

dependencies {
Expand Down
2 changes: 2 additions & 0 deletions gradle/custom-tasks/src/sc/gradle/ScriptsTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import java.io.File
open class ScriptsTask : DefaultTask() {
@OutputDirectory
lateinit var destinationDir: File
@Input
lateinit var fileName: String
@Input
lateinit var content: String

init {
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading