mirror of
https://github.com/Jikoo/OpenInv.git
synced 2026-11-04 16:50:04 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d564773be6 | ||
|
|
e834e940e2 | ||
|
|
cd73430bb2 | ||
|
|
1c1dc9505b |
No files matched your search
@@ -29,7 +29,7 @@ jobs:
|
||||
- uses: gradle/actions/setup-gradle@v4
|
||||
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
run: ./gradlew clean build
|
||||
|
||||
# Upload artifacts
|
||||
- name: Upload Distributable Jar
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
import org.gradle.api.file.RegularFile
|
||||
import org.gradle.api.provider.Property
|
||||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.InputFile
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.gradle.api.tasks.bundling.Jar
|
||||
import java.io.File
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
|
||||
abstract class ReobfTask: Jar() {
|
||||
|
||||
@get:Input
|
||||
open val spigotVersion: Property<String> = objectFactory.property(String::class.java)
|
||||
|
||||
@get:InputFile
|
||||
open val inputFile: Property<RegularFile> = objectFactory.fileProperty()
|
||||
|
||||
@get:Input
|
||||
open val intermediaryClassifier: Property<String> = objectFactory.property(String::class.java).convention("mojang-mapped")
|
||||
|
||||
init {
|
||||
archiveClassifier.convention("reobf")
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
override fun copy() {
|
||||
val spigotVer = spigotVersion.get()
|
||||
val inFile = inputFile.get().asFile
|
||||
val obfPath = inFile.resolveSibling(inFile.name.replace(".jar", "-${intermediaryClassifier.get()}.jar"))
|
||||
|
||||
// https://www.spigotmc.org/threads/510208/#post-4184317
|
||||
val specialsource = project.configurations.named("spigotRemap").get().incoming.artifacts.artifacts
|
||||
.first { it.id.componentIdentifier.toString() == "net.md-5:SpecialSource:1.11.4" }.file.path
|
||||
val repo = Paths.get(project.repositories.mavenLocal().url)
|
||||
val spigotDir = repo.resolve("org/spigotmc/spigot/$spigotVer/")
|
||||
val mappingDir = repo.resolve("org/spigotmc/minecraft-server/$spigotVer/")
|
||||
|
||||
// Remap original Mojang-mapped jar to obfuscated intermediary
|
||||
val mojangServer = spigotDir.resolve("spigot-$spigotVer-remapped-mojang.jar")
|
||||
val mojangMappings = mappingDir.resolve("minecraft-server-$spigotVer-maps-mojang.txt")
|
||||
remapPartial(specialsource, mojangServer, mojangMappings, inFile, obfPath, true)
|
||||
|
||||
// Remap obfuscated intermediary jar to Spigot and replace original
|
||||
val obfServer = spigotDir.resolve("spigot-$spigotVer-remapped-obf.jar")
|
||||
val spigotMappings = mappingDir.resolve("minecraft-server-$spigotVer-maps-spigot.csrg")
|
||||
remapPartial(specialsource, obfServer, spigotMappings, obfPath, archiveFile.get().asFile, false)
|
||||
}
|
||||
|
||||
private fun remapPartial(specialSource: String, serverJar: Path, mapping: Path, input: File, output: File, reverse: Boolean) {
|
||||
project.providers.exec {
|
||||
commandLine("java", "-cp", "$specialSource${File.pathSeparator}$serverJar",
|
||||
"net.md_5.specialsource.SpecialSource", "--live",
|
||||
"-i", input.path, "-o", output.path,
|
||||
"-m", "$mapping",
|
||||
if (reverse) "--reverse" else "")
|
||||
}.result.get()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
|
||||
val spigotRemap = configurations.create("spigotRemap")
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
spigotRemap("net.md-5:SpecialSource:1.11.4:shaded")
|
||||
}
|
||||
|
||||
abstract class RemapTask
|
||||
@Inject constructor(private val project: Project): DefaultTask() {
|
||||
|
||||
@get:Input
|
||||
abstract var spigotVersion: String
|
||||
|
||||
@TaskAction
|
||||
fun remapInputs() {
|
||||
inputs.files.forEach {
|
||||
remap(spigotVersion, it.toPath(), it.toPath().resolveSibling(it.name.replace(".jar", "-obf.jar")))
|
||||
}
|
||||
}
|
||||
|
||||
private fun remap(spigotVersion: String, jarPath: Path, obfPath: Path) {
|
||||
// https://www.spigotmc.org/threads/510208/#post-4184317
|
||||
val specialsource = project.configurations.named("spigotRemap").get().incoming.artifacts.artifacts
|
||||
.first { it.id.componentIdentifier.toString() == "net.md-5:SpecialSource:1.11.4" }.file.path
|
||||
val repo = Paths.get(project.repositories.mavenLocal().url)
|
||||
val spigotDir = repo.resolve("org/spigotmc/spigot/$spigotVersion/")
|
||||
val mappingDir = repo.resolve("org/spigotmc/minecraft-server/$spigotVersion/")
|
||||
|
||||
// Remap original Mojang-mapped jar to obfuscated intermediary
|
||||
val mojangServer = spigotDir.resolve("spigot-$spigotVersion-remapped-mojang.jar")
|
||||
val mojangMappings = mappingDir.resolve("minecraft-server-$spigotVersion-maps-mojang.txt")
|
||||
remapPartial(specialsource, mojangServer, mojangMappings, jarPath, obfPath, true)
|
||||
|
||||
// Remap obfuscated intermediary jar to Spigot and replace original
|
||||
val obfServer = spigotDir.resolve("spigot-$spigotVersion-remapped-obf.jar")
|
||||
val spigotMappings = mappingDir.resolve("minecraft-server-$spigotVersion-maps-spigot.csrg")
|
||||
remapPartial(specialsource, obfServer, spigotMappings, obfPath, jarPath, false)
|
||||
}
|
||||
|
||||
private fun remapPartial(specialSource: String, serverJar: Path, mapping: Path, input: Path, output: Path, reverse: Boolean) {
|
||||
project.providers.exec {
|
||||
commandLine("java", "-cp", "$specialSource${File.pathSeparator}$serverJar",
|
||||
"net.md_5.specialsource.SpecialSource", "--live",
|
||||
"-i", "$input", "-o", "$output",
|
||||
"-m", "$mapping",
|
||||
if (reverse) "--reverse" else "")
|
||||
}.result.get()
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
# Project meta
|
||||
group=com.lishid.openinv
|
||||
version=5.1.8
|
||||
version=5.1.9
|
||||
description=A Bukkit plugin for opening normally-inaccessible inventories.
|
||||
|
||||
# Gradle configuration
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
plugins {
|
||||
`remap-spigot`
|
||||
`openinv-base`
|
||||
alias(libs.plugins.shadow)
|
||||
}
|
||||
@@ -9,6 +8,7 @@ repositories {
|
||||
}
|
||||
|
||||
val spigotVer = "1.21.4-R0.1-SNAPSHOT"
|
||||
rootProject.extra["spigotVersion"] = spigotVer
|
||||
rootProject.extra["craftbukkitPackage"] = "v1_21_R3"
|
||||
|
||||
configurations.all {
|
||||
@@ -25,7 +25,10 @@ configurations.all {
|
||||
}
|
||||
}
|
||||
|
||||
val spigotRemap = configurations.create("spigotRemap")
|
||||
|
||||
dependencies {
|
||||
spigotRemap("net.md-5:SpecialSource:1.11.4:shaded")
|
||||
compileOnly(libs.spigotapi)
|
||||
compileOnly(create("org.spigotmc", "spigot", spigotVer, classifier = "remapped-mojang"))
|
||||
|
||||
@@ -40,11 +43,24 @@ tasks.shadowJar {
|
||||
relocate("com.lishid.openinv.internal.common", "com.lishid.openinv.internal.reobf")
|
||||
}
|
||||
|
||||
// TODO this appears to be a deprecated way to do things
|
||||
// may want to just move all helper methods here.
|
||||
tasks.register<Remap_spigot_gradle.RemapTask>("reobf") {
|
||||
val reobfTask = tasks.register<ReobfTask>("reobfTask") {
|
||||
notCompatibleWithConfigurationCache("gradle is hard")
|
||||
dependsOn(tasks.shadowJar)
|
||||
inputs.files(tasks.shadowJar.get().outputs.files.files)
|
||||
spigotVersion = spigotVer
|
||||
inputFile.value(tasks.shadowJar.get().archiveFile.get())
|
||||
spigotVersion.value(spigotVer)
|
||||
}
|
||||
|
||||
configurations {
|
||||
consumable("reobf") {
|
||||
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("reobf", reobfTask)
|
||||
}
|
||||
@@ -13,7 +13,7 @@ dependencies {
|
||||
implementation(project(":openinvadaptercommon"))
|
||||
implementation(project(":openinvadapterpaper1_21_3"))
|
||||
implementation(project(":openinvadapterpaper1_21_1"))
|
||||
implementation(project(":openinvadapterspigot", configuration = "shadow"))
|
||||
implementation(project(":openinvadapterspigot", configuration = "reobf"))
|
||||
implementation(libs.planarwrappers)
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ tasks.jar {
|
||||
}
|
||||
|
||||
tasks.shadowJar {
|
||||
dependsOn(":openinvadapterspigot:reobf")
|
||||
minimize {
|
||||
exclude(":openinv**")
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user