Skip to content

Commit

Permalink
Splits modrinth publish.
Browse files Browse the repository at this point in the history
  • Loading branch information
toxicity188 committed Nov 2, 2024
1 parent 0c57725 commit 2fa4fcf
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Publish to Modrinth
run: ./gradlew modrinth --stacktrace
run: ./gradlew modrinthPublish --stacktrace
- name: Publish to Hangar
run: ./gradlew publishPluginPublicationToHangar --stacktrace
2 changes: 1 addition & 1 deletion BANNER.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div align="center">
<div style="text-align: center;">

![-0001-export](https://github.com/toxicity188/BetterHud/assets/114675706/ccbf4bd3-9133-44ee-b277-985eae4349ae)

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div align="center">
<div style="text-align: center;">

![-0001-export](https://github.com/toxicity188/BetterHud/assets/114675706/ccbf4bd3-9133-44ee-b277-985eae4349ae)

Expand Down Expand Up @@ -47,7 +47,8 @@ This project implements a server-side HUD.
Requires Java 17, 21 Eclipse Adoptium.

- Build all available jar: ./gradlew build
- Build Bukkit plugin: ./gradlew pluginJar
- Build Bukkit plugin: ./gradlew pluginJar
- Build Velocity plugin: ./gradlew velocityJar
- Build Fabric server side mod: ./gradlew fabricJar
- Build source code jar: ./gradlew sourceJar
- Build dokka-based docs jar: ./gradlew dokkaJar
Expand Down
79 changes: 56 additions & 23 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,27 @@ fun Project.legacy() = also {
toolchain.languageVersion = JavaLanguageVersion.of(17)
}
}
fun Project.modrinthPublish(depend: Jar, additionalJar: List<Jar>, supports: List<String>) {
apply(plugin = "com.modrinth.minotaur")
tasks.modrinth {
dependsOn(
depend
)
}
modrinth {
token = System.getenv("MODRINTH_API_TOKEN")
projectId = "betterhud2"
versionType = "alpha"
changelog = System.getenv("COMMIT_MESSAGE")
versionNumber = project.version as String
uploadFile.set(depend.archiveFile)
additionalFiles = additionalJar.map {
it.archiveFile
}
gameVersions = supportedMinecraftVersions
loaders = supports
}
}

val apiShare = project("api:standard-api").adventure().legacy()
val apiBukkit = project("api:bukkit-api").adventure().bukkit().dependency(apiShare).legacy()
Expand Down Expand Up @@ -307,9 +328,7 @@ val fabricJar by tasks.creating(Jar::class.java) {
}
}
val pluginJar by tasks.creating(Jar::class.java) {
from(zipTree(velocityBootstrap.tasks.jar.map {
it.archiveFile
}))
archiveClassifier = "bukkit"
from(zipTree(bukkitBootstrap.tasks.jar.map {
it.archiveFile
}))
Expand Down Expand Up @@ -338,6 +357,18 @@ val pluginJar by tasks.creating(Jar::class.java) {
relocateAll()
}
}
val velocityJar by tasks.creating(Jar::class.java) {
archiveClassifier = "velocity"
from(zipTree(velocityBootstrap.tasks.jar.map {
it.archiveFile
}))
from(zipTree(tasks.shadowJar.map {
it.archiveFile
}))
doLast {
relocateAll()
}
}

fun Jar.relocateAll() {
val file = archiveFile.get().asFile
Expand Down Expand Up @@ -375,10 +406,7 @@ tasks {
pluginJars(fileTree("plugins"))
}
build {
finalizedBy(sourceJar)
finalizedBy(dokkaJar)
finalizedBy(pluginJar)
finalizedBy(fabricJar)
finalizedBy(sourceJar, dokkaJar, pluginJar, velocityJar, fabricJar)
}
logLinkDokkaGeneratePublicationHtml {
enabled = false
Expand All @@ -390,15 +418,33 @@ tasks {
}
}

tasks.modrinth {
bukkitBootstrap.modrinthPublish(
pluginJar,
listOf(sourceJar, dokkaJar),
listOf("bukkit", "spigot", "paper", "purpur", "folia")
)

velocityBootstrap.modrinthPublish(
velocityJar,
listOf(sourceJar, dokkaJar),
listOf("velocity")
)
fabricBootstrap.modrinthPublish(
fabricJar,
listOf(sourceJar, dokkaJar),
listOf("fabric", "qulit")
)

tasks.create("modrinthPublish") {
dependsOn(
tasks.shadowJar,
sourceJar,
dokkaJar,
pluginJar,
fabricJar,
tasks.modrinthSyncBody
)
bootstrap.forEach {
dependsOn(it.modrinth)
}
}

hangarPublish {
Expand All @@ -422,18 +468,5 @@ hangarPublish {
}

modrinth {
token = System.getenv("MODRINTH_API_TOKEN")
projectId = "betterhud2"
versionType = "alpha"
changelog = System.getenv("COMMIT_MESSAGE")
versionNumber = project.version as String
uploadFile.set(file("build/libs/${project.name}-${project.version}.jar"))
additionalFiles = listOf(
file("build/libs/${project.name}-${project.version}-dokka.jar"),
file("build/libs/${project.name}-${project.version}-source.jar"),
file("build/libs/${project.name}-${project.version}-fabric+$minecraft.jar")
)
gameVersions = supportedMinecraftVersions
loaders = listOf("bukkit", "spigot", "paper", "purpur", "folia", "velocity")
syncBodyFrom = rootProject.file("BANNER.md").readText()
}

0 comments on commit 2fa4fcf

Please sign in to comment.