更新项目配置和新增功能
This commit is contained in:
229
build.gradle
Normal file
229
build.gradle
Normal file
@@ -0,0 +1,229 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'io.papermc.paperweight.userdev' version '2.0.0-beta.21'
|
||||
id 'com.gradleup.shadow' version '8.3.6'
|
||||
}
|
||||
|
||||
group = 'cn.infstar'
|
||||
version = '1.3.0'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = 'papermc'
|
||||
url = uri('https://repo.papermc.io/repository/maven-public/')
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
paperweight.paperDevBundle('1.21.11-R0.1-SNAPSHOT')
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
|
||||
def excludedModules = project.hasProperty('excludeModules') ?
|
||||
project.property('excludeModules').split(',')*.trim() : []
|
||||
|
||||
def includeBlocks = !excludedModules.contains('blocks')
|
||||
def includePlayer = !excludedModules.contains('player')
|
||||
def includeJeiFix = !excludedModules.contains('jei-fix')
|
||||
def includeMobDrops = !excludedModules.contains('mob-drops')
|
||||
|
||||
println "\n📦 EssentialsC 模块配置:"
|
||||
println " ✅ Core (核心)"
|
||||
println " ${includeBlocks ? '✅' : '❌'} Blocks (便捷方块)"
|
||||
println " ${includePlayer ? '✅' : '❌'} Player (玩家管理)"
|
||||
println " ${includeJeiFix ? '✅' : '❌'} JEI Fix (JEI 修复)"
|
||||
println " ${includeMobDrops ? '✅' : '❌'} Mob Drops (生物掉落物)"
|
||||
println ""
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
if (!includeBlocks) {
|
||||
exclude '**/commands/WorkbenchCommand.java'
|
||||
exclude '**/commands/AnvilCommand.java'
|
||||
exclude '**/commands/CartographyTableCommand.java'
|
||||
exclude '**/commands/GrindstoneCommand.java'
|
||||
exclude '**/commands/LoomCommand.java'
|
||||
exclude '**/commands/SmithingTableCommand.java'
|
||||
exclude '**/commands/StonecutterCommand.java'
|
||||
exclude '**/commands/EnderChestCommand.java'
|
||||
exclude '**/commands/BlocksMenuCommand.java'
|
||||
exclude '**/listeners/ShulkerBoxListener.java'
|
||||
}
|
||||
|
||||
if (!includePlayer) {
|
||||
exclude '**/commands/FlyCommand.java'
|
||||
exclude '**/commands/HealCommand.java'
|
||||
exclude '**/commands/FeedCommand.java'
|
||||
exclude '**/commands/VanishCommand.java'
|
||||
exclude '**/commands/SeenCommand.java'
|
||||
exclude '**/commands/HatCommand.java'
|
||||
exclude '**/commands/SuicideCommand.java'
|
||||
exclude '**/commands/RepairCommand.java'
|
||||
}
|
||||
|
||||
if (!includeJeiFix) {
|
||||
exclude '**/listeners/JeiRecipeSyncListener.java'
|
||||
}
|
||||
|
||||
if (!includeMobDrops) {
|
||||
exclude '**/listeners/MobDropListener.java'
|
||||
exclude '**/listeners/MobDropMenuListener.java'
|
||||
exclude '**/commands/MobDropCommand.java'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
options.encoding = 'UTF-8'
|
||||
}
|
||||
|
||||
processResources {
|
||||
filteringCharset = 'UTF-8'
|
||||
inputs.property('version', project.version)
|
||||
filesMatching('paper-plugin.yml') {
|
||||
expand('version': project.version)
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
enabled = false
|
||||
}
|
||||
|
||||
// ========== 多版本构建任务 ==========
|
||||
|
||||
task shadowJarStandard(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
|
||||
from sourceSets.main.output
|
||||
configurations = [project.configurations.runtimeClasspath]
|
||||
|
||||
exclude '**/listeners/MobDropListener.class'
|
||||
exclude '**/listeners/MobDropMenuListener.class'
|
||||
exclude '**/commands/MobDropCommand.class'
|
||||
|
||||
archiveFileName.set("EssentialsC-${project.version}.jar")
|
||||
}
|
||||
|
||||
task shadowJarAll(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
|
||||
from sourceSets.main.output
|
||||
configurations = [project.configurations.runtimeClasspath]
|
||||
|
||||
archiveFileName.set("EssentialsC-all-${project.version}.jar")
|
||||
}
|
||||
|
||||
task shadowJarLite(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
|
||||
from sourceSets.main.output
|
||||
configurations = [project.configurations.runtimeClasspath]
|
||||
|
||||
exclude '**/commands/WorkbenchCommand.class'
|
||||
exclude '**/commands/AnvilCommand.class'
|
||||
exclude '**/commands/CartographyTableCommand.class'
|
||||
exclude '**/commands/GrindstoneCommand.class'
|
||||
exclude '**/commands/LoomCommand.class'
|
||||
exclude '**/commands/SmithingTableCommand.class'
|
||||
exclude '**/commands/StonecutterCommand.class'
|
||||
exclude '**/commands/EnderChestCommand.class'
|
||||
exclude '**/commands/BlocksMenuCommand.class'
|
||||
exclude '**/listeners/ShulkerBoxListener.class'
|
||||
|
||||
archiveFileName.set("EssentialsC-lite-${project.version}.jar")
|
||||
}
|
||||
|
||||
build {
|
||||
dependsOn shadowJarAll
|
||||
}
|
||||
|
||||
// ========== 部署任务 ==========
|
||||
|
||||
task deployToPaper12111(type: Copy) {
|
||||
group = 'deployment'
|
||||
description = '部署到 Paper 1.21.11 测试服务器(仅完整版)'
|
||||
dependsOn shadowJarAll
|
||||
from shadowJarAll
|
||||
into "${projectDir}/test-server/paper-1.21.11/plugins"
|
||||
doLast {
|
||||
println "✅ 插件已部署到 Paper 1.21.11: ${projectDir}/test-server/paper-1.21.11/plugins"
|
||||
}
|
||||
}
|
||||
|
||||
task deployToPaper26 {
|
||||
group = 'deployment'
|
||||
description = '部署到 Paper 26.1.2 测试服务器(仅完整版)'
|
||||
dependsOn shadowJarAll
|
||||
|
||||
doFirst {
|
||||
def pluginsDir = file("${projectDir}/test-server/paper-26.1.2/plugins")
|
||||
if (pluginsDir.exists()) {
|
||||
// 删除所有 EssentialsC 相关的 JAR 文件
|
||||
fileTree(pluginsDir).include('EssentialsC*.jar').each { file ->
|
||||
println "🗑️ 删除旧插件: ${file.name}"
|
||||
file.delete()
|
||||
}
|
||||
// 删除配置文件夹
|
||||
def configDir = file("${pluginsDir}/EssentialsC")
|
||||
if (configDir.exists()) {
|
||||
println "🗑️ 删除旧配置文件夹"
|
||||
configDir.deleteDir()
|
||||
}
|
||||
println "✅ 清理完成"
|
||||
} else {
|
||||
println "⚠️ plugins 目录不存在,跳过清理"
|
||||
}
|
||||
}
|
||||
|
||||
doLast {
|
||||
copy {
|
||||
from shadowJarAll.archiveFile
|
||||
into "${projectDir}/test-server/paper-26.1.2/plugins"
|
||||
}
|
||||
println "✅ 插件已部署到 Paper 26.1.2: ${projectDir}/test-server/paper-26.1.2/plugins"
|
||||
}
|
||||
}
|
||||
|
||||
// Paper 26.1.2 一键构建和部署任务
|
||||
task buildAndDeployToPaper26 {
|
||||
group = 'deployment'
|
||||
description = '一键构建并部署到 Paper 26.1.2'
|
||||
dependsOn clean, deployToPaper26
|
||||
}
|
||||
|
||||
// 默认部署到 Paper 1.21.11
|
||||
task deployToTestServer {
|
||||
dependsOn deployToPaper12111
|
||||
}
|
||||
|
||||
build.finalizedBy deployToTestServer
|
||||
|
||||
task buildAllVersions {
|
||||
group = 'build'
|
||||
description = '构建所有版本的插件'
|
||||
dependsOn shadowJarStandard, shadowJarAll, shadowJarLite
|
||||
|
||||
doLast {
|
||||
println "\n🎉 所有版本构建完成!"
|
||||
println "📦 标准版: EssentialsC-${project.version}.jar"
|
||||
println "📦 完整版: EssentialsC-all-${project.version}.jar"
|
||||
println "📦 轻量版: EssentialsC-lite-${project.version}.jar"
|
||||
println "📁 输出目录: ${buildDir}/libs/"
|
||||
|
||||
def standardFile = file("${buildDir}/libs/EssentialsC-${project.version}.jar")
|
||||
def allFile = file("${buildDir}/libs/EssentialsC-all-${project.version}.jar")
|
||||
def liteFile = file("${buildDir}/libs/EssentialsC-lite-${project.version}.jar")
|
||||
|
||||
if (!standardFile.exists()) {
|
||||
throw new GradleException("❌ 标准版文件不存在!")
|
||||
}
|
||||
if (!allFile.exists()) {
|
||||
throw new GradleException("❌ 完整版文件不存在!")
|
||||
}
|
||||
if (!liteFile.exists()) {
|
||||
throw new GradleException("❌ 轻量版文件不存在!")
|
||||
}
|
||||
|
||||
println "✅ 所有文件验证通过!"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user