Enhance build configuration and dependencies for Hytale plugin to use HytaleServer.jar from official maven repository. Added permissions in workflows to allow github action to create new releases.
This commit is contained in:
88
.github/workflows/build.yml
vendored
88
.github/workflows/build.yml
vendored
@@ -1,8 +1,12 @@
|
|||||||
name: Build Plugin
|
name: Build Plugin
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ main, develop ]
|
branches: [ main, develop ]
|
||||||
|
tags: [ 'v*' ]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ main ]
|
branches: [ main ]
|
||||||
|
|
||||||
@@ -11,37 +15,37 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Java 25
|
- name: Setup Java 25
|
||||||
uses: actions/setup-java@v4
|
uses: actions/setup-java@v4
|
||||||
with:
|
with:
|
||||||
java-version: '25'
|
java-version: '25'
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
|
|
||||||
- name: Cache Gradle Dependencies
|
- name: Cache Gradle Dependencies
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: ~/.gradle
|
path: ~/.gradle
|
||||||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-gradle-
|
${{ runner.os }}-gradle-
|
||||||
|
|
||||||
- name: Grant Execute Permission for Gradlew
|
- name: Grant Execute Permission for Gradlew
|
||||||
run: chmod +x gradlew
|
run: chmod +x gradlew
|
||||||
|
|
||||||
- name: Build with Gradle
|
- name: Build with Gradle
|
||||||
run: ./gradlew shadowJar
|
run: ./gradlew shadowJar
|
||||||
|
|
||||||
- name: Run Tests
|
- name: Run Tests
|
||||||
run: ./gradlew test
|
run: ./gradlew test
|
||||||
|
|
||||||
- name: Upload Artifact
|
- name: Upload Artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: plugin-jar
|
name: plugin-jar
|
||||||
path: build/libs/*.jar
|
path: build/libs/*.jar
|
||||||
|
|
||||||
release:
|
release:
|
||||||
needs: build
|
needs: build
|
||||||
@@ -49,24 +53,24 @@ jobs:
|
|||||||
if: startsWith(github.ref, 'refs/tags/v')
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Java 25
|
- name: Setup Java 25
|
||||||
uses: actions/setup-java@v4
|
uses: actions/setup-java@v4
|
||||||
with:
|
with:
|
||||||
java-version: '25'
|
java-version: '25'
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
|
|
||||||
- name: Grant Execute Permission for Gradlew
|
- name: Grant Execute Permission for Gradlew
|
||||||
run: chmod +x gradlew
|
run: chmod +x gradlew
|
||||||
|
|
||||||
- name: Build with Gradle
|
- name: Build with Gradle
|
||||||
run: ./gradlew shadowJar
|
run: ./gradlew shadowJar
|
||||||
|
|
||||||
- name: Create Release
|
- name: Create Release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
files: build/libs/*.jar
|
files: build/libs/*.jar
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|||||||
147
build.gradle
147
build.gradle
@@ -1,6 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'java'
|
id 'java'
|
||||||
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.3'
|
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.3'
|
||||||
|
id 'com.gradleup.shadow' version '9.3.1'
|
||||||
}
|
}
|
||||||
|
|
||||||
import org.gradle.internal.os.OperatingSystem
|
import org.gradle.internal.os.OperatingSystem
|
||||||
@@ -26,11 +27,10 @@ ext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!project.hasProperty('hytaleHome')) {
|
def hytaleHomePath = project.findProperty('hytaleHome')
|
||||||
throw new GradleException('Your Hytale install could not be detected automatically. If you are on an unsupported platform or using a custom install location, please define the install location using the hytale_home property.');
|
def hasHytaleHome = hytaleHomePath && file(hytaleHomePath).exists()
|
||||||
}
|
if (!hasHytaleHome) {
|
||||||
else if (!file(project.findProperty('hytaleHome')).exists()) {
|
logger.lifecycle("Hytale install not detected; run configs that launch the server will be skipped. Set -Phytale_home=/path/to/Hytale to enable them.")
|
||||||
throw new GradleException("Failed to find Hytale at the expected location. Please make sure you have installed the game. The expected location can be changed using the hytale_home property. Currently looking in ${project.findProperty('hytaleHome')}")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
@@ -45,16 +45,29 @@ javadoc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Adds the Hytale server as a build dependency, allowing you to reference and
|
// Adds the Hytale server as a build dependency, allowing you to reference and
|
||||||
// compile against their code. This requires you to have Hytale installed using
|
// compile against their code without bundling it. When a local install is
|
||||||
// the official launcher for now.
|
// present, we still use its jar for launching the server in IDE run configs.
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(files("$hytaleHome/install/$patchline/package/game/latest/Server/HytaleServer.jar"))
|
compileOnly("com.hypixel.hytale:Server:$hytale_build")
|
||||||
|
if (hasHytaleHome) {
|
||||||
|
runtimeOnly(files("$hytaleHome/install/$patchline/package/game/latest/Server/HytaleServer.jar"))
|
||||||
|
}
|
||||||
|
implementation('org.xerial:sqlite-jdbc:3.51.1.0')
|
||||||
|
implementation('com.j256.ormlite:ormlite-jdbc:6.1')
|
||||||
|
implementation('org.postgresql:postgresql:42.7.3')
|
||||||
|
implementation('com.mysql:mysql-connector-j:9.1.0')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the working directory to run the server if it does not already exist.
|
repositories {
|
||||||
def serverRunDir = file("$projectDir/run")
|
mavenCentral()
|
||||||
if (!serverRunDir.exists()) {
|
maven {
|
||||||
serverRunDir.mkdirs()
|
name = "hytale-release"
|
||||||
|
url = uri("https://maven.hytale.com/release")
|
||||||
|
}
|
||||||
|
maven {
|
||||||
|
name = "hytale-pre-release"
|
||||||
|
url = uri("https://maven.hytale.com/pre-release")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Updates the manifest.json file with the latest properties defined in the
|
// Updates the manifest.json file with the latest properties defined in the
|
||||||
@@ -78,54 +91,78 @@ tasks.named('processResources') {
|
|||||||
dependsOn 'updatePluginManifest'
|
dependsOn 'updatePluginManifest'
|
||||||
}
|
}
|
||||||
|
|
||||||
def createServerRunArguments(String srcDir) {
|
tasks.named('shadowJar') {
|
||||||
def programParameters = '--allow-op --disable-sentry --assets="' + "${hytaleHome}/install/$patchline/package/game/latest/Assets.zip" + '"'
|
archiveClassifier.set('')
|
||||||
def modPaths = []
|
mergeServiceFiles()
|
||||||
if (includes_pack.toBoolean()) {
|
|
||||||
modPaths << srcDir
|
|
||||||
}
|
|
||||||
if (load_user_mods.toBoolean()) {
|
|
||||||
modPaths << "${hytaleHome}/UserData/Mods"
|
|
||||||
}
|
|
||||||
if (!modPaths.isEmpty()) {
|
|
||||||
programParameters += ' --mods="' + modPaths.join(',') + '"'
|
|
||||||
}
|
|
||||||
return programParameters
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates a run configuration in IDEA that will run the Hytale server with
|
// Ensure the shaded jar is produced during a normal build.
|
||||||
// your plugin and the default assets.
|
tasks.named('build') {
|
||||||
idea.project.settings.runConfigurations {
|
dependsOn 'shadowJar'
|
||||||
'HytaleServer'(org.jetbrains.gradle.ext.Application) {
|
|
||||||
mainClass = 'com.hypixel.hytale.Main'
|
|
||||||
moduleName = project.idea.module.name + '.main'
|
|
||||||
programParameters = createServerRunArguments(sourceSets.main.java.srcDirs.first().parentFile.absolutePath)
|
|
||||||
workingDirectory = serverRunDir.absolutePath
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates a launch.json file for VSCode with the same configuration
|
if (hasHytaleHome) {
|
||||||
tasks.register('generateVSCodeLaunch') {
|
// Create the working directory to run the server if it does not already exist.
|
||||||
def vscodeDir = file("$projectDir/.vscode")
|
def serverRunDir = file("$projectDir/run")
|
||||||
def launchFile = file("$vscodeDir/launch.json")
|
if (!serverRunDir.exists()) {
|
||||||
doLast {
|
serverRunDir.mkdirs()
|
||||||
if (!vscodeDir.exists()) {
|
}
|
||||||
vscodeDir.mkdirs()
|
|
||||||
|
def createServerRunArguments = { String srcDir ->
|
||||||
|
def programParameters = '--allow-op --disable-sentry --assets="' + "${hytaleHome}/install/$patchline/package/game/latest/Assets.zip" + '"'
|
||||||
|
def modPaths = []
|
||||||
|
if (includes_pack.toBoolean()) {
|
||||||
|
modPaths << srcDir
|
||||||
}
|
}
|
||||||
def programParams = createServerRunArguments("\${workspaceFolder}")
|
if (load_user_mods.toBoolean()) {
|
||||||
def launchConfig = [
|
modPaths << "${hytaleHome}/UserData/Mods"
|
||||||
version: "0.2.0",
|
}
|
||||||
configurations: [
|
if (!modPaths.isEmpty()) {
|
||||||
[
|
programParameters += ' --mods="' + modPaths.join(',') + '"'
|
||||||
type: "java",
|
}
|
||||||
name: "HytaleServer",
|
return programParameters
|
||||||
request: "launch",
|
}
|
||||||
mainClass: "com.hypixel.hytale.Main",
|
|
||||||
args: programParams,
|
// Creates a run configuration in IDEA that will run the Hytale server with
|
||||||
cwd: "\${workspaceFolder}/run"
|
// your plugin and the default assets.
|
||||||
]
|
idea.project.settings.runConfigurations {
|
||||||
|
'HytaleServer'(org.jetbrains.gradle.ext.Application) {
|
||||||
|
mainClass = 'com.hypixel.hytale.Main'
|
||||||
|
moduleName = project.idea.module.name + '.main'
|
||||||
|
programParameters = createServerRunArguments(sourceSets.main.java.srcDirs.first().parentFile.absolutePath)
|
||||||
|
workingDirectory = serverRunDir.absolutePath
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Creates a launch.json file for VSCode with the same configuration
|
||||||
|
tasks.register('generateVSCodeLaunch') {
|
||||||
|
def vscodeDir = file("$projectDir/.vscode")
|
||||||
|
def launchFile = file("$vscodeDir/launch.json")
|
||||||
|
doLast {
|
||||||
|
if (!vscodeDir.exists()) {
|
||||||
|
vscodeDir.mkdirs()
|
||||||
|
}
|
||||||
|
def programParams = createServerRunArguments("\${workspaceFolder}")
|
||||||
|
def launchConfig = [
|
||||||
|
version: "0.2.0",
|
||||||
|
configurations: [
|
||||||
|
[
|
||||||
|
type: "java",
|
||||||
|
name: "HytaleServer",
|
||||||
|
request: "launch",
|
||||||
|
mainClass: "com.hypixel.hytale.Main",
|
||||||
|
args: programParams,
|
||||||
|
cwd: "\${workspaceFolder}/run"
|
||||||
|
]
|
||||||
|
]
|
||||||
]
|
]
|
||||||
]
|
launchFile.text = groovy.json.JsonOutput.prettyPrint(groovy.json.JsonOutput.toJson(launchConfig))
|
||||||
launchFile.text = groovy.json.JsonOutput.prettyPrint(groovy.json.JsonOutput.toJson(launchConfig))
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tasks.register('generateVSCodeLaunch') {
|
||||||
|
doLast {
|
||||||
|
logger.lifecycle("Skipped VSCode launch configuration because hytale_home is not set or the install path is missing.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ includes_pack=true
|
|||||||
# official launcher.
|
# official launcher.
|
||||||
patchline=release
|
patchline=release
|
||||||
|
|
||||||
|
# The exact Hytale build to compile against. Use the build string from the
|
||||||
|
# launcher (format YYYY.MM.DD-<hash>) so Gradle pulls the matching server jar
|
||||||
|
# for your selected patchline.
|
||||||
|
hytale_build=2026.01.27-734d39026
|
||||||
|
|
||||||
# Determines if the development server should also load mods from the user's
|
# Determines if the development server should also load mods from the user's
|
||||||
# standard mods folder. This lets you test mods by installing them where a
|
# standard mods folder. This lets you test mods by installing them where a
|
||||||
# normal player would, instead of adding them as dependencies or adding them
|
# normal player would, instead of adding them as dependencies or adding them
|
||||||
|
|||||||
Reference in New Issue
Block a user