Files
ShopPro/build.gradle.kts

193 lines
7.2 KiB
Kotlin

plugins {
`java-library`
`maven-publish`
id("io.izzel.taboolib") version "2.0.2-community-1"
id("org.jetbrains.kotlin.jvm") version "1.7.10"
}
taboolib {
description {
dependencies {
name("PlaceholderAPI").optional(true)
name("Vault").optional(true)
name("MMOItems").optional(true)
name("Zaphkiel").optional(true)
name("NeigeItems").optional(true)
}
contributors {
name("xbaimiao")
}
val bukkitNodes = bukkitNodes as MutableMap<Any, Any>
bukkitNodes["update-info"] = "支持1.12.2物品附加值"
}
env {
// TabooLib 6.2 split the legacy bundles into versioned modules. The
// 6.2 platform contains the Bukkit 1.21 compatibility layer.
install(
"bukkit-ui",
"minecraft-command-helper",
"bukkit-hook",
"bukkit-util",
"bukkit-xseries",
"platform-bukkit",
"platform-bukkit-impl",
"database",
"minecraft-chat",
"basic-configuration",
"minecraft-i18n",
"minecraft-kether"
)
repoTabooLib = "https://maven.xbaimiao.com/repository/maven-public/"
}
version {
taboolib = "6.2.0-beta33"
}
// relocate("kotlin", "libs.kotlin171")
relocate("com.xbaimiao.ktor", "com.github.xbaimiao.shoppro.stat")
}
repositories {
mavenCentral()
maven("https://maven.xbaimiao.com/repository/maven-public/")
maven("https://r.irepo.space/maven/")
}
val bundledRuntime by configurations.creating
val taboolibRuntimeModules = listOf(
"common",
"platform-bukkit",
"common-env",
"common-util",
"common-legacy-api",
"common-platform-api",
"bukkit-ui",
"minecraft-command-helper",
"bukkit-hook",
"bukkit-util",
"bukkit-xseries",
"platform-bukkit-impl",
"database",
"minecraft-chat",
"basic-configuration",
"minecraft-i18n",
"minecraft-kether"
)
dependencies {
// These files are embedded as resources and installed before TabooLib's
// primitive loader runs, so a server can start without Maven access.
add("bundledRuntime", "me.lucko:jar-relocator:1.7")
add("bundledRuntime", "org.ow2.asm:asm:9.6")
add("bundledRuntime", "org.ow2.asm:asm-util:9.6")
add("bundledRuntime", "org.ow2.asm:asm-commons:9.6")
add("bundledRuntime", "org.tabooproject.reflex:reflex:1.1.7")
add("bundledRuntime", "org.tabooproject.reflex:analyser:1.1.7")
add("bundledRuntime", "org.jetbrains.kotlin:kotlin-stdlib:1.7.10")
add("bundledRuntime", "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10")
add("bundledRuntime", "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.7.3")
taboolibRuntimeModules.forEach { module ->
add("bundledRuntime", "io.izzel.taboolib:$module:6.2.0-beta33")
}
}
val prepareBundledRuntime by tasks.registering {
val output = layout.buildDirectory.dir("generated/bundled-runtime")
outputs.dir(output)
doLast {
val root = output.get().asFile
root.deleteRecursively()
val resourceRoot = root.resolve("META-INF/taboolib/bundled")
val index = linkedMapOf<String, String>()
configurations["bundledRuntime"].resolvedConfiguration.resolvedArtifacts.forEach { artifact ->
val module = artifact.moduleVersion.id
val relative = "${module.group.replace('.', '/')}/${module.name}/${module.version}/${module.name}-${module.version}.jar"
val destination = resourceRoot.resolve(relative)
destination.parentFile.mkdirs()
artifact.file.copyTo(destination, overwrite = true)
index[relative] = relative
// The TabooLib build metadata in this project is generated by the
// Kotlin 1.7.10 Gradle plugin, while Reflex 1.1.7 resolves a newer
// compatible stdlib transitively. Install the resolved bytes at
// the exact paths PrimitiveSettings requests as well.
if (module.group == "org.jetbrains.kotlin" &&
(module.name == "kotlin-stdlib" || module.name == "kotlin-stdlib-jdk8")) {
val requested = "${module.group.replace('.', '/')}/${module.name}/1.7.10/${module.name}-1.7.10.jar"
val requestedDestination = resourceRoot.resolve(requested)
requestedDestination.parentFile.mkdirs()
artifact.file.copyTo(requestedDestination, overwrite = true)
index[requested] = requested
val requestedPom = requested.removeSuffix(".jar") + ".pom"
val requestedPomFile = resourceRoot.resolve(requestedPom)
requestedPomFile.parentFile.mkdirs()
requestedPomFile.writeText(
"<project><modelVersion>4.0.0</modelVersion>" +
"<groupId>${module.group}</groupId><artifactId>${module.name}</artifactId>" +
"<version>1.7.10</version></project>",
Charsets.UTF_8
)
index[requestedPom] = requestedPom
}
// RuntimeEnvDependency checks POM + SHA-1 files for Kotlin and
// coroutine roots. A minimal local POM is sufficient because all
// requested root JARs are bundled explicitly.
if (module.group == "org.jetbrains.kotlin" || module.group == "org.jetbrains.kotlinx") {
val pomRelative = relative.removeSuffix(".jar") + ".pom"
val pom = resourceRoot.resolve(pomRelative)
pom.parentFile.mkdirs()
pom.writeText(
"<project><modelVersion>4.0.0</modelVersion>" +
"<groupId>${module.group}</groupId><artifactId>${module.name}</artifactId>" +
"<version>${module.version}</version></project>",
Charsets.UTF_8
)
index[pomRelative] = pomRelative
}
}
val indexFile = root.resolve("META-INF/taboolib/bundled-libraries.properties")
indexFile.parentFile.mkdirs()
indexFile.writeText(index.entries.joinToString("\n") { (target, resource) -> "$target=$resource" } + "\n", Charsets.UTF_8)
}
}
tasks.processResources {
dependsOn(prepareBundledRuntime)
from(prepareBundledRuntime)
}
dependencies {
compileOnly("com.mojang:authlib:3.16.29")
compileOnly("ink.ptms:nms-all:1.0.0")
compileOnly("public:MythicMobs:4.14.1")
compileOnly("public:papi:1.0.0")
compileOnly("public:vault:1.0.0")
compileOnly("public:points:1.0.0")
compileOnly("ink.ptms.core:v11902:11902-minimize:mapped")
compileOnly("ink.ptms.core:v11902:11902-minimize:universal")
compileOnly("public:Zaphkiel:1.0.0")
compileOnly("pers.neige.neigeitems:NeigeItems:1.15.113")
compileOnly("public:MMOItems:6.9.4")
// taboo(kotlin("stdlib"))
compileOnly(fileTree("libs"))
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = listOf("-Xjvm-default=all")
}
}
configure<JavaPluginConvention> {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}