133 lines
4.6 KiB
Groovy
133 lines
4.6 KiB
Groovy
import io.papermc.paperweight.userdev.ReobfArtifactConfiguration
|
|
|
|
import java.nio.file.Files
|
|
|
|
/*
|
|
* PICKSHADOW SERVER KIT SOURCE FILE
|
|
* Copyright (c) 2024 The PickShadow Server Kit authors
|
|
* Licensed under the GNU Affero General Public License v3
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
* License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
// Plugins
|
|
plugins {
|
|
id("java")
|
|
id("io.freefair.lombok") version("${pluginLombok}")
|
|
id("io.papermc.paperweight.userdev") version("${pluginPaperweight}")
|
|
id("io.github.goooler.shadow") version("${pluginShadow}")
|
|
id("com.gorylenko.gradle-git-properties") version("${pluginGitProperties}")
|
|
id("xyz.jpenilla.run-paper") version("${pluginRunTask}")
|
|
}
|
|
|
|
// Dependencies
|
|
dependencies {
|
|
// Lombok
|
|
compileOnly("org.projectlombok:lombok:${dependencyLombok}")
|
|
annotationProcessor("org.projectlombok:lombok:${dependencyLombok}")
|
|
|
|
// JetBrains Annotations
|
|
compileOnly("org.jetbrains:annotations:${dependencyJetbrainsAnnotations}")
|
|
|
|
// Libraries
|
|
compileOnly("de.staropensource.sosengine:base:${dependencyStarOpenSourceEngine}")
|
|
implementation("com.google.code.gson:gson:${dependencyGson}")
|
|
|
|
// Server
|
|
compileOnly("io.papermc.paper:paper-api:${minecraftVersion}-${dependencyPaper}-SNAPSHOT")
|
|
compileOnly("net.kyori:adventure-api:${dependencyAdventure}")
|
|
paperweight.paperDevBundle("${minecraftVersion}-${dependencyPaper}-SNAPSHOT")
|
|
|
|
// Plugins
|
|
compileOnly("net.luckperms:api:${dependencyLuckPerms}")
|
|
}
|
|
|
|
// Set Java version
|
|
java {
|
|
toolchain.languageVersion.set(JavaLanguageVersion.of("${javaTarget}"))
|
|
}
|
|
|
|
// Update plugin.yml
|
|
processResources {
|
|
filesMatching("plugin.yml") {
|
|
expand project.properties
|
|
}
|
|
}
|
|
|
|
// Git properties configuration
|
|
// Allows us to embed git commit information in the plugin build
|
|
gitProperties {
|
|
dotGitDirectory = file("${rootProject.rootDir}/.git")
|
|
failOnNoGitDirectory = false // Allow continuing if .git directory is missing for the few who use tarballs
|
|
extProperty = "gitProps"
|
|
|
|
dateFormat = "yyyy-MM-dd'T'HH:mmZ"
|
|
dateFormatTimeZone = "UTC"
|
|
}
|
|
|
|
tasks.register("writeGitProperties") { // This task's only purpose is to copy the git.properties from our git properties plugin to the resources directory so it's included in the final build
|
|
doLast {
|
|
File target = file("${project.projectDir}/src/main/resources/psse-git.properties")
|
|
File source = file("${project.projectDir}/build/resources/main/git.properties")
|
|
|
|
target.delete()
|
|
source.renameTo(target)
|
|
}
|
|
|
|
outputs.upToDateWhen({ false }) // Force task execution
|
|
}
|
|
generateGitProperties.outputs.upToDateWhen({ false }) // Force task execution
|
|
processResources.dependsOn(writeGitProperties) // Ensure git.properties file is present
|
|
|
|
// Copy gradle.properties file for inclusion in final build
|
|
tasks.register("copyGradleProperties") {
|
|
doFirst {
|
|
File target = file("${project.projectDir}/src/main/resources/psse-gradle.properties")
|
|
File source = file(project(":").projectDir.getPath() + "/gradle.properties")
|
|
target.delete()
|
|
Files.copy(source.toPath(), target.toPath())
|
|
}
|
|
|
|
outputs.upToDateWhen({ false }) // Force task execution
|
|
}
|
|
processResources.dependsOn(copyGradleProperties)
|
|
|
|
// Configure paperweight
|
|
paperweight {
|
|
reobfArtifactConfiguration = ReobfArtifactConfiguration.getMOJANG_PRODUCTION()
|
|
}
|
|
|
|
// Configure server
|
|
runServer {
|
|
minecraftVersion("${minecraftVersion}")
|
|
systemProperty("file.encoding", "UTF-8")
|
|
systemProperty("com.mojang.eula.agree", "true")
|
|
systemProperty("sosengine.base.loggerLevel", "diagnostic")
|
|
|
|
downloadPlugins {
|
|
modrinth("freedomchat", "${downloadFreedomChat}")
|
|
url("${downloadEngineMC}")
|
|
url("${downloadLuckPerms}")
|
|
}
|
|
|
|
doFirst {
|
|
// Disable bStats
|
|
File config = new File(runDirectory.get().getAsFile().getPath() + "/plugins/bStats/config.yml")
|
|
if (!config.exists()) {
|
|
config.getParentFile().mkdirs()
|
|
config.createNewFile()
|
|
config.write("enabled: false\n")
|
|
}
|
|
}
|
|
}
|