mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 14:38:48 +00:00
Fetch LuckPerms download link dynamically, update repository configuration
This commit is contained in:
6 files changed
+119
-15
No files matched your search
@@ -18,6 +18,7 @@ dependencies {
|
||||
implementation(libs.configurateYaml)
|
||||
implementation(libs.gremlin.gradle)
|
||||
implementation(libs.run.task)
|
||||
implementation(libs.gson)
|
||||
|
||||
// https://github.com/gradle/gradle/issues/15383#issuecomment-779893192
|
||||
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.file.ProjectLayout
|
||||
import org.gradle.api.file.RegularFileProperty
|
||||
import org.gradle.api.tasks.OutputFile
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.gradle.api.tasks.UntrackedTask
|
||||
import java.net.URI
|
||||
import javax.inject.Inject
|
||||
|
||||
@UntrackedTask(because = "Always check for new metadata")
|
||||
abstract class FetchLuckPermsDownloads : DefaultTask() {
|
||||
companion object {
|
||||
const val ENDPOINT: String = "https://metadata.luckperms.net/data/downloads"
|
||||
}
|
||||
|
||||
@get:Inject
|
||||
abstract val layout: ProjectLayout
|
||||
|
||||
@get:OutputFile
|
||||
abstract val outputFile: RegularFileProperty
|
||||
|
||||
init {
|
||||
init()
|
||||
}
|
||||
|
||||
private fun init() {
|
||||
outputFile.convention(layout.buildDirectory.file("luckperms/downloads.json"))
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
fun run () {
|
||||
val url = URI.create(ENDPOINT).toURL()
|
||||
val data = url.readText(Charsets.UTF_8)
|
||||
val outFile = outputFile.get().asFile.also {
|
||||
it.parentFile.mkdirs()
|
||||
if (it.exists()) {
|
||||
it.delete()
|
||||
}
|
||||
}
|
||||
outFile.writeText(data, Charsets.UTF_8)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.JsonElement
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.file.ProjectLayout
|
||||
import org.gradle.api.file.RegularFileProperty
|
||||
import org.gradle.api.provider.Property
|
||||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.InputFile
|
||||
import org.gradle.api.tasks.OutputFile
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.gradle.api.tasks.TaskProvider
|
||||
import org.gradle.kotlin.dsl.register
|
||||
import java.net.URI
|
||||
import javax.inject.Inject
|
||||
|
||||
abstract class FetchLuckPermsJar : DefaultTask() {
|
||||
companion object {
|
||||
fun setup(
|
||||
project: Project,
|
||||
type: String,
|
||||
): TaskProvider<FetchLuckPermsJar> {
|
||||
val getMeta = project.tasks.register<FetchLuckPermsDownloads>("fetchLuckPermsDownloads")
|
||||
return project.tasks.register<FetchLuckPermsJar>("fetchLuckPermsJar") {
|
||||
this.type.set(type)
|
||||
inputFile.set(getMeta.flatMap { it.outputFile })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@get:Inject
|
||||
abstract val layout: ProjectLayout
|
||||
|
||||
@get:Input
|
||||
abstract val type: Property<String>
|
||||
|
||||
@get:InputFile
|
||||
abstract val inputFile: RegularFileProperty
|
||||
|
||||
@get:OutputFile
|
||||
abstract val outputFile: RegularFileProperty
|
||||
|
||||
init {
|
||||
init()
|
||||
}
|
||||
|
||||
private fun init() {
|
||||
outputFile.convention(type.flatMap {
|
||||
layout.buildDirectory.file("luckperms/${it}.jar")
|
||||
})
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
fun run () {
|
||||
val json = inputFile.get().asFile.readText(Charsets.UTF_8)
|
||||
val map = Gson().fromJson(json, JsonElement::class.java).asJsonObject.get("downloads").asJsonObject
|
||||
val url = map.get(type.get()).asString
|
||||
val data = URI.create(url).toURL().readBytes()
|
||||
val outFile = outputFile.get().asFile.also {
|
||||
it.parentFile.mkdirs()
|
||||
if (it.exists()) {
|
||||
it.delete()
|
||||
}
|
||||
}
|
||||
outFile.writeBytes(data)
|
||||
}
|
||||
}
|
||||
@@ -58,14 +58,15 @@ tasks {
|
||||
relocateDependency("net.fabricmc.mappingio")
|
||||
relocateCloud()
|
||||
}
|
||||
val luckperms = FetchLuckPermsJar.setup(project, "bukkit")
|
||||
withType(RunServer::class).configureEach {
|
||||
version.set(libs.versions.minecraft)
|
||||
downloadPlugins {
|
||||
url("https://download.luckperms.net/1575/bukkit/loader/LuckPerms-Bukkit-5.4.158.jar")
|
||||
github("MiniPlaceholders", "MiniPlaceholders", libs.versions.miniplaceholders.get(), "MiniPlaceholders-Paper-${libs.versions.miniplaceholders.get()}.jar")
|
||||
github("MiniPlaceholders", "PlaceholderAPI-Expansion", "1.2.0", "PlaceholderAPI-Expansion-1.2.0.jar")
|
||||
hangar("PlaceholderAPI", libs.versions.placeholderapi.get())
|
||||
}
|
||||
pluginJars.from(luckperms.flatMap { it.outputFile })
|
||||
providers.gradleProperty("smokeTest").map { it.toBoolean() }.getOrElse(false).let { smokeTest ->
|
||||
if (smokeTest) {
|
||||
runDirectory.set(layout.buildDirectory.dir("tmp/smokeTest"))
|
||||
|
||||
+5
-13
@@ -2,23 +2,21 @@ enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
|
||||
|
||||
dependencyResolutionManagement {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
mavenCentral {
|
||||
mavenContent { releasesOnly() }
|
||||
}
|
||||
maven("https://repo.jpenilla.xyz/snapshots/") {
|
||||
mavenContent {
|
||||
snapshotsOnly()
|
||||
includeModuleByRegex("de\\.hexaoxi", "messenger-.*")
|
||||
includeModule("org.incendo", "cloud-sponge")
|
||||
includeModule("com.seiama", "registry")
|
||||
includeModule("com.seiama", "event-api")
|
||||
}
|
||||
}
|
||||
maven("https://central.sonatype.com/repository/maven-snapshots/") {
|
||||
mavenContent { snapshotsOnly() }
|
||||
}
|
||||
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") {
|
||||
mavenContent { snapshotsOnly() }
|
||||
}
|
||||
maven("https://oss.sonatype.org/content/repositories/snapshots/") {
|
||||
mavenContent { snapshotsOnly() }
|
||||
}
|
||||
// PaperMC
|
||||
maven("https://repo.papermc.io/repository/maven-public/")
|
||||
// Sponge API
|
||||
@@ -70,12 +68,6 @@ pluginManagement {
|
||||
maven("https://central.sonatype.com/repository/maven-snapshots/") {
|
||||
mavenContent { snapshotsOnly() }
|
||||
}
|
||||
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") {
|
||||
mavenContent { snapshotsOnly() }
|
||||
}
|
||||
maven("https://oss.sonatype.org/content/repositories/snapshots/") {
|
||||
mavenContent { snapshotsOnly() }
|
||||
}
|
||||
maven("https://maven.fabricmc.net/")
|
||||
maven("https://repo.jpenilla.xyz/snapshots/") {
|
||||
mavenContent { snapshotsOnly() }
|
||||
|
||||
@@ -71,11 +71,12 @@ tasks {
|
||||
relocateDependency("io.leangen.geantyref")
|
||||
relocateGuice()
|
||||
}
|
||||
val luckperms = FetchLuckPermsJar.setup(project, "velocity")
|
||||
runVelocity {
|
||||
velocityVersion(libs.versions.velocityApi.get())
|
||||
pluginJars.from(prod)
|
||||
pluginJars.from(luckperms.flatMap { it.outputFile })
|
||||
downloadPlugins {
|
||||
url("https://download.luckperms.net/1575/velocity/LuckPerms-Velocity-5.4.158.jar")
|
||||
github("MiniPlaceholders", "MiniPlaceholders", libs.versions.miniplaceholders.get(), "MiniPlaceholders-Velocity-${libs.versions.miniplaceholders.get()}.jar")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user