Skip to content

Commit 1dd3f5a

Browse files
authored
Refactor Gradle build logic and update dependencies (#3309)
* Add foojay to download JVMs. (cherry picked from commit cd8bca9) Signed-off-by: Matt Bonanno <[email protected]> * Renamed some dependencies to kebab-case for clarity and to align with common Gradle practices. Signed-off-by: Matt Bonanno <[email protected]> * Refine build logic and dependency management in Gradle configuration. Signed-off-by: Matt Bonanno <[email protected]> * Update Gradle wrapper to version 9.0.0 * Fix internalVersion expansion to use mapOf. Gradle 9 changed the behavior of this code but didn't set off any deprecation warnings...🙄 * Refactor build logic to use plugins for dependency management and improve project structure. * Update tasks in build.gradle.kt to use configureEach for improved performance with lazy configuration. * Refactor dependencies in build.gradle.kts and libs.versions.toml for consistency * Add build-logic-improvements branch to GitHub Actions workflow for CI * Set maxParallelForks for tests based on available processors * Fixed a rebase issue * Update Target JVM version from 16 to 21 in library attributes * Add intellectualsites repository to allowed prefixes for better up-time guarantees * Updated gradle wrapper and foojay-resolver-convention plugin * Add PaperMC repository to adapter build logic * Refactor build logic to exclude net.kyori group from EngineHub repository and stop relocating and bundling fastutil * Reformatted buildlogic.platform.gradle.kts * Fixed artifact generation --------- Signed-off-by: Matt Bonanno <[email protected]>
1 parent b935a07 commit 1dd3f5a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1432
-1201
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ on:
33
push:
44
branches:
55
- main
6+
- build-logic-improvements
67
jobs:
78
build:
89
if: github.repository_owner == 'IntellectualSites'
@@ -19,7 +20,7 @@ jobs:
1920
cache: gradle
2021
java-version: 21
2122
- name: Clean Build
22-
run: ./gradlew clean build --no-daemon
23+
run: ./gradlew build
2324
- name: Determine release status
2425
if: ${{ runner.os == 'Linux' }}
2526
run: |

build-logic/build.gradle.kts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
plugins {
2+
`kotlin-dsl`
3+
}
4+
5+
repositories {
6+
gradlePluginPortal()
7+
maven {
8+
name = "EngineHub Repository"
9+
url = uri("https://maven.enginehub.org/repo/")
10+
}
11+
}
12+
13+
dependencies {
14+
implementation(gradleApi())
15+
implementation(libs.grgit)
16+
implementation(libs.shadow)
17+
implementation(libs.paperweight)
18+
19+
constraints {
20+
val asmVersion = "[${libs.versions.minimumAsm.get()},)"
21+
implementation("org.ow2.asm:asm:$asmVersion") {
22+
because("Need Java 21 support in shadow")
23+
}
24+
implementation("org.ow2.asm:asm-commons:$asmVersion") {
25+
because("Need Java 21 support in shadow")
26+
}
27+
implementation("org.vafer:jdependency:[${libs.versions.minimumJdependency.get()},)") {
28+
because("Need Java 21 support in shadow")
29+
}
30+
}
31+
}

build-logic/settings.gradle.kts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
dependencyResolutionManagement {
2+
versionCatalogs {
3+
create("libs") {
4+
from(files("../gradle/libs.versions.toml"))
5+
}
6+
}
7+
}
8+
9+
rootProject.name = "build-logic"
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import buildlogic.stringyLibs
2+
3+
plugins {
4+
`java-library`
5+
id("buildlogic.common")
6+
id("buildlogic.common-java")
7+
id("io.papermc.paperweight.userdev")
8+
}
9+
10+
paperweight {
11+
injectPaperRepository = false
12+
reobfArtifactConfiguration = io.papermc.paperweight.userdev.ReobfArtifactConfiguration.REOBF_PRODUCTION
13+
}
14+
15+
repositories {
16+
maven {
17+
name = "PaperMC"
18+
url = uri("https://repo.papermc.io/repository/maven-public/")
19+
}
20+
maven {
21+
name = "EngineHub Repository"
22+
url = uri("https://maven.enginehub.org/repo/")
23+
}
24+
mavenCentral()
25+
afterEvaluate {
26+
killNonEngineHubRepositories()
27+
}
28+
}
29+
30+
dependencies {
31+
implementation(project(":worldedit-bukkit"))
32+
constraints {
33+
//Reduces the amount of libraries Gradle and IntelliJ need to resolve
34+
implementation("net.kyori:adventure-bom") {
35+
version { strictly("4.24.0") }
36+
because("Ensure a consistent version of adventure is used.")
37+
}
38+
}
39+
}
40+
41+
tasks.named("assemble") {
42+
dependsOn("reobfJar")
43+
}
44+
45+
tasks.named<Javadoc>("javadoc") {
46+
enabled = false
47+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import buildlogic.stringyLibs
2+
import buildlogic.getLibrary
3+
4+
plugins {
5+
id("eclipse")
6+
id("idea")
7+
id("buildlogic.common")
8+
}
9+
10+
tasks
11+
.withType<JavaCompile>()
12+
.matching { it.name == "compileJava" || it.name == "compileTestJava" }
13+
.configureEach {
14+
// TODO: re-enable this-escape when ANTLR suppresses it properly
15+
val disabledLint = listOf(
16+
"processing", "path", "fallthrough", "serial", "overloads", "this-escape",
17+
)
18+
options.release.set(21)
19+
options.compilerArgs.addAll(listOf("-Xlint:all") + disabledLint.map { "-Xlint:-$it" })
20+
options.isDeprecation = true
21+
options.encoding = "UTF-8"
22+
options.compilerArgs.add("-parameters")
23+
options.compilerArgs.add("--add-modules=jdk.incubator.vector")
24+
}
25+
26+
tasks.withType<Test>().configureEach {
27+
useJUnitPlatform {
28+
includeEngines("junit-jupiter", "jqwik")
29+
}
30+
}
31+
32+
dependencies {
33+
"compileOnly"(stringyLibs.getLibrary("jsr305"))
34+
"testImplementation"(platform(stringyLibs.getLibrary("junit-bom")))
35+
"testImplementation"(stringyLibs.getLibrary("junit-jupiter-api"))
36+
"testImplementation"(stringyLibs.getLibrary("junit-jupiter-params"))
37+
"testImplementation"(stringyLibs.getLibrary("jqwik"))
38+
"testImplementation"(platform(stringyLibs.getLibrary("mockito-bom")))
39+
"testImplementation"(stringyLibs.getLibrary("mockito-core"))
40+
"testImplementation"(stringyLibs.getLibrary("mockito-junit-jupiter"))
41+
"testRuntimeOnly"(stringyLibs.getLibrary("junit-jupiter-engine"))
42+
"testRuntimeOnly"(stringyLibs.getLibrary("junit-platform-launcher"))
43+
}
44+
45+
// Java 8 turns on doclint which we fail
46+
tasks.withType<Javadoc>().configureEach {
47+
options.encoding = "UTF-8"
48+
(options as StandardJavadocDocletOptions).apply {
49+
addStringOption("Xdoclint:none", "-quiet")
50+
addStringOption("-add-modules", "jdk.incubator.vector")
51+
addBooleanOption("Xdoclint:-missing", true)
52+
tags(
53+
"apiNote:a:API Note:",
54+
"implSpec:a:Implementation Requirements:",
55+
"implNote:a:Implementation Note:"
56+
)
57+
links(
58+
"https://jd.advntr.dev/api/latest/",
59+
"https://logging.apache.org/log4j/2.x/javadoc/log4j-api/",
60+
"https://www.antlr.org/api/Java/",
61+
"https://jd.papermc.io/paper/1.21.8/",
62+
"https://intellectualsites.github.io/fastasyncworldedit-javadocs/worldedit-core/"
63+
)
64+
docTitle = "${rootProject.name}-${project.description}" + " " + "${rootProject.version}"
65+
}
66+
}
67+
68+
configure<JavaPluginExtension> {
69+
withJavadocJar()
70+
withSourcesJar()
71+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import buildlogic.getLibrary
2+
import buildlogic.stringyLibs
3+
import org.gradle.plugins.ide.idea.model.IdeaModel
4+
5+
group = rootProject.group
6+
version = rootProject.version
7+
8+
configurations.all {
9+
resolutionStrategy {
10+
cacheChangingModulesFor(1, TimeUnit.DAYS)
11+
}
12+
}
13+
14+
plugins.withId("java") {
15+
the<JavaPluginExtension>().toolchain {
16+
languageVersion.set(JavaLanguageVersion.of(21))
17+
}
18+
}
19+
20+
dependencies {
21+
for (conf in listOf("implementation", "api")) {
22+
if (!configurations.names.contains(conf)) {
23+
continue
24+
}
25+
add(conf, platform(stringyLibs.getLibrary("log4j-bom")).map {
26+
val dep = create(it)
27+
dep.because("Mojang provides Log4j")
28+
dep
29+
})
30+
constraints {
31+
add(conf, stringyLibs.getLibrary("guava")) {
32+
version { require("33.3.1-jre") }
33+
because("Mojang provides Guava")
34+
}
35+
add(conf, stringyLibs.getLibrary("gson")) {
36+
version { require("2.11.0") }
37+
because("Mojang provides Gson")
38+
}
39+
add(conf, stringyLibs.getLibrary("fastutil")) {
40+
version { require("8.5.15") }
41+
because("Mojang provides FastUtil")
42+
}
43+
}
44+
}
45+
}
46+
47+
plugins.withId("idea") {
48+
configure<IdeaModel> {
49+
module {
50+
isDownloadSources = true
51+
isDownloadJavadoc = true
52+
}
53+
}
54+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
plugins {
2+
id("java")
3+
id("maven-publish")
4+
id("buildlogic.common-java")
5+
id("signing")
6+
}
7+
8+
ext["internalVersion"] = "$version+${rootProject.ext["gitCommitHash"]}"
9+
10+
val publishingExtension = the<PublishingExtension>()
11+
12+
configure<SigningExtension> {
13+
if (!version.toString().endsWith("-SNAPSHOT")) {
14+
val signingKey: String? by project
15+
val signingPassword: String? by project
16+
useInMemoryPgpKeys(signingKey, signingPassword)
17+
isRequired
18+
sign(publishingExtension.publications)
19+
}
20+
}
21+
22+
publishing {
23+
publications {
24+
register<MavenPublication>("maven") {
25+
afterEvaluate {
26+
versionMapping {
27+
usage("java-api") {
28+
fromResolutionOf("runtimeClasspath")
29+
}
30+
usage("java-runtime") {
31+
fromResolutionResult()
32+
}
33+
}
34+
group = "com.fastasyncworldedit"
35+
artifactId = "${rootProject.name}-${project.description}"
36+
version = "$version"
37+
pom {
38+
name.set("${rootProject.name}-${project.description}" + " " + project.version)
39+
description.set("Blazingly fast Minecraft world manipulation for artists, builders and everyone else.")
40+
url.set("https://github.com/IntellectualSites/FastAsyncWorldEdit")
41+
42+
licenses {
43+
license {
44+
name.set("GNU General Public License, Version 3.0")
45+
url.set("https://www.gnu.org/licenses/gpl-3.0.html")
46+
distribution.set("repo")
47+
}
48+
}
49+
50+
developers {
51+
developer {
52+
id.set("NotMyFault")
53+
name.set("Alexander Brandes")
54+
email.set("contact(at)notmyfault.dev")
55+
organization.set("IntellectualSites")
56+
organizationUrl.set("https://github.com/IntellectualSites")
57+
}
58+
developer {
59+
id.set("SirYwell")
60+
name.set("Hannes Greule")
61+
organization.set("IntellectualSites")
62+
organizationUrl.set("https://github.com/IntellectualSites")
63+
}
64+
developer {
65+
id.set("dordsor21")
66+
name.set("dordsor21")
67+
organization.set("IntellectualSites")
68+
organizationUrl.set("https://github.com/IntellectualSites")
69+
}
70+
}
71+
72+
scm {
73+
url.set("https://github.com/IntellectualSites/FastAsyncWorldEdit")
74+
connection.set("scm:git:https://github.com/IntellectualSites/FastAsyncWorldEdit.git")
75+
developerConnection.set("scm:git:[email protected]:IntellectualSites/FastAsyncWorldEdit.git")
76+
tag.set("${project.version}")
77+
}
78+
79+
issueManagement {
80+
system.set("GitHub")
81+
url.set("https://github.com/IntellectualSites/FastAsyncWorldEdit/issues")
82+
}
83+
}
84+
}
85+
}
86+
}
87+
}

0 commit comments

Comments
 (0)