[ci skip] Add remote build cache configuration through Gradle properties (#12797)

This commit is contained in:
Jason Penilla
2025-07-04 13:12:45 -07:00
committed by GitHub
parent 6e598f8527
commit f7d5a0a017
4 changed files with 36 additions and 8 deletions

View File

@@ -16,6 +16,12 @@ on:
jobs:
build:
env:
ORG_GRADLE_PROJECT_paperBuildCacheEnabled: true
ORG_GRADLE_PROJECT_paperBuildCacheUsername: ${{ secrets.PAPER_BUILD_CACHE_USERNAME }}
ORG_GRADLE_PROJECT_paperBuildCachePassword: ${{ secrets.PAPER_BUILD_CACHE_PASSWORD }}
ORG_GRADLE_PROJECT_paperBuildCachePush: true
# The goal of the build workflow is split into multiple requirements.
# 1. Run on pushes to same repo.
# 2. Run on PR open/reopen/syncs from repos that are not the same (PRs from the same repo are covered by 1)

View File

@@ -2,7 +2,7 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
plugins {
id("io.papermc.paperweight.core") version "2.0.0-beta.17" apply false
id("io.papermc.paperweight.core") version "2.0.0-beta.18" apply false
}
subprojects {
@@ -24,19 +24,19 @@ subprojects {
val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/"
subprojects {
tasks.withType<JavaCompile> {
tasks.withType<JavaCompile>().configureEach {
options.encoding = Charsets.UTF_8.name()
options.release = 21
options.isFork = true
options.compilerArgs.addAll(listOf("-Xlint:-deprecation", "-Xlint:-removal"))
}
tasks.withType<Javadoc> {
tasks.withType<Javadoc>().configureEach {
options.encoding = Charsets.UTF_8.name()
}
tasks.withType<ProcessResources> {
tasks.withType<ProcessResources>().configureEach {
filteringCharset = Charsets.UTF_8.name()
}
tasks.withType<Test> {
tasks.withType<Test>().configureEach {
testLogging {
showStackTraces = true
exceptionFormat = TestExceptionFormat.FULL

View File

@@ -164,7 +164,7 @@ abstract class Services {
}
val services = objects.newInstance<Services>()
tasks.withType<Javadoc> {
tasks.withType<Javadoc>().configureEach {
val options = options as StandardJavadocDocletOptions
options.overview = "src/main/javadoc/overview.html"
options.use()

View File

@@ -1,5 +1,3 @@
import java.util.Locale
pluginManagement {
repositories {
gradlePluginPortal()
@@ -56,3 +54,27 @@ fun optionalInclude(name: String, op: (ProjectDescriptor.() -> Unit)? = null) {
)
}
}
if (providers.gradleProperty("paperBuildCacheEnabled").orNull.toBoolean()) {
val buildCacheUsername = providers.gradleProperty("paperBuildCacheUsername").orElse("").get()
val buildCachePassword = providers.gradleProperty("paperBuildCachePassword").orElse("").get()
if (buildCacheUsername.isBlank() || buildCachePassword.isBlank()) {
println("The Paper remote build cache is enabled, but no credentials were provided. Remote build cache will not be used.")
} else {
val buildCacheUrl = providers.gradleProperty("paperBuildCacheUrl")
.orElse("https://gradle-build-cache.papermc.io/")
.get()
val buildCachePush = providers.gradleProperty("paperBuildCachePush").orNull?.toBoolean()
?: System.getProperty("CI").toBoolean()
buildCache {
remote<HttpBuildCache> {
url = uri(buildCacheUrl)
isPush = buildCachePush
credentials {
username = buildCacheUsername
password = buildCachePassword
}
}
}
}
}