Skip to content
Open
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
14 changes: 12 additions & 2 deletions addon/togglepersist/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
plugins {
`openinv-base`
repositories {
mavenCentral()
maven("https://hub.spigotmc.org/nexus/content/groups/public/")
}

dependencies {
compileOnly(libs.spigotapi)
implementation(project(":openinvapi"))
}

java {
toolchain.languageVersion = JavaLanguageVersion.of(21)
}

tasks.withType<JavaCompile>().configureEach {
options.release = 21
}

tasks.processResources {
expand("version" to version)
}
Expand Down
18 changes: 17 additions & 1 deletion api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
plugins {
`openinv-base`
`maven-publish`
}

repositories {
mavenCentral()
maven("https://hub.spigotmc.org/nexus/content/groups/public/")
}

dependencies {
compileOnly(libs.spigotapi)
}

java {
toolchain.languageVersion = JavaLanguageVersion.of(21)
}

tasks.withType<JavaCompile>().configureEach {
options.release = 21
}

publishing {
publications {
create<MavenPublication>("jitpack") {
Expand Down
31 changes: 25 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,40 @@ plugins {
`java-library`
alias(libs.plugins.paperweight) apply false
alias(libs.plugins.shadow) apply false
id(libs.plugins.errorprone.gradle.get().pluginId) apply false
alias(libs.plugins.errorprone.gradle)
}

// Set by Spigot module, used by Paper module to convert to Spigot's version of Mojang mappings.
project.ext.set("craftbukkitPackage", "UNKNOWN")

repositories {
maven("https://repo.papermc.io/repository/maven-public/")
}

// Allow submodules to target higher Java release versions.
// Not currently necessary (as lowest supported version is in the 1.21 range)
// but may become relevant in the future.
java.disableAutoTargetJvm()

subprojects {
apply(plugin = "java-library")
apply(plugin = rootProject.libs.plugins.errorprone.gradle.get().pluginId)

repositories {
mavenCentral()
}

dependencies {
compileOnly(rootProject.libs.jspecify)
compileOnly(rootProject.libs.annotations)
errorprone(rootProject.libs.errorprone.core)
}

tasks {
withType<JavaCompile>().configureEach {
options.encoding = Charsets.UTF_8.name()
}
withType<Javadoc>().configureEach {
options.encoding = Charsets.UTF_8.name()
}
}
}

// Task to delete ./dist where final files are output.
tasks.register("cleanDist") {
delete("dist")
Expand Down
6 changes: 0 additions & 6 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,3 @@ repositories {
gradlePluginPortal()
mavenCentral()
}

dependencies {
val libs = project.extensions.getByType(VersionCatalogsExtension::class.java).named("libs")
implementation(libs.findLibrary("specialsource").orElseThrow())
implementation(libs.findLibrary("errorprone-gradle").orElseThrow())
}
7 changes: 0 additions & 7 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +0,0 @@
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
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
Loading