|
1 | 1 | import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar |
2 | 2 | import io.papermc.paperweight.userdev.attribute.Obfuscation |
| 3 | +import me.modmuss50.mpp.ReleaseType |
3 | 4 |
|
4 | 5 | plugins { |
5 | 6 | `java-library` |
6 | | - alias(libs.plugins.minotaur) |
| 7 | + alias(libs.plugins.mod.publish.plugin) |
7 | 8 | } |
8 | 9 |
|
9 | 10 | project.description = "Bukkit" |
@@ -47,21 +48,26 @@ val localImplementation = configurations.create("localImplementation") { |
47 | 48 | } |
48 | 49 |
|
49 | 50 | val adapters = configurations.create("adapters") { |
50 | | - description = "Adapters to include in the JAR" |
| 51 | + description = "Adapters to include in the JAR (Mojmap)" |
51 | 52 | isCanBeConsumed = false |
52 | 53 | isCanBeResolved = true |
53 | 54 | shouldResolveConsistentlyWith(configurations["runtimeClasspath"]) |
54 | 55 | attributes { |
55 | | - attribute(Obfuscation.OBFUSCATION_ATTRIBUTE, |
56 | | - if ((project.findProperty("enginehub.obf.none") as String?).toBoolean()) { |
57 | | - objects.named(Obfuscation.NONE) |
58 | | - } else { |
59 | | - objects.named(Obfuscation.OBFUSCATED) |
60 | | - } |
61 | | - ) |
| 56 | + attribute(Obfuscation.OBFUSCATION_ATTRIBUTE, objects.named(Obfuscation.NONE)) |
62 | 57 | } |
63 | 58 | } |
64 | 59 |
|
| 60 | +val adaptersReobf = configurations.create("adaptersReobf") { |
| 61 | + description = "Adapters to include in the JAR (Spigot-Mapped)" |
| 62 | + isCanBeConsumed = false |
| 63 | + isCanBeResolved = true |
| 64 | + shouldResolveConsistentlyWith(configurations["runtimeClasspath"]) |
| 65 | + attributes { |
| 66 | + attribute(Obfuscation.OBFUSCATION_ATTRIBUTE, objects.named(Obfuscation.OBFUSCATED)) |
| 67 | + } |
| 68 | + extendsFrom(adapters) |
| 69 | +} |
| 70 | + |
65 | 71 | dependencies { |
66 | 72 | // Modules |
67 | 73 | api(projects.worldeditCore) |
@@ -141,9 +147,37 @@ tasks.named<Jar>("jar") { |
141 | 147 |
|
142 | 148 | addJarManifest(WorldEditKind.Plugin, includeClasspath = true) |
143 | 149 |
|
| 150 | +tasks.register<ShadowJar>("reobfShadowJar") { |
| 151 | + archiveFileName.set("${rootProject.name}-Bukkit-${project.version}.${archiveExtension.getOrElse("jar")}") |
| 152 | + configurations = listOf( |
| 153 | + project.configurations.runtimeClasspath.get(), // as is done by shadow for the default shadowJar |
| 154 | + adaptersReobf |
| 155 | + ) |
| 156 | + |
| 157 | + // as is done by shadow for the default shadowJar |
| 158 | + from(sourceSets.main.map { it.output }) |
| 159 | + manifest.inheritFrom(tasks.jar.get().manifest) |
| 160 | + exclude("META-INF/INDEX.LIST", "META-INF/*.SF", "META-INF/*.DSA", "META-INF/*.RSA", "module-info.class") |
| 161 | + |
| 162 | + manifest { |
| 163 | + attributes( |
| 164 | + "FAWE-Plugin-Jar-Type" to "spigot" |
| 165 | + ) |
| 166 | + } |
| 167 | +} |
| 168 | + |
144 | 169 | tasks.named<ShadowJar>("shadowJar") { |
| 170 | + archiveFileName.set("${rootProject.name}-Paper-${project.version}.${archiveExtension.getOrElse("jar")}") |
145 | 171 | configurations.add(adapters) |
146 | | - archiveFileName.set("${rootProject.name}-Bukkit-${project.version}.${archiveExtension.getOrElse("jar")}") |
| 172 | + manifest { |
| 173 | + attributes( |
| 174 | + "paperweight-mappings-namespace" to "mojang", |
| 175 | + "FAWE-Plugin-Jar-Type" to "mojang" |
| 176 | + ) |
| 177 | + } |
| 178 | +} |
| 179 | + |
| 180 | +tasks.withType<ShadowJar>().configureEach { |
147 | 181 | dependencies { |
148 | 182 | // In tandem with not bundling log4j, we shouldn't relocate base package here. |
149 | 183 | // relocate("org.apache.logging", "com.sk89q.worldedit.log4j") |
@@ -198,20 +232,51 @@ tasks.named<ShadowJar>("shadowJar") { |
198 | 232 |
|
199 | 233 | tasks.named("assemble").configure { |
200 | 234 | dependsOn("shadowJar") |
| 235 | + dependsOn("reobfShadowJar") |
201 | 236 | } |
202 | 237 |
|
203 | | -tasks { |
204 | | - modrinth { |
205 | | - token.set(System.getenv("MODRINTH_TOKEN")) |
| 238 | +publishMods { |
| 239 | + displayName.set("${project.version}") |
| 240 | + version.set("${project.version}") |
| 241 | + type.set(ReleaseType.STABLE) |
| 242 | + changelog.set("The changelog is available on GitHub: https://github.com/IntellectualSites/" + |
| 243 | + "FastAsyncWorldEdit/releases/tag/${project.version}") |
| 244 | + |
| 245 | + val common = modrinthOptions { |
| 246 | + accessToken.set(System.getenv("MODRINTH_TOKEN")) |
206 | 247 | projectId.set("fastasyncworldedit") |
207 | | - versionName.set("${project.version}") |
208 | | - versionNumber.set("${project.version}") |
209 | | - versionType.set("release") |
210 | | - uploadFile.set(file("build/libs/${rootProject.name}-Bukkit-${project.version}.jar")) |
211 | | - gameVersions.addAll(listOf("1.20.2", "1.20.4", "1.20.6", "1.21.1", "1.21.3")) |
212 | | - loaders.addAll(listOf("paper", "spigot")) |
213 | | - changelog.set("The changelog is available on GitHub: https://github.com/IntellectualSites/" + |
214 | | - "FastAsyncWorldEdit/releases/tag/${project.version}") |
215 | | - syncBodyFrom.set(rootProject.file("README.md").readText()) |
| 248 | + projectDescription.set(rootProject.file("README.md").readText()) |
216 | 249 | } |
| 250 | + |
| 251 | + // We publish the reobfJar twice to ensure that the modrinth download menu picks the right jar for the platform regardless |
| 252 | + // of minecraft version. |
| 253 | + |
| 254 | + val mojmapPaperVersions = listOf("1.20.6", "1.21.1", "1.21.3") |
| 255 | + val spigotMappedPaperVersions = listOf("1.20.2", "1.20.4") |
| 256 | + |
| 257 | + // Mark reobfJar as spigot only for 1.20.5+ |
| 258 | + modrinth("spigot") { |
| 259 | + from(common) |
| 260 | + file.set(tasks.named<ShadowJar>("reobfShadowJar").flatMap { it.archiveFile }) |
| 261 | + minecraftVersions.set(mojmapPaperVersions) |
| 262 | + modLoaders.set(listOf("spigot")) |
| 263 | + } |
| 264 | + |
| 265 | + // Mark reobfJar as spigot & paper for <1.20.5 |
| 266 | + modrinth("spigotAndOldPaper") { |
| 267 | + from(common) |
| 268 | + file.set(tasks.named<ShadowJar>("reobfShadowJar").flatMap { it.archiveFile }) |
| 269 | + minecraftVersions.set(spigotMappedPaperVersions) |
| 270 | + modLoaders.set(listOf("paper", "spigot")) |
| 271 | + } |
| 272 | + |
| 273 | + // Mark mojang mapped jar as paper 1.20.5+ only |
| 274 | + modrinth { |
| 275 | + from(common) |
| 276 | + file.set(tasks.named<ShadowJar>("shadowJar").flatMap { it.archiveFile }) |
| 277 | + minecraftVersions.set(mojmapPaperVersions) |
| 278 | + modLoaders.set(listOf("paper")) |
| 279 | + } |
| 280 | + |
| 281 | + // dryRun.set(true) // For testing |
217 | 282 | } |
0 commit comments