Skip to content

Commit

Permalink
Merge pull request #2512 from EngineHub/ot/feature/1.20.5
Browse files Browse the repository at this point in the history
Java 21 + 1.20.6
  • Loading branch information
me4502 authored May 1, 2024
2 parents d25669a + b5b5902 commit fda9ded
Show file tree
Hide file tree
Showing 176 changed files with 2,258 additions and 6,125 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 17
java-version: 21
cache: 'gradle'
distribution: 'temurin'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 17
java-version: 21
distribution: 'temurin'

- name: Setup Gradle
Expand Down
9 changes: 3 additions & 6 deletions COMPILING.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
Compiling
=========

You can compile WorldEdit as long as you have some version of Java greater than or equal to 16 installed. Gradle will download JDK 16 specifically if needed,
You can compile WorldEdit as long as you have some version of Java greater than or equal to 21 installed. Gradle will download JDK 21 specifically if needed,
but it needs some version of Java to bootstrap from.

Note that if you have JRE 16 installed, Gradle will currently attempt to use that to compile, which will not work. It is easiest to uninstall JRE 16 and
replace it with JDK 16.

The build process uses Gradle, which you do *not* need to download. WorldEdit is a multi-module project with four modules:

* `worldedit-core` contains the WorldEdit API
* `worldedit-bukkit` is the Bukkit plugin
* `worldedit-sponge` is the Sponge plugin
* `worldedit-forge` is the Forge mod
* `worldedit-neoforge` is the NeoForge mod
* `worldedit-fabric` is the Fabric mod

## To compile...
Expand All @@ -34,7 +31,7 @@ You will find:
* The core WorldEdit API in **worldedit-core/build/libs**
* WorldEdit for Bukkit in **worldedit-bukkit/build/libs**
* WorldEdit for Sponge in **worldedit-sponge/build/libs**
* WorldEdit for Forge in **worldedit-forge/build/libs**
* WorldEdit for NeoForge in **worldedit-neoforge/build/libs**
* WorldEdit for Fabric in **worldedit-fabric/build/libs**

If you want to use WorldEdit, use the `-dist` version.
Expand Down
34 changes: 34 additions & 0 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
plugins {
`kotlin-dsl`
}

repositories {
gradlePluginPortal()
maven {
name = "EngineHub Repository"
url = uri("https://maven.enginehub.org/repo/")
}
}

dependencies {
implementation(gradleApi())
implementation(libs.licenser)
implementation(libs.grgit)
implementation(libs.japicmp)
implementation(libs.shadow)
implementation(libs.jfrog.buildinfo)
implementation(libs.paperweight)
implementation(libs.gson)
constraints {
val asmVersion = "[${libs.versions.minimumAsm.get()},)"
implementation("org.ow2.asm:asm:$asmVersion") {
because("Need Java 21 support in shadow")
}
implementation("org.ow2.asm:asm-commons:$asmVersion") {
because("Need Java 21 support in shadow")
}
implementation("org.vafer:jdependency:[${libs.versions.minimumJdependency.get()},)") {
because("Need Java 21 support in shadow")
}
}
}
9 changes: 9 additions & 0 deletions build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}

rootProject.name = "build-logic"
26 changes: 26 additions & 0 deletions build-logic/src/main/kotlin/buildlogic.adapter.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import buildlogic.stringyLibs
import buildlogic.getVersion

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

configure<buildlogic.CommonJavaExtension> {
banSlf4j = false
}

dependencies {
"implementation"(project(":worldedit-bukkit"))
constraints {
"remapper"("net.fabricmc:tiny-remapper:[${stringyLibs.getVersion("minimumTinyRemapper")},)") {
because("Need remapper to support Java 21")
}
}
}

tasks.named("assemble") {
dependsOn("reobfJar")
}
35 changes: 35 additions & 0 deletions build-logic/src/main/kotlin/buildlogic.artifactory-root.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.named
import org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention
import org.jfrog.gradle.plugin.artifactory.task.ArtifactoryTask

plugins {
id("com.jfrog.artifactory")
}

val ARTIFACTORY_CONTEXT_URL = "artifactory_contextUrl"
val ARTIFACTORY_USER = "artifactory_user"
val ARTIFACTORY_PASSWORD = "artifactory_password"

if (!project.hasProperty(ARTIFACTORY_CONTEXT_URL)) ext[ARTIFACTORY_CONTEXT_URL] = "http://localhost"
if (!project.hasProperty(ARTIFACTORY_USER)) ext[ARTIFACTORY_USER] = "guest"
if (!project.hasProperty(ARTIFACTORY_PASSWORD)) ext[ARTIFACTORY_PASSWORD] = ""

configure<ArtifactoryPluginConvention> {
setContextUrl("${project.property(ARTIFACTORY_CONTEXT_URL)}")
clientConfig.publisher.run {
repoKey = when {
"${project.version}".contains("SNAPSHOT") -> "libs-snapshot-local"
else -> "libs-release-local"
}
username = "${project.property(ARTIFACTORY_USER)}"
password = "${project.property(ARTIFACTORY_PASSWORD)}"
isMaven = true
isIvy = false
}
}

tasks.named<ArtifactoryTask>("artifactoryPublish") {
isSkip = true
}
10 changes: 10 additions & 0 deletions build-logic/src/main/kotlin/buildlogic.artifactory-sub.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
plugins {
id("com.jfrog.artifactory")
}

// Artifactory eagerly evaluates publications, so this must run after all changes to artifacts are done
afterEvaluate {
tasks.named<org.jfrog.gradle.plugin.artifactory.task.ArtifactoryTask>("artifactoryPublish") {
publications("maven")
}
}
82 changes: 82 additions & 0 deletions build-logic/src/main/kotlin/buildlogic.common-java.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import buildlogic.stringyLibs
import buildlogic.getLibrary

plugins {
id("eclipse")
id("idea")
id("checkstyle")
id("buildlogic.common")
}

val commonJava = extensions.create<buildlogic.CommonJavaExtension>("commonJava")
commonJava.banSlf4j.convention(true)

tasks
.withType<JavaCompile>()
.matching { it.name == "compileJava" || it.name == "compileTestJava" }
.configureEach {
// TODO: re-enable this-escape when ANTLR suppresses it properly
val disabledLint = listOf(
"processing", "path", "fallthrough", "serial", "overloads", "this-escape",
)
options.release.set(21)
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")
}

configure<CheckstyleExtension> {
configFile = rootProject.file("config/checkstyle/checkstyle.xml")
toolVersion = "10.16.0"
}

tasks.withType<Test>().configureEach {
useJUnitPlatform()
}

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

// 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()
}

configurations["compileClasspath"].apply {
resolutionStrategy.componentSelection {
withModule("org.slf4j:slf4j-api") {
if (commonJava.banSlf4j.get()) {
reject("No SLF4J allowed on compile classpath")
}
}
}
}

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

plugins {
id("org.cadixdev.licenser")
}

group = rootProject.group
version = rootProject.version

repositories {
maven {
name = "EngineHub"
url = uri("https://maven.enginehub.org/repo/")
}
}

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

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

dependencies {
for (conf in listOf("implementation", "api")) {
if (!configurations.names.contains(conf)) {
continue
}
add(conf, platform(stringyLibs.getLibrary("log4j-bom")).map {
val dep = create(it)
dep.because("Mojang provides Log4j")
dep
})
constraints {
add(conf, stringyLibs.getLibrary("guava")) {
because("Mojang provides Guava")
}
add(conf, stringyLibs.getLibrary("gson")) {
because("Mojang provides Gson")
}
add(conf, stringyLibs.getLibrary("fastutil")) {
because("Mojang provides FastUtil")
}
}
}
}

license {
header(rootProject.file("HEADER.txt"))
include("**/*.java")
include("**/*.kt")
}

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

ext["internalVersion"] = "$version+${rootProject.ext["gitCommitHash"]}"

publishing {
publications {
register<MavenPublication>("maven") {
versionMapping {
usage("java-api") {
fromResolutionOf("runtimeClasspath")
}
usage("java-runtime") {
fromResolutionResult()
}
}
}
}
}
Loading

0 comments on commit fda9ded

Please sign in to comment.