From 9eb69a4ecc1128b1d1e665a077ed70789a193783 Mon Sep 17 00:00:00 2001 From: ZhangYuheng Date: Mon, 7 Oct 2024 16:09:10 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B2=BE=E7=AE=80=E9=A1=B9=E7=9B=AE=E7=BB=93?= =?UTF-8?q?=E6=9E=84=EF=BC=8C=E6=8F=90=E4=BE=9B=E4=B8=A4=E7=A7=8D=E4=B8=8D?= =?UTF-8?q?=E5=90=8C=E4=B8=8B=E8=BD=BD=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/build.yml | 7 +++---- .github/workflows/main.yml | 10 ++++----- BuildScript.sh | 26 +++++++++++++++++++++++ build.gradle.kts | 33 ++++++++++++++++++++++++------ core/src/main/resources/plugin.yml | 3 ++- 5 files changed, 62 insertions(+), 17 deletions(-) create mode 100644 BuildScript.sh diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index dcec1a4..ab8989b 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -21,9 +21,8 @@ jobs: cache: gradle - name: "Build with Gradle" run: | - ./gradlew buildPlugin - - name: "Copy jar to staging" - run: mkdir staging && cp build/libs/*.jar staging/ + chmod +x ./BuildScript.sh + ./BuildScript.sh all - name: "Build & test" run: | echo "done!" @@ -36,7 +35,7 @@ jobs: - name: "Release" uses: https://ssl.lunadeer.cn:14446/zhangyuheng/release-action@main with: - note: " - 带 `original-` 前缀的文件无法用于运行,请下载不带此前缀的版本。" + note: " - `full` 后缀包含所有依赖直接安装即可使用,`lite` 后缀不包含任何依赖,会在第一次安装后启动时自动下载" files: |- staging/*.jar api_key: '${{secrets.RELEASE_TOKEN}}' \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7e4d34a..6ce5f81 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,10 +19,9 @@ jobs: distribution: 'zulu' cache: gradle - name: "Build with Gradle" - run: ./gradlew buildPlugin - - name: "Copy jar to staging" run: | - mkdir staging && cp build/libs/*.jar staging/ + chmod +x ./BuildScript.sh + ./BuildScript.sh all - name: "Build & test" run: | 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 version_number: ${{ env.AUTOMATIC_RELEASES_TAG }} files: | - staging/*.jar + staging/*-lite.jar changelog: "See https://github.com/ColdeZhang/Dominion/releases/tag/${{ env.AUTOMATIC_RELEASES_TAG }}" version_type: beta featured: false @@ -55,5 +54,4 @@ jobs: - name: "Hangar Release" env: HANGAR_TOKEN: ${{ secrets.HANGAR_API_TOKEN }} - run: ./gradlew build publishPluginPublicationToHangar --stacktrace - continue-on-error: true + run: ./gradlew build publishPluginPublicationToHangar -PBuildFull=false diff --git a/BuildScript.sh b/BuildScript.sh new file mode 100644 index 0000000..f49c523 --- /dev/null +++ b/BuildScript.sh @@ -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/ diff --git a/build.gradle.kts b/build.gradle.kts index 7aa24d1..650533a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,8 +6,12 @@ plugins { id("io.papermc.hangar-publish-plugin") version "0.1.2" } +var BuildFull = properties["BuildFull"].toString() == "true" +var libraries = listOf() +libraries = libraries + "cn.lunadeer:MinecraftPluginUtils:1.3.10" + group = "cn.lunadeer" -version = "2.10.2-beta" +version = "2.11.0-beta" java { toolchain.languageVersion.set(JavaLanguageVersion.of(21)) @@ -29,7 +33,6 @@ allprojects { maven("https://repo.papermc.io/repository/maven-public/") maven("https://jitpack.io") maven("https://repo.mikeprimm.com/") - maven("https://ssl.lunadeer.cn:14454/repository/maven-snapshots/") maven("https://repo.extendedclip.com/content/repositories/placeholderapi/") } @@ -38,8 +41,15 @@ allprojects { compileOnly("us.dynmap:DynmapCoreAPI:3.4") compileOnly("me.clip:placeholderapi:2.11.6") - implementation("cn.lunadeer:MinecraftPluginUtils:1.3.10-SNAPSHOT") - implementation("org.yaml:snakeyaml:2.0") + if (!BuildFull) { + libraries.forEach { + compileOnly(it) + } + } else { + libraries.forEach { + implementation(it) + } + } } tasks.processResources { @@ -53,6 +63,15 @@ allprojects { filter { 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("") archiveVersion.set(project.version.toString()) dependsOn(tasks.withType()) + // 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()) } -tasks.register("buildPlugin") { // <<<< RUN THIS TASK TO BUILD PLUGIN +tasks.register("Clean&Build") { // <<<< RUN THIS TASK TO BUILD PLUGIN dependsOn(tasks.clean) dependsOn(tasks.shadowJar) } @@ -98,5 +119,5 @@ hangarPublish { } tasks.named("publishPluginPublicationToHangar") { - dependsOn(tasks.named("jar")) + dependsOn(tasks.named("Clean&Build")) } \ No newline at end of file diff --git a/core/src/main/resources/plugin.yml b/core/src/main/resources/plugin.yml index 6038dea..961426c 100644 --- a/core/src/main/resources/plugin.yml +++ b/core/src/main/resources/plugin.yml @@ -3,6 +3,7 @@ version: @version@ main: cn.lunadeer.dominion.Dominion api-version: '1.20' folia-supported: true +libraries: [ ] softdepend: - Vault - dynmap @@ -18,4 +19,4 @@ permissions: default: op dominion.default: description: 领地插件用户权限 - default: true + default: true \ No newline at end of file