|
| 1 | +import groovy.lang.Closure |
| 2 | +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar |
| 3 | +import com.palantir.gradle.gitversion.VersionDetails |
| 4 | +import org.gradle.api.tasks.compile.JavaCompile |
| 5 | +import org.gradle.language.jvm.tasks.ProcessResources |
| 6 | +import xyz.jpenilla.runpaper.task.RunServer |
| 7 | +import xyz.jpenilla.runwaterfall.task.RunWaterfall |
| 8 | +import xyz.jpenilla.runvelocity.task.RunVelocity |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | +val PLUGIN_NAME = "MaintenanceMOTDEagler" |
| 14 | +val PLUGIN_IDEN = "maintenancemotdeagler" |
| 15 | +val PLUGIN_DOMN = "xyz.webmc.$PLUGIN_IDEN" |
| 16 | +val PLUGIN_DESC = "An EaglerXServer addon to display the maintenance MOTD." |
| 17 | +val PLUGIN_VERS = "1.0.0" |
| 18 | +val PLUGIN_SITE = "https://github.com/WebMCDevelopment/$PLUGIN_IDEN" |
| 19 | +val PLUGIN_DEPA = listOf("EaglercraftXServer", "Maintenance") |
| 20 | +val PLUGIN_DEPB = listOf("EaglercraftXServer", "Maintenance") |
| 21 | +val PLUGIN_DEPC = listOf("eaglerxserver", "maintenance") |
| 22 | +val PLUGIN_SDPA = emptyList<String>() |
| 23 | +val PLUGIN_SDPB = emptyList<String>() |
| 24 | +val PLUGIN_SDPC = emptyList<String>() |
| 25 | +val PLUGIN_PROV = emptyList<String>() |
| 26 | +val PLUGIN_ATHR = listOf("Colbster937") |
| 27 | +val PLUGIN_CTBR = emptyList<String>() |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | +val PLUGIN_DEPA_J = getBukkitBungeeDeps(PLUGIN_DEPA) |
| 33 | +val PLUGIN_DEPB_J = getBukkitBungeeDeps(PLUGIN_DEPB) |
| 34 | +val PLUGIN_DEPC_J = getVelocityDeps(PLUGIN_DEPC, PLUGIN_SDPC) |
| 35 | +val PLUGIN_SDPA_J = getBukkitBungeeDeps(PLUGIN_SDPA) |
| 36 | +val PLUGIN_SDPB_J = getBukkitBungeeDeps(PLUGIN_SDPB) |
| 37 | +val PLUGIN_PROV_J = getBukkitBungeeDeps(PLUGIN_PROV) |
| 38 | +val PLUGIN_ATHR_J = getBukkitBungeeDeps(PLUGIN_ATHR) |
| 39 | +val PLUGIN_CTBR_J = getBukkitBungeeDeps(PLUGIN_CTBR) |
| 40 | + |
| 41 | +val EAGXS_VER = "1.0.8" |
| 42 | +val MTNCE_VER = "4.2.1" |
| 43 | + |
| 44 | +plugins { |
| 45 | + id("java") |
| 46 | + id("com.gradleup.shadow") version "9.3.1" |
| 47 | + id("com.palantir.git-version") version "4.2.0" |
| 48 | + id("xyz.jpenilla.run-paper") version "3.0.2" |
| 49 | + id("xyz.jpenilla.run-waterfall") version "3.0.2" |
| 50 | + id("xyz.jpenilla.run-velocity") version "3.0.2" |
| 51 | +} |
| 52 | + |
| 53 | +@Suppress("UNCHECKED_CAST") |
| 54 | +val GIT_INFO = (extra["versionDetails"] as Closure<VersionDetails>)() |
| 55 | + |
| 56 | +repositories { |
| 57 | + mavenCentral() |
| 58 | + maven("https://repo.papermc.io/repository/maven-public/") |
| 59 | + maven("https://oss.sonatype.org/content/groups/public/") |
| 60 | + maven("https://hub.spigotmc.org/nexus/content/repositories/public/") |
| 61 | + maven("https://repo.md-5.net/content/repositories/releases/") |
| 62 | + maven("https://repo.aikar.co/nexus/content/groups/aikar/") |
| 63 | + maven("https://repo.lax1dude.net/repository/releases/") |
| 64 | +} |
| 65 | + |
| 66 | +dependencies { |
| 67 | + compileOnly("com.velocitypowered:velocity-api:3.4.0-SNAPSHOT") |
| 68 | + compileOnly("org.bukkit:bukkit:1.8-R0.1-SNAPSHOT") |
| 69 | + compileOnly("net.md-5:bungeecord-api:1.21-R0.5-SNAPSHOT") |
| 70 | + compileOnly("net.lax1dude.eaglercraft.backend:api-velocity:1.0.0") |
| 71 | + compileOnly("net.lax1dude.eaglercraft.backend:api-bungee:1.0.0") |
| 72 | + compileOnly("net.lax1dude.eaglercraft.backend:api-bukkit:1.0.0") |
| 73 | + compileOnly("eu.kennytv.maintenance:maintenance-api:" + MTNCE_VER) |
| 74 | + compileOnly("eu.kennytv.maintenance:maintenance-spigot:" + MTNCE_VER) |
| 75 | + compileOnly("eu.kennytv.maintenance:maintenance-bungee:" + MTNCE_VER) |
| 76 | + compileOnly("eu.kennytv.maintenance:maintenance-velocity:" + MTNCE_VER) |
| 77 | + implementation("net.kyori:adventure-text-minimessage:4.26.1") |
| 78 | + implementation("net.kyori:adventure-text-serializer-legacy:4.26.1") |
| 79 | +} |
| 80 | + |
| 81 | +sourceSets { |
| 82 | + named("main") { |
| 83 | + java.srcDir("./src/main/java") |
| 84 | + resources.srcDir("./src/main/resources") |
| 85 | + } |
| 86 | +} |
| 87 | + |
| 88 | +java { |
| 89 | + toolchain.languageVersion.set(JavaLanguageVersion.of(17)) |
| 90 | +} |
| 91 | + |
| 92 | +val BUILD_PROPS = mapOf( |
| 93 | + "plugin_name" to PLUGIN_NAME, |
| 94 | + "plugin_iden" to PLUGIN_IDEN, |
| 95 | + "plugin_desc" to PLUGIN_DESC, |
| 96 | + "plugin_vers" to PLUGIN_VERS, |
| 97 | + "plugin_site" to PLUGIN_SITE, |
| 98 | + "plugin_depa" to PLUGIN_DEPA_J, |
| 99 | + "plugin_depb" to PLUGIN_DEPB_J, |
| 100 | + "plugin_depc" to PLUGIN_DEPC_J, |
| 101 | + "plugin_sdpa" to PLUGIN_SDPA_J, |
| 102 | + "plugin_sdpb" to PLUGIN_SDPB_J, |
| 103 | + "plugin_prov" to PLUGIN_PROV_J, |
| 104 | + "plugin_athr" to PLUGIN_ATHR_J, |
| 105 | + "plugin_ctbr" to PLUGIN_CTBR_J, |
| 106 | + "git_cm_hash" to GIT_INFO.gitHashFull, |
| 107 | +) |
| 108 | + |
| 109 | +tasks.withType<JavaCompile>().configureEach { |
| 110 | + options.encoding = "UTF-8" |
| 111 | + options.release.set(17) |
| 112 | +} |
| 113 | + |
| 114 | +tasks.withType<ProcessResources>().configureEach { |
| 115 | + duplicatesStrategy = DuplicatesStrategy.EXCLUDE |
| 116 | + outputs.upToDateWhen { false } |
| 117 | + |
| 118 | + doFirst { |
| 119 | + filesMatching(listOf("plugin.yml", "bungee.yml", "velocity-plugin.json")) { |
| 120 | + expand(BUILD_PROPS) |
| 121 | + } |
| 122 | + } |
| 123 | + |
| 124 | + doLast { |
| 125 | + val file = destinationDir.resolve("build.properties") |
| 126 | + file.parentFile.mkdirs() |
| 127 | + file.writeText( |
| 128 | + BUILD_PROPS.entries.joinToString("\n") { (k, v) -> |
| 129 | + "$k = $v" |
| 130 | + } |
| 131 | + ) |
| 132 | + } |
| 133 | + |
| 134 | + inputs.files(tasks.named<JavaCompile>("compileJava").map { it.outputs.files }) |
| 135 | +} |
| 136 | + |
| 137 | +tasks.withType<Jar>().configureEach { |
| 138 | + enabled = false |
| 139 | +} |
| 140 | + |
| 141 | +tasks.withType<ShadowJar>().configureEach { |
| 142 | + enabled = true |
| 143 | + doFirst { |
| 144 | + delete(layout.buildDirectory.dir("libs")) |
| 145 | + mkdir(layout.buildDirectory.dir("libs")) |
| 146 | + } |
| 147 | + archiveFileName.set("$PLUGIN_NAME-$PLUGIN_VERS.jar") |
| 148 | +} |
| 149 | + |
| 150 | +tasks.named("build") { |
| 151 | + dependsOn(tasks.named("shadowJar")) |
| 152 | +} |
| 153 | + |
| 154 | +tasks.register("printVars") { |
| 155 | + group = "help" |
| 156 | + doLast { |
| 157 | + println("VERS = " + PLUGIN_VERS) |
| 158 | + println("AFCT = " + tasks.named("shadowJar").get().outputs.files.singleFile.name.removeSuffix(".jar")) |
| 159 | + } |
| 160 | +} |
| 161 | + |
| 162 | +tasks.withType<RunServer>().configureEach { |
| 163 | + minecraftVersion("1.12.2") |
| 164 | + runDirectory.set(layout.projectDirectory.dir("run/paper")) |
| 165 | + jvmArgs("-Dcom.mojang.eula.agree=true") |
| 166 | + downloadPlugins { |
| 167 | + github("lax1dude", "eaglerxserver", "v" + EAGXS_VER, "EaglerXServer.jar") |
| 168 | + github("kennytv", "Maintenance", MTNCE_VER, "Maintenance-" + MTNCE_VER + ".jar") |
| 169 | + } |
| 170 | +} |
| 171 | + |
| 172 | +tasks.withType<RunWaterfall>().configureEach { |
| 173 | + waterfallVersion("1.21") |
| 174 | + runDirectory.set(layout.projectDirectory.dir("run/waterfall")) |
| 175 | + downloadPlugins { |
| 176 | + github("lax1dude", "eaglerxserver", "v" + EAGXS_VER, "EaglerXServer.jar") |
| 177 | + github("kennytv", "Maintenance", MTNCE_VER, "Maintenance-" + MTNCE_VER + ".jar") |
| 178 | + } |
| 179 | +} |
| 180 | + |
| 181 | +tasks.withType<RunVelocity>().configureEach { |
| 182 | + velocityVersion("3.4.0-SNAPSHOT") |
| 183 | + runDirectory.set(layout.projectDirectory.dir("run/velocity")) |
| 184 | + downloadPlugins { |
| 185 | + github("lax1dude", "eaglerxserver", "v" + EAGXS_VER, "EaglerXServer.jar") |
| 186 | + github("kennytv", "Maintenance", MTNCE_VER, "Maintenance-Velocity-" + MTNCE_VER + ".jar") |
| 187 | + } |
| 188 | +} |
| 189 | + |
| 190 | +fun getBukkitBungeeDeps(list: List<String>): String { |
| 191 | + return list.joinToString( |
| 192 | + prefix = "[", |
| 193 | + postfix = "]" |
| 194 | + ) { "\"$it\"" } |
| 195 | +} |
| 196 | + |
| 197 | +fun getVelocityDeps(a: List<String>, b: List<String>): String { |
| 198 | + val c = a.joinToString(", ") { "{\"id\":\"$it\",\"optional\":false}" } |
| 199 | + val d = b.joinToString(", ") { "{\"id\":\"$it\",\"optional\":true}" } |
| 200 | + return "[" + listOf(c, d).filter { it.isNotEmpty() }.joinToString(",") + "]" |
| 201 | +} |
0 commit comments