Skip to content
Merged
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
1 change: 0 additions & 1 deletion build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ repositories {

dependencies {
implementation(gradleApi())
implementation(libs.grgit)
implementation(libs.shadow)
implementation(libs.paperweight)

Expand Down
2 changes: 1 addition & 1 deletion build-logic/src/main/kotlin/buildlogic.common.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import org.gradle.plugins.ide.idea.model.IdeaModel
group = rootProject.group
version = rootProject.version

configurations.all {
configurations.configureEach {
resolutionStrategy {
cacheChangingModulesFor(1, TimeUnit.DAYS)
}
Expand Down
46 changes: 24 additions & 22 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import org.ajoberstar.grgit.Grgit
import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
import org.gradle.api.tasks.testing.logging.TestLogEvent.FAILED
import java.time.format.DateTimeFormatter
import xyz.jpenilla.runpaper.task.RunServer

plugins {
Expand All @@ -18,11 +16,18 @@ var revision: String = (extra.properties["revision"] as? String) ?: ""
var buildNumber: String = (extra.properties["buildNumber"] as? String) ?: ""
var date: String = (extra.properties["date"] as? String) ?: ""

val git: Grgit = Grgit.open {
dir = File("$rootDir/.git")
}
date = git.head().dateTime.format(DateTimeFormatter.ofPattern("yy.MM.dd"))
revision = "-${git.head().abbreviatedId}"
// Get Git metadata during build setup using the Git CLI.
// This replaces Grgit/JGit so the build stays compatible with Gradle's configuration cache.
// The result is recorded as a build input and can be reused without re-running Git each time.
// We keep the short hash length the same as before for consistency.
fun gitOutput(vararg args: String): String =
providers.exec {
commandLine("git", *args)
workingDir = rootDir
}.standardOutput.asText.get().trim()

date = gitOutput("show", "-s", "--format=%cd", "--date=format:%y.%m.%d", "HEAD")
revision = "-" + gitOutput("rev-parse", "--short=7", "HEAD")
buildNumber = if (project.hasProperty("buildnumber")) {
snapshot + "-" + (project.findProperty("buildnumber") as? String ?: "")
} else {
Expand All @@ -38,9 +43,8 @@ extra.set("date", date)
version = String.format("%s-%s", rootVersion, snapshot)

if (!project.hasProperty("gitCommitHash")) {
pluginManager.apply("org.ajoberstar.grgit")
ext["gitCommitHash"] = try {
extensions.getByName<Grgit>("grgit").head()?.abbreviatedId
gitOutput("rev-parse", "--short=7", "HEAD")
} catch (e: Exception) {
logger.warn("Error getting commit hash", e)

Expand Down Expand Up @@ -82,19 +86,17 @@ codecov {
}

allprojects {
gradle.projectsEvaluated {
tasks.withType<JavaCompile>().configureEach {
options.compilerArgs.addAll(arrayOf("-Xmaxerrs", "1000"))
}
tasks.withType<Test>().configureEach {
maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).takeIf { it > 0 } ?: 1
testLogging {
events(FAILED)
exceptionFormat = FULL
showExceptions = true
showCauses = true
showStackTraces = true
}
tasks.withType<JavaCompile>().configureEach {
options.compilerArgs.addAll(arrayOf("-Xmaxerrs", "1000"))
}
tasks.withType<Test>().configureEach {
maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).takeIf { it > 0 } ?: 1
testLogging {
events(FAILED)
exceptionFormat = FULL
showExceptions = true
showCauses = true
showStackTraces = true
}
}
}
Expand Down
1 change: 0 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ minimumJdependency = "2.10"

[libraries]
# Gradle plugins
grgit = { group = "org.ajoberstar.grgit", name = "grgit-gradle", version.ref = "grgit" }
shadow = { group = "com.gradleup.shadow", name = "shadow-gradle-plugin", version.ref = "shadow" }
paperweight = { group = "io.papermc.paperweight.userdev", name = "io.papermc.paperweight.userdev.gradle.plugin", version.ref = "paperweight" }
Comment on lines 64 to 68

Expand Down
26 changes: 20 additions & 6 deletions worldedit-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ tasks.test {
}

tasks.compileJava {
dependsOn(":worldedit-libs:build")
options.compilerArgs.add("-Aarg.name.key.prefix=")
}

Expand Down Expand Up @@ -103,13 +102,28 @@ sourceSets.named("main") {
}
}

// Resolve these to plain Strings up front. Referencing `version` or `rootProject`
// inside the filesMatching action would capture a Project instance in the task,
// which cannot be serialized by the configuration cache.
val faweVersion = "$version"
val faweCommit = "${rootProject.ext["revision"]}"
val faweDate = "${rootProject.ext["date"]}"

tasks.named<Copy>("processResources") {
// Collect into a local of THIS block. A top-level `val` in a .gradle.kts is a
// property of the script object, so referencing one from the filesMatching
// closure would capture the script itself - which the configuration cache
// cannot serialize. A local is captured by value instead.
val expansions = mapOf(
"version" to faweVersion,
"commit" to faweCommit,
"date" to faweDate
)
inputs.property("faweVersion", faweVersion)
inputs.property("faweCommit", faweCommit)
inputs.property("faweDate", faweDate)
filesMatching("fawe.properties") {
expand(
"version" to "$version",
"commit" to "${rootProject.ext["revision"]}",
"date" to "${rootProject.ext["date"]}"
)
expand(expansions)
}
}

Expand Down
Loading