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
15 changes: 12 additions & 3 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,27 @@ repositories {
name = "MinecraftForge"
url = uri("https://maven.minecraftforge.net/")
}
maven {
name = "EngineHub"
url = uri("https://repo.enginehub.org/libs-release/")
}
mavenCentral()
gradlePluginPortal()
}

dependencies {
implementation(gradleApi())
implementation(libs.crankcase.java)
implementation(libs.crankcase.javaLibrary)
implementation(libs.crankcase.checkstyle)
implementation(libs.crankcase.common)
implementation(libs.crankcase.licensing)
implementation(libs.crankcase.git)
implementation(libs.crankcase.japicmp)
implementation(libs.crankcase.publishing)
implementation(libs.levelHeadered)
implementation(libs.japicmp)
implementation(libs.shadow)
implementation(libs.jfrog.buildinfo)
implementation(libs.paperweight)
implementation(libs.errorprone.gradle.plugin)
implementation(libs.gson)

implementation(libs.sponge.vanillagradle)
Expand Down
33 changes: 32 additions & 1 deletion build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,35 @@
apply(from = "../gradle/shared-scripts/repo-reconfiguration.settings.gradle.kts")
pluginManagement {
// pluginManagement repositories resolve plugins before the repo-reconfiguration plugin can
// apply, so they must point at EngineHub mirrors directly rather than upstream URLs.
repositories {
maven {
name = "EngineHub"
url = uri("https://repo.enginehub.org/libs-release/")
mavenContent {
releasesOnly()
includeGroupAndSubgroups("com.sk89q")
includeGroupAndSubgroups("org.enginehub")
}
}
maven {
name = "EngineHub Maven Central Mirror"
url = uri("https://repo.enginehub.org/internal/maven-central-proxy/")
mavenContent {
releasesOnly()
}
}
maven {
name = "EngineHub Gradle Plugin Portal Mirror"
url = uri("https://repo.enginehub.org/internal/plugin-portal-proxy/")
mavenContent {
releasesOnly()
}
}
}
}
plugins {
id("org.enginehub.crankcase.repo-reconfiguration") version "0.1.0"
}

dependencyResolutionManagement {
versionCatalogs {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import io.papermc.paperweight.userdev.ReobfArtifactConfiguration
import org.gradle.kotlin.dsl.named

plugins {
id("buildlogic.adapter")
Expand All @@ -8,10 +7,3 @@ plugins {
paperweight {
reobfArtifactConfiguration = ReobfArtifactConfiguration.MOJANG_PRODUCTION
}

tasks
.withType<JavaCompile>()
.matching { it.name == "compileJava" || it.name == "compileTestJava" }
.configureEach {
options.release.set(25)
}
4 changes: 1 addition & 3 deletions build-logic/src/main/kotlin/buildlogic.adapter.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import buildlogic.stringyLibs
import buildlogic.getVersion

plugins {
`java-library`
id("buildlogic.common")
id("buildlogic.common-java")
id("buildlogic.common-java-library")
id("io.papermc.paperweight.userdev")
}

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import buildlogic.stringyLibs
import buildlogic.getLibrary

plugins {
id("org.enginehub.crankcase.java-library")
id("buildlogic.common-java")
}

dependencies {
"compileOnlyApi"(stringyLibs.getLibrary("errorprone-annotations"))
}
81 changes: 17 additions & 64 deletions build-logic/src/main/kotlin/buildlogic.common-java.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,46 +1,30 @@
import buildlogic.stringyLibs
import buildlogic.getLibrary
import net.ltgt.gradle.errorprone.errorprone

plugins {
id("eclipse")
id("idea")
id("checkstyle")
id("net.ltgt.errorprone")
id("org.enginehub.crankcase.java")
id("org.enginehub.crankcase.checkstyle")
id("buildlogic.common")
}

tasks
.withType<JavaCompile>()
.matching { it.name == "compileJava" || it.name == "compileTestJava" }
.configureEach {
val disabledLint = listOf(
"processing", "path", "fallthrough", "serial", "overloads",
)
options.release.set(25)
options.compilerArgs.addAll(listOf("-Xlint:all") + disabledLint.map { "-Xlint:-$it" })
options.isDeprecation = true
options.encoding = "UTF-8"
options.compilerArgs.add("-parameters")
options.compilerArgs.add("-Werror")
options.errorprone {
// We use -Werror, so we don't need errorprone to fail the build separately
allErrorsAsWarnings = true
// Obviously we don't need to fix generated code
disableWarningsInGeneratedCode = true
// We use reference equality intentionally in several places
// Perhaps we should consider testing the performance impact of using .equals() instead?
// Especially for the types that are only compared by reference equality, we could consider
// removing their .equals() implementations to avoid confusion.
disable("ReferenceEquality")
// We're on JDK 21, so System.console() can still be null
disable("SystemConsoleNull")
}
}
crankcaseJava {
javaRelease = 25
disabledLints = listOf("processing", "path", "fallthrough", "serial", "overloads")
disabledErrorprone = listOf(
// We use reference equality intentionally in several places
// Perhaps we should consider testing the performance impact of using .equals() instead?
// Especially for the types that are only compared by reference equality, we could consider
// removing their .equals() implementations to avoid confusion.
"ReferenceEquality",
// We're on JDK 21, so System.console() can still be null
"SystemConsoleNull",
)
}

configure<CheckstyleExtension> {
configFile = rootProject.file("config/checkstyle/checkstyle.xml")
toolVersion = "13.3.0"
crankcaseCheckstyle {
suppressionsFile = rootDir.resolve("config/checkstyle/checkstyle-suppression.xml")
}

tasks.withType<Test>().configureEach {
Expand All @@ -51,39 +35,8 @@ tasks.withType<Test>().configureEach {

dependencies {
"compileOnly"(stringyLibs.getLibrary("jsr305"))
"compileOnlyApi"(stringyLibs.getLibrary("errorprone-annotations"))
"errorprone"(stringyLibs.getLibrary("errorprone-core"))
"testImplementation"(platform(stringyLibs.getLibrary("junit-bom")))
"testImplementation"(stringyLibs.getLibrary("junit-jupiter-api"))
"testImplementation"(stringyLibs.getLibrary("junit-jupiter-params"))
"testImplementation"(stringyLibs.getLibrary("jqwik"))
"testImplementation"(platform(stringyLibs.getLibrary("mockito-bom")))
"testImplementation"(stringyLibs.getLibrary("mockito-core"))
"testImplementation"(stringyLibs.getLibrary("mockito-junit-jupiter"))
"testRuntimeOnly"(stringyLibs.getLibrary("junit-jupiter-engine"))
"testRuntimeOnly"(stringyLibs.getLibrary("junit-platform-launcher"))
}

// Java 8 turns on doclint which we fail
tasks.withType<Javadoc>().configureEach {
options.encoding = "UTF-8"
(options as StandardJavadocDocletOptions).apply {
addBooleanOption("Werror", true)
addBooleanOption("Xdoclint:all", true)
addBooleanOption("Xdoclint:-missing", true)
tags(
"apiNote:a:API Note:",
"implSpec:a:Implementation Requirements:",
"implNote:a:Implementation Note:"
)
}
}

configure<JavaPluginExtension> {
withJavadocJar()
withSourcesJar()
}

tasks.named("check").configure {
dependsOn("checkstyleMain", "checkstyleTest")
}
28 changes: 3 additions & 25 deletions build-logic/src/main/kotlin/buildlogic.common.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
import buildlogic.getLibrary
import buildlogic.stringyLibs
import org.gradle.plugins.ide.idea.model.IdeaModel

plugins {
id("net.octyl.level-headered")
id("org.enginehub.crankcase.common")
id("org.enginehub.crankcase.licensing")
id("org.enginehub.crankcase.git")
}

group = rootProject.group
version = rootProject.version

configurations.all {
resolutionStrategy {
cacheChangingModulesFor(1, TimeUnit.DAYS)
}
}

plugins.withId("java") {
the<JavaPluginExtension>().toolchain {
languageVersion.set(JavaLanguageVersion.of(25))
}
}

dependencies {
for (conf in listOf("implementation", "api")) {
if (!configurations.names.contains(conf)) {
Expand All @@ -46,19 +35,8 @@ dependencies {
}

levelHeadered {
headerTemplate(rootProject.file("HEADER.txt"))

sourceMatchPatterns {
// Exclude overrides for text formatting
exclude("com/sk89q/worldedit/util/formatting/text/")
}
}

plugins.withId("idea") {
configure<IdeaModel> {
module {
isDownloadSources = true
isDownloadJavadoc = true
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
plugins {
id("java")
id("maven-publish")
id("buildlogic.common-java")
id("buildlogic.artifactory-sub")
id("buildlogic.common-java-library")
id("org.enginehub.crankcase.publishing")
}

publishing {
Expand Down
3 changes: 1 addition & 2 deletions build-logic/src/main/kotlin/buildlogic.libs.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ plugins {
id("java-base")
id("maven-publish")
id("com.gradleup.shadow")
id("com.jfrog.artifactory")
id("buildlogic.common")
id("buildlogic.artifactory-sub")
id("org.enginehub.crankcase.publishing")
}

// A horrible hack because `softwareComponentFactory` has to be gotten via plugin
Expand Down
25 changes: 0 additions & 25 deletions build-logic/src/main/kotlin/buildlogic/GitBuildService.kt

This file was deleted.

9 changes: 6 additions & 3 deletions build-logic/src/main/kotlin/buildlogic/GradleExtras.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.api.artifacts.VersionConstraint
import org.gradle.api.artifacts.dsl.RepositoryHandler
import org.gradle.api.plugins.ExtraPropertiesExtension
import org.enginehub.crankcase.git.GitExtension
import org.gradle.api.provider.Provider
import org.gradle.kotlin.dsl.getByType
import org.gradle.kotlin.dsl.registerIfAbsent
import org.gradle.kotlin.dsl.the
import java.net.URI

val Project.ext: ExtraPropertiesExtension
Expand All @@ -19,8 +20,10 @@ val Project.stringyLibs: VersionCatalog
get() = extensions.getByType<VersionCatalogsExtension>().named("libs")

val Project.internalVersion: Provider<String>
get() = gradle.sharedServices.registerIfAbsent("git", GitBuildService::class) {}
.flatMap { service -> service.computeInternalVersion(project.version as String) }
get() {
val version = version.toString()
return the<GitExtension>().commitHash.map { "$version+$it" }
}

fun VersionCatalog.getLibrary(name: String): Provider<MinimalExternalModuleDependency> = findLibrary(name).orElseThrow {
error("Library $name not found in version catalog")
Expand Down
Loading
Loading