2024-09-11 14:12:29 +08:00
|
|
|
import io.papermc.hangarpublishplugin.model.Platforms
|
|
|
|
|
2024-08-01 17:06:57 +08:00
|
|
|
plugins {
|
|
|
|
id("java")
|
|
|
|
id("com.github.johnrengelman.shadow") version "8.1.1"
|
2024-09-11 14:12:29 +08:00
|
|
|
id("io.papermc.hangar-publish-plugin") version "0.1.2"
|
2024-08-01 17:06:57 +08:00
|
|
|
}
|
|
|
|
|
2024-10-07 16:09:10 +08:00
|
|
|
var BuildFull = properties["BuildFull"].toString() == "true"
|
|
|
|
var libraries = listOf<String>()
|
2024-10-12 15:19:13 +08:00
|
|
|
libraries = libraries + "cn.lunadeer:MinecraftPluginUtils:2.0.7"
|
2024-10-07 16:09:10 +08:00
|
|
|
|
2024-08-01 17:06:57 +08:00
|
|
|
group = "cn.lunadeer"
|
2024-10-19 18:12:09 +08:00
|
|
|
version = "2.14.4-beta"
|
2024-08-01 23:06:01 +08:00
|
|
|
|
|
|
|
java {
|
2024-10-09 14:45:59 +08:00
|
|
|
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
2024-08-01 23:06:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// utf-8
|
|
|
|
tasks.withType<JavaCompile> {
|
|
|
|
options.encoding = "UTF-8"
|
|
|
|
}
|
2024-08-01 17:06:57 +08:00
|
|
|
|
2024-08-05 15:45:59 +08:00
|
|
|
allprojects {
|
2024-08-05 00:52:12 +08:00
|
|
|
apply(plugin = "java")
|
|
|
|
apply(plugin = "com.github.johnrengelman.shadow")
|
|
|
|
|
|
|
|
repositories {
|
|
|
|
mavenLocal()
|
2024-08-12 16:32:34 +08:00
|
|
|
mavenCentral()
|
2024-08-05 00:52:12 +08:00
|
|
|
maven("https://oss.sonatype.org/content/groups/public")
|
|
|
|
maven("https://repo.papermc.io/repository/maven-public/")
|
|
|
|
maven("https://jitpack.io")
|
|
|
|
maven("https://repo.mikeprimm.com/")
|
2024-08-11 01:59:34 +08:00
|
|
|
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
|
2024-10-19 17:24:07 +08:00
|
|
|
maven("https://repo.codemc.org/repository/maven-public")
|
2024-08-05 00:52:12 +08:00
|
|
|
}
|
2024-08-01 17:06:57 +08:00
|
|
|
|
2024-08-05 00:52:12 +08:00
|
|
|
dependencies {
|
|
|
|
compileOnly("com.github.BlueMap-Minecraft:BlueMapAPI:v2.6.2")
|
|
|
|
compileOnly("us.dynmap:DynmapCoreAPI:3.4")
|
2024-08-11 01:59:34 +08:00
|
|
|
compileOnly("me.clip:placeholderapi:2.11.6")
|
2024-10-19 17:19:06 +08:00
|
|
|
compileOnly("com.github.MilkBowl:VaultAPI:1.7")
|
|
|
|
compileOnly("net.milkbowl.vault:VaultUnlockedAPI:2.2")
|
2024-08-01 23:06:01 +08:00
|
|
|
|
2024-10-07 16:09:10 +08:00
|
|
|
if (!BuildFull) {
|
|
|
|
libraries.forEach {
|
|
|
|
compileOnly(it)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
libraries.forEach {
|
|
|
|
implementation(it)
|
|
|
|
}
|
|
|
|
}
|
2024-08-05 00:52:12 +08:00
|
|
|
}
|
2024-08-01 17:06:57 +08:00
|
|
|
|
2024-08-05 15:45:59 +08:00
|
|
|
tasks.processResources {
|
2024-08-12 10:56:53 +08:00
|
|
|
outputs.upToDateWhen { false }
|
2024-09-11 14:12:29 +08:00
|
|
|
// copy languages folder from PROJECT_DIR/languages to core/src/main/resources
|
|
|
|
from(file("${projectDir}/languages")) {
|
|
|
|
into("languages")
|
|
|
|
}
|
2024-08-01 23:06:01 +08:00
|
|
|
// replace @version@ in plugin.yml with project version
|
|
|
|
filesMatching("**/plugin.yml") {
|
|
|
|
filter {
|
2024-08-05 15:45:59 +08:00
|
|
|
it.replace("@version@", rootProject.version.toString())
|
2024-08-01 23:06:01 +08:00
|
|
|
}
|
2024-10-07 16:09:10 +08:00
|
|
|
if (!BuildFull) {
|
|
|
|
var libs = "libraries: ["
|
|
|
|
libraries.forEach {
|
|
|
|
libs += "$it,"
|
|
|
|
}
|
|
|
|
filter {
|
2024-10-07 17:50:47 +08:00
|
|
|
it.replace("libraries: [ ]", libs.substring(0, libs.length - 1) + "]")
|
2024-10-07 16:09:10 +08:00
|
|
|
}
|
|
|
|
}
|
2024-08-01 23:06:01 +08:00
|
|
|
}
|
|
|
|
}
|
2024-08-01 18:03:21 +08:00
|
|
|
|
2024-08-05 15:45:59 +08:00
|
|
|
tasks.shadowJar {
|
2024-08-01 23:06:01 +08:00
|
|
|
archiveClassifier.set("")
|
|
|
|
archiveVersion.set(project.version.toString())
|
2024-08-05 00:52:12 +08:00
|
|
|
dependsOn(tasks.withType<ProcessResources>())
|
2024-10-07 16:09:10 +08:00
|
|
|
// add -lite to the end of the file name if BuildLite is true or -full if BuildLite is false
|
|
|
|
archiveFileName.set("${project.name}-${project.version}${if (BuildFull) "-full" else "-lite"}.jar")
|
2024-08-01 23:06:01 +08:00
|
|
|
}
|
2024-08-05 15:45:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
implementation(project(":core"))
|
|
|
|
implementation(project(":v1_20_1"))
|
|
|
|
implementation(project(":v1_21"))
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.shadowJar {
|
|
|
|
archiveClassifier.set("")
|
|
|
|
archiveVersion.set(project.version.toString())
|
|
|
|
}
|
|
|
|
|
2024-10-07 16:09:10 +08:00
|
|
|
tasks.register("Clean&Build") { // <<<< RUN THIS TASK TO BUILD PLUGIN
|
2024-08-12 10:56:53 +08:00
|
|
|
dependsOn(tasks.clean)
|
|
|
|
dependsOn(tasks.shadowJar)
|
2024-09-11 14:12:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
hangarPublish {
|
|
|
|
publications.register("plugin") {
|
|
|
|
version.set(project.version as String) // use project version as publication version
|
|
|
|
id.set("Dominion")
|
|
|
|
channel.set("Beta")
|
|
|
|
changelog.set("See https://github.com/ColdeZhang/Dominion/releases/tag/v${project.version}")
|
|
|
|
apiKey.set(System.getenv("HANGAR_TOKEN"))
|
|
|
|
// register platforms
|
|
|
|
platforms {
|
|
|
|
register(Platforms.PAPER) {
|
|
|
|
jar.set(tasks.shadowJar.flatMap { it.archiveFile })
|
|
|
|
println("ShadowJar: ${tasks.shadowJar.flatMap { it.archiveFile }}")
|
|
|
|
platformVersions.set(listOf("1.20.1-1.20.6","1.21.x"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.named("publishPluginPublicationToHangar") {
|
2024-10-07 16:38:19 +08:00
|
|
|
dependsOn(tasks.named("jar"))
|
2024-08-05 00:52:12 +08:00
|
|
|
}
|