Skip to content
Draft
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: 2 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,12 @@ jobs:
- uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '21'

# We can't use 'maven' prebuilt cache setup because it requires that the project have a pom file.
# BuildTools installs to Maven local if available, so it's easier to just rely on that.
- name: Cache Spigot dependency
uses: actions/cache@v5
with:
path: |
~/.m2/repository/org/spigotmc/
key: ${{ runner.os }}-buildtools-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-buildtools-
java-version: '25'

- uses: gradle/actions/setup-gradle@v5

- name: Build with Gradle
run: ./gradlew clean build
run: ./gradlew build

# Upload artifacts
- name: Upload Distributable Jar
Expand Down
1 change: 0 additions & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ repositories {

dependencies {
val libs = project.extensions.getByType(VersionCatalogsExtension::class.java).named("libs")
implementation(libs.findLibrary("specialsource").orElseThrow())
implementation(libs.findLibrary("errorprone-gradle").orElseThrow())
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ abstract class BuildToolsValueSource : ValueSource<File, BuildToolsValueSource.P
abstract val exec: ExecOperations

interface Parameters : ValueSourceParameters {
val mavenLocal: Property<File>
val installDir: DirectoryProperty
val workingDir: DirectoryProperty

val spigotVersion: Property<String>
Expand All @@ -31,11 +31,11 @@ abstract class BuildToolsValueSource : ValueSource<File, BuildToolsValueSource.P
override fun obtain(): File {
val version = parameters.spigotVersion.get()
val revision = parameters.spigotRevision.get()
val installLocation = getInstallLocation(version)
val spigotLocation = parameters.installDir.get().asFile.resolve("spigot-$version.jar")
// If Spigot is already installed, don't reinstall.
if (!parameters.ignoreCached.get() && installLocation.exists()) {
if (!parameters.ignoreCached.get() && spigotLocation.exists()) {
println("Skipping Spigot installation, $version is present")
return installLocation
return spigotLocation
}

val buildTools = installBuildTools(parameters.workingDir.get().asFile)
Expand All @@ -47,22 +47,29 @@ abstract class BuildToolsValueSource : ValueSource<File, BuildToolsValueSource.P
executable = parameters.javaExecutable.get()
workingDir = buildTools.parentFile
classpath(buildTools)
args = listOf("--nogui", "--rev", revision, "--remapped")
args = listOf("--nogui", "--rev", revision)
}.rethrowFailure()

val spigotBuild = buildTools.parentFile.resolve("Spigot/Spigot-Server/target/spigot-$version.jar")

if (!spigotBuild.exists()) {
throw IllegalStateException(
"Spigot build completed, but $spigotBuild does not exist! Did BuildTools change output location?"
)
}

spigotBuild.copyTo(spigotLocation, overwrite = true)

// Mark work for delete.
cleanUp(buildTools.parentFile)

if (!installLocation.exists()) {
if (!spigotLocation.exists()) {
throw IllegalStateException(
"Failed to install Spigot $version from $revision. Does the revision point to a different version?"
)
}
return installLocation
}

private fun getInstallLocation(version: String): File {
return parameters.mavenLocal.get().resolve("org/spigotmc/spigot/$version/spigot-$version-remapped-mojang.jar")
return spigotLocation
}

private fun installBuildTools(workingDir: File): File {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ abstract class SpigotDependencyExtension(
.convention(version.map {
it.replace("-R\\d+\\.\\d+-SNAPSHOT".toRegex(), "")
})
val classifier = objects.property(String::class.java).convention("remapped-mojang")
val classifier = objects.property(String::class.java).convention("")
val java = objects.property(JavaToolchainSpec::class.java)
val ignoreCached = objects.property(Boolean::class.java).convention(false)

Expand Down
56 changes: 0 additions & 56 deletions buildSrc/src/main/kotlin/com/github/jikoo/openinv/SpigotReobf.kt

This file was deleted.

This file was deleted.

13 changes: 4 additions & 9 deletions buildSrc/src/main/kotlin/com/github/jikoo/openinv/SpigotSetup.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.jvm.toolchain.JavaToolchainService
import org.gradle.kotlin.dsl.create
import java.nio.file.Paths
import java.io.File
import javax.inject.Inject

abstract class SpigotSetup : Plugin<Project> {
Expand All @@ -24,17 +23,15 @@ abstract class SpigotSetup : Plugin<Project> {
target.objects
)

val mvnLocal = target.repositories.mavenLocal()

target.afterEvaluate {
// Get Java requirements, defaulting to version used for compilation.
spigotExt.java.convention(target.extensions.getByType(JavaPluginExtension::class.java).toolchain)
val launcher = javaToolchainService.launcherFor(spigotExt.java.get()).get()

// Install Spigot with BuildTools.
target.providers.of(BuildToolsValueSource::class.java) {
val spigot: File = target.providers.of(BuildToolsValueSource::class.java) {
parameters {
mavenLocal.set(Paths.get(mvnLocal.url).toFile())
installDir.set(target.gradle.gradleUserHomeDir.resolve("caches/spigot"))
workingDir.set(target.layout.buildDirectory.dir("tmp/buildtools"))
spigotVersion.set(spigotExt.version)
spigotRevision.set(spigotExt.revision)
Expand All @@ -45,9 +42,7 @@ abstract class SpigotSetup : Plugin<Project> {
}.get()

// Add Spigot dependency.
val dependency = target.dependencies.create(
"org.spigotmc:spigot:${spigotExt.version.get()}:${spigotExt.classifier.getOrElse("")}"
)
val dependency = target.dependencies.create(files(spigot))
target.dependencies.add("compileOnly", dependency)
}
}
Expand Down
2 changes: 0 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[versions]
spigotapi = "1.21.5-R0.1-SNAPSHOT"
specialsource = "1.11.6"
planarwrappers = "3.3.0"
annotations = "26.1.0"
paperweight = "2.0.0-beta.17"
Expand All @@ -13,7 +12,6 @@ sqlite-jdbc = "3.49.1.0"

[libraries]
spigotapi = { module = "org.spigotmc:spigot-api", version.ref = "spigotapi" }
specialsource = { module = "net.md-5:SpecialSource", version.ref = "specialsource" }
planarwrappers = { module = "com.github.jikoo:planarwrappers", version.ref = "planarwrappers" }
annotations = { module = "org.jetbrains:annotations", version.ref = "annotations" }
folia-scheduler-wrapper = { module = "com.github.NahuLD.folia-scheduler-wrapper:folia-scheduler-wrapper", version.ref = "folia-scheduler-wrapper" }
Expand Down
25 changes: 0 additions & 25 deletions internal/common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

plugins {
`openinv-base`
alias(libs.plugins.paperweight)
Expand Down Expand Up @@ -35,26 +33,3 @@ dependencies {

paperweight.paperDevBundle("1.21.11-R0.1-SNAPSHOT")
}

val spigot = tasks.register<ShadowJar>("spigotRelocations") {
dependsOn(tasks.jar)
from(sourceSets.main.get().output)
relocate("com.lishid.openinv.internal.common", "com.lishid.openinv.internal.reobf")
relocate("org.bukkit.craftbukkit", "org.bukkit.craftbukkit.${rootProject.extra["craftbukkitPackage"]}")
archiveClassifier = "spigot"
}

configurations {
consumable("spigotRelocated") {
attributes {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.LIBRARY))
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME))
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.EXTERNAL))
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements.JAR))
}
}
}

artifacts {
add("spigotRelocated", spigot)
}
23 changes: 9 additions & 14 deletions internal/spigot/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import com.github.jikoo.openinv.SpigotDependencyExtension
import com.github.jikoo.openinv.SpigotReobf
import com.github.jikoo.openinv.SpigotSetup

plugins {
`openinv-base`
alias(libs.plugins.shadow)
}

apply<SpigotSetup>()
apply<SpigotReobf>()
java {
toolchain.languageVersion = JavaLanguageVersion.of(25)
}

val spigotVer = "1.21.11-R0.2-SNAPSHOT"
// Used by common adapter to relocate Craftbukkit classes to a versioned package.
rootProject.extra["craftbukkitPackage"] = "v1_21_R7"
apply<SpigotSetup>()

configurations.all {
resolutionStrategy.capabilitiesResolution.withCapability("org.spigotmc:spigot-api") {
Expand All @@ -30,15 +28,12 @@ configurations.all {

dependencies {
compileOnly(libs.spigotapi)
extensions.getByType(SpigotDependencyExtension::class.java).version = spigotVer
extensions.getByType(SpigotDependencyExtension::class.java).version = "26.1-R0.1-SNAPSHOT"
compileOnly("com.mojang:logging:1.6.11")
compileOnly("com.mojang:brigadier:1.3.10")
compileOnly("com.mojang:datafixerupper:9.0.19")
compileOnly("com.mojang:authlib:7.0.62")

compileOnly(project(":openinvapi"))
compileOnly(project(":openinvcommon"))

// Reduce duplicate code by lightly remapping common adapter.
implementation(project(":openinvadaptercommon", configuration = "spigotRelocated"))
}

tasks.shadowJar {
relocate("com.lishid.openinv.internal.common", "com.lishid.openinv.internal.reobf")
}
Loading