精简项目结构,提供两种不同下载版本

This commit is contained in:
ZhangYuheng 2024-10-07 16:09:10 +08:00
parent 897c6f17fd
commit 9eb69a4ecc
5 changed files with 62 additions and 17 deletions

View File

@ -21,9 +21,8 @@ jobs:
cache: gradle cache: gradle
- name: "Build with Gradle" - name: "Build with Gradle"
run: | run: |
./gradlew buildPlugin chmod +x ./BuildScript.sh
- name: "Copy jar to staging" ./BuildScript.sh all
run: mkdir staging && cp build/libs/*.jar staging/
- name: "Build & test" - name: "Build & test"
run: | run: |
echo "done!" echo "done!"
@ -36,7 +35,7 @@ jobs:
- name: "Release" - name: "Release"
uses: https://ssl.lunadeer.cn:14446/zhangyuheng/release-action@main uses: https://ssl.lunadeer.cn:14446/zhangyuheng/release-action@main
with: with:
note: " - 带 `original-` 前缀的文件无法用于运行,请下载不带此前缀的版本。" note: " - `full` 后缀包含所有依赖直接安装即可使用,`lite` 后缀不包含任何依赖,会在第一次安装后启动时自动下载"
files: |- files: |-
staging/*.jar staging/*.jar
api_key: '${{secrets.RELEASE_TOKEN}}' api_key: '${{secrets.RELEASE_TOKEN}}'

View File

@ -19,10 +19,9 @@ jobs:
distribution: 'zulu' distribution: 'zulu'
cache: gradle cache: gradle
- name: "Build with Gradle" - name: "Build with Gradle"
run: ./gradlew buildPlugin
- name: "Copy jar to staging"
run: | run: |
mkdir staging && cp build/libs/*.jar staging/ chmod +x ./BuildScript.sh
./BuildScript.sh all
- name: "Build & test" - name: "Build & test"
run: | run: |
TAG=$(echo $GITHUB_REF | sed 's/refs\/tags\///') TAG=$(echo $GITHUB_REF | sed 's/refs\/tags\///')
@ -46,7 +45,7 @@ jobs:
game_versions: 1.20.1:1.20.6,1.21,1.21.1 game_versions: 1.20.1:1.20.6,1.21,1.21.1
version_number: ${{ env.AUTOMATIC_RELEASES_TAG }} version_number: ${{ env.AUTOMATIC_RELEASES_TAG }}
files: | files: |
staging/*.jar staging/*-lite.jar
changelog: "See https://github.com/ColdeZhang/Dominion/releases/tag/${{ env.AUTOMATIC_RELEASES_TAG }}" changelog: "See https://github.com/ColdeZhang/Dominion/releases/tag/${{ env.AUTOMATIC_RELEASES_TAG }}"
version_type: beta version_type: beta
featured: false featured: false
@ -55,5 +54,4 @@ jobs:
- name: "Hangar Release" - name: "Hangar Release"
env: env:
HANGAR_TOKEN: ${{ secrets.HANGAR_API_TOKEN }} HANGAR_TOKEN: ${{ secrets.HANGAR_API_TOKEN }}
run: ./gradlew build publishPluginPublicationToHangar --stacktrace run: ./gradlew build publishPluginPublicationToHangar -PBuildFull=false
continue-on-error: true

26
BuildScript.sh Normal file
View File

@ -0,0 +1,26 @@
#!/usr/bin bash
mode=full
if [ $# -eq 1 ]; then
mode=$1
fi
./gradlew clean
# all full lite
if [ $mode == "all" ]; then
./gradlew shadowJar -PBuildFull=false
./gradlew shadowJar -PBuildFull=true
elif [ $mode == "lite" ]; then
./gradlew shadowJar -PBuildFull=false
elif [ $mode == "full" ]; then
./gradlew shadowJar -PBuildFull=true
else
echo "Invalid mode: $mode"
echo "Usage: $0 [all|full|lite]"
exit 1
fi
mkdir -p staging
mv build/libs/*.jar staging/

View File

@ -6,8 +6,12 @@ plugins {
id("io.papermc.hangar-publish-plugin") version "0.1.2" id("io.papermc.hangar-publish-plugin") version "0.1.2"
} }
var BuildFull = properties["BuildFull"].toString() == "true"
var libraries = listOf<String>()
libraries = libraries + "cn.lunadeer:MinecraftPluginUtils:1.3.10"
group = "cn.lunadeer" group = "cn.lunadeer"
version = "2.10.2-beta" version = "2.11.0-beta"
java { java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21)) toolchain.languageVersion.set(JavaLanguageVersion.of(21))
@ -29,7 +33,6 @@ allprojects {
maven("https://repo.papermc.io/repository/maven-public/") maven("https://repo.papermc.io/repository/maven-public/")
maven("https://jitpack.io") maven("https://jitpack.io")
maven("https://repo.mikeprimm.com/") maven("https://repo.mikeprimm.com/")
maven("https://ssl.lunadeer.cn:14454/repository/maven-snapshots/")
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/") maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
} }
@ -38,8 +41,15 @@ allprojects {
compileOnly("us.dynmap:DynmapCoreAPI:3.4") compileOnly("us.dynmap:DynmapCoreAPI:3.4")
compileOnly("me.clip:placeholderapi:2.11.6") compileOnly("me.clip:placeholderapi:2.11.6")
implementation("cn.lunadeer:MinecraftPluginUtils:1.3.10-SNAPSHOT") if (!BuildFull) {
implementation("org.yaml:snakeyaml:2.0") libraries.forEach {
compileOnly(it)
}
} else {
libraries.forEach {
implementation(it)
}
}
} }
tasks.processResources { tasks.processResources {
@ -53,6 +63,15 @@ allprojects {
filter { filter {
it.replace("@version@", rootProject.version.toString()) it.replace("@version@", rootProject.version.toString())
} }
if (!BuildFull) {
var libs = "libraries: ["
libraries.forEach {
libs += "$it,"
}
filter {
it.replace("libraries: []", libs.substring(0, libs.length - 1) + "]")
}
}
} }
} }
@ -60,6 +79,8 @@ allprojects {
archiveClassifier.set("") archiveClassifier.set("")
archiveVersion.set(project.version.toString()) archiveVersion.set(project.version.toString())
dependsOn(tasks.withType<ProcessResources>()) dependsOn(tasks.withType<ProcessResources>())
// add -lite to the end of the file name if BuildLite is true or -full if BuildLite is false
archiveFileName.set("${project.name}-${project.version}${if (BuildFull) "-full" else "-lite"}.jar")
} }
} }
@ -74,7 +95,7 @@ tasks.shadowJar {
archiveVersion.set(project.version.toString()) archiveVersion.set(project.version.toString())
} }
tasks.register("buildPlugin") { // <<<< RUN THIS TASK TO BUILD PLUGIN tasks.register("Clean&Build") { // <<<< RUN THIS TASK TO BUILD PLUGIN
dependsOn(tasks.clean) dependsOn(tasks.clean)
dependsOn(tasks.shadowJar) dependsOn(tasks.shadowJar)
} }
@ -98,5 +119,5 @@ hangarPublish {
} }
tasks.named("publishPluginPublicationToHangar") { tasks.named("publishPluginPublicationToHangar") {
dependsOn(tasks.named("jar")) dependsOn(tasks.named("Clean&Build"))
} }

View File

@ -3,6 +3,7 @@ version: @version@
main: cn.lunadeer.dominion.Dominion main: cn.lunadeer.dominion.Dominion
api-version: '1.20' api-version: '1.20'
folia-supported: true folia-supported: true
libraries: [ ]
softdepend: softdepend:
- Vault - Vault
- dynmap - dynmap
@ -18,4 +19,4 @@ permissions:
default: op default: op
dominion.default: dominion.default:
description: 领地插件用户权限 description: 领地插件用户权限
default: true default: true