Skip to content

Commit

Permalink
Move to Gradle, set up publishing, get rid of item steerables workaro…
Browse files Browse the repository at this point in the history
…und (#26)

* Gradle changes 

* init: remove item steerable option

* Use javadowngrader to produce Java 8 compatible jars

* Address review

---------

Co-authored-by: Joshua Castle <[email protected]>
  • Loading branch information
onebeastchris and Kas-tle authored Sep 9, 2024
1 parent d9e8af2 commit bde84b0
Show file tree
Hide file tree
Showing 39 changed files with 694 additions and 891 deletions.
82 changes: 55 additions & 27 deletions .github/workflows/build-workflow.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,68 @@
name: Build Hurricane
name: Build

on: push
on:
workflow_dispatch:
push:
paths-ignore:
- '.gitignore'
- 'LICENSE'
- 'README.md'

jobs:
build-job:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Java
uses: actions/setup-java@v2
- name: Setup Gradle
uses: GeyserMC/actions/setup-gradle-composite@master
with:
distribution: 'temurin'
java-version: '17'
cache: 'maven'

- name: Prepare NMS 1.17 mappings
run: mvn ca.bkaw:paper-nms-maven-plugin:1.2:init -pl :nms-1_17_R1
setup-java_java-version: 21

- name: Prepare NMS 1.18 mappings
run: mvn ca.bkaw:paper-nms-maven-plugin:1.2:init -pl :nms-1_18_R1
- name: Build Hurricane
run: ./gradlew build

- name: Prepare NMS 1.18.2 mappings
run: mvn ca.bkaw:paper-nms-maven-plugin:1.2:init -pl :nms-1_18_R2
- name: Archive Artifacts
uses: GeyserMC/actions/upload-multi-artifact@master
if: success()
with:
artifacts: |
spigot/build/libs/hurricane-spigot.jar
- name: Prepare NMS 1.19.2 mappings
run: mvn ca.bkaw:paper-nms-maven-plugin:1.2:init -pl :nms-1_19_R1
- name: Get Version
if: ${{ success() && github.repository == 'GeyserMC/Hurricane' && github.ref_name == 'master' }}
id: get-version
run: |
version=$(cat gradle.properties | grep -o "^version=[0-9\\.]*" | cut -d"=" -f2)
echo "VERSION=${version}" >> $GITHUB_OUTPUT
- name: Prepare NMS 1.19.3 mappings
run: mvn ca.bkaw:paper-nms-maven-plugin:1.2:init -pl :nms-1_19_R2
- name: Get Release Metadata
if: ${{ success() && github.repository == 'GeyserMC/Hurricane' && github.ref_name == 'master' }}
uses: GeyserMC/actions/release@master
id: metadata
with:
appID: ${{ secrets.RELEASE_APP_ID }}
appPrivateKey: ${{ secrets.RELEASE_APP_PK }}
files: |
spigot:spigot/build/libs/hurricane-spigot.jar
releaseEnabled: false
saveMetadata: true
releaseProject: 'hurricane'
releaseVersion: ${{ steps.get-version.outputs.VERSION }}

- name: Build with Maven
run: mvn -B package -T 2C
- name: Publish to Downloads API
if: ${{ success() && github.repository == 'GeyserMC/Hurricane' && github.ref_name == 'master' }}
uses: GeyserMC/actions/upload-release@master
with:
username: ${{ vars.DOWNLOADS_USERNAME }}
privateKey: ${{ secrets.DOWNLOADS_PRIVATE_KEY }}
host: ${{ secrets.DOWNLOADS_SERVER_IP }}
files: |
spigot/build/libs/hurricane-spigot.jar
changelog: ${{ steps.metadata.outputs.body }}

- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
- name: Notify Discord
if: ${{ (success() || failure()) && github.repository == 'GeyserMC/Hurricane' }}
uses: GeyserMC/actions/notify-discord@master
with:
files: spigot/target/Hurricane.jar
discordWebhook: ${{ secrets.DISCORD_WEBHOOK }}
status: ${{ job.status }}
body: ${{ steps.metadata.outputs.body }}
14 changes: 12 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ out/
*.ctxt

# Package Files #
*.jar
#*.jar
*.war
*.nar
*.ear
Expand Down Expand Up @@ -111,4 +111,14 @@ buildNumber.properties

# Common working directory
run/
.paper-nms
.paper-nms


### Gradle ###
.gradle
**/build/
!src/**/build/
**/bin

### VSCode ###
.vscode/*
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ Issues with each workaround are listed in the plugin's config. **Please take you

## Fixes:
- Bamboo and dripstone collision (by setting them to no server-side collision)
- Allow Geyser players to ride pigs and striders (by implementing the control server-side.) (Doesn't work on 1.20+)
Fixes https://github.com/GeyserMC/Geyser/issues/638

## Supported Versions:
- 1.14.x - 1.21 for bamboo and dripstone collision fixes
- 1.17.x - 1.19.x for pig/strider riding
Supported Versions:
- 1.14.x - 1.21.1
13 changes: 13 additions & 0 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
plugins {
`kotlin-dsl`
}

repositories {
gradlePluginPortal()
}

dependencies {
implementation(libs.shadow)
implementation(libs.paperweight)
implementation(libs.javadowngrader)
}
12 changes: 12 additions & 0 deletions build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
dependencyResolutionManagement {
repositories {
gradlePluginPortal()
}
versionCatalogs {
register("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}

rootProject.name = "build-logic"
15 changes: 15 additions & 0 deletions build-logic/src/main/kotlin/extensions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.api.Project
import org.gradle.kotlin.dsl.named

fun Project.relocate(pattern: String) {
tasks.named<ShadowJar>("shadowJar") {
relocate(pattern, "org.geysermc.hurricane.relocations.$pattern")
}
}

fun Project.exclude(group: String) {
tasks.named<ShadowJar>("shadowJar") {
exclude(group)
}
}
37 changes: 37 additions & 0 deletions build-logic/src/main/kotlin/hurricane.java-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
plugins {
`java-library`
`maven-publish`
}

repositories {
//mavenLocal()
maven("https://papermc.io/repo/repository/maven-public/")
maven("https://oss.sonatype.org/content/groups/public/")
maven("https://repo.opencollab.dev/maven-releases/")
maven("https://repo.opencollab.dev/maven-snapshots/")
maven("https://repo.maven.apache.org/maven2/")
}

group = properties["group"] as String
version = properties["version"] as String
java.sourceCompatibility = JavaVersion.VERSION_17

publishing {
publications.create<MavenPublication>("maven") {
from(components["java"])
}
}

tasks.withType<JavaCompile>() {
options.encoding = "UTF-8"
}

tasks {
processResources {
filesMatching(listOf("plugin.yml")) {
expand(
"version" to properties["version"]
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

plugins {
id("hurricane.java-conventions")
id("io.papermc.paperweight.userdev")
}

tasks {
assemble {
// according to paperweight-test-plugin
dependsOn(reobfJar)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
plugins {
id("hurricane.java-conventions")
id("com.gradleup.shadow")
id("xyz.wagyourtail.jvmdowngrader")
}

tasks {
jar {
archiveClassifier.set("unshaded")
archiveVersion.set("")
}

shadowJar {
archiveClassifier.set("shaded")
archiveVersion.set("")
}

downgradeJar {
mustRunAfter(shadowJar)
inputFile.set(shadowJar.get().archiveFile)
archiveClassifier.set("")
archiveVersion.set("")
}

build {
dependsOn(shadowJar)
dependsOn(downgradeJar)
}
}

jvmdg {
downgradeTo = JavaVersion.VERSION_1_8
}
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
group=org.geysermc.hurricane
version=2.1-SNAPSHOT
27 changes: 27 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[versions]
configurate ="4.2.0-SNAPSHOT"
geyser ="2.4.2-SNAPSHOT"
floodgate ="2.2.3-SNAPSHOT"
paper ="1.18.2-R0.1-SNAPSHOT"
paperweight = "1.5.5"
shadow = "8.3.0"
javadowngrader = "1.0.0"

[libraries]
configurate-hocon = { group = "org.spongepowered", name = "configurate-hocon", version.ref = "configurate" }
floodgate-api = { group = "org.geysermc.floodgate", name = "api", version.ref = "floodgate" }
geyser-api = { group = "org.geysermc.geyser", name = "api", version.ref = "geyser" }
paper-api = { group = "io.papermc.paper", name = "paper-api", version.ref = "paper" }
paperweight = { group = "io.papermc.paperweight", name = "paperweight-userdev", version.ref = "paperweight" }
shadow = { group = "com.gradleup.shadow", name = "shadow-gradle-plugin", version.ref = "shadow" }
javadowngrader = { group = "xyz.wagyourtail.jvmdowngrader", name = "gradle-plugin", version.ref = "javadowngrader" }

[bundles]
geyser = [
"floodgate-api",
"geyser-api"
]

[plugins]
shadow = { id = "com.gradleup.shadow", version.ref = "shadow" }
paperweight = { id = "io.papermc.paperweight.userdev", version.ref = "paperweight" }
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit bde84b0

Please sign in to comment.