Advanced-Portals/build.gradle

200 lines
6.0 KiB
Groovy
Raw Permalink Normal View History

import java.nio.file.Files
import java.nio.file.Paths
import java.nio.file.StandardCopyOption
import java.nio.file.StandardOpenOption
2022-05-04 02:17:54 +02:00
buildscript {
repositories {
maven {url "https://plugins.gradle.org/m2/"}
mavenCentral()
}
dependencies {
classpath "org.apache.httpcomponents:httpmime:4.5.13"
classpath "com.google.code.gson:gson:2.8.6"
classpath "org.apache.httpcomponents:httpclient:4.5.13"
}
}
plugins {
id 'dev.s7a.gradle.minecraft.server' version '1.1.0'
2024-11-13 12:02:01 +01:00
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.1.7'
2022-05-04 02:17:54 +02:00
}
allprojects {
apply plugin: 'java'
2024-11-13 12:02:01 +01:00
apply plugin: 'idea'
tasks.withType(JavaCompile).configureEach {
2021-05-25 02:32:22 +02:00
options.encoding = 'UTF-8'
}
2023-11-22 01:25:22 +01:00
if (project.name != "Advanced-Portals") {
task buildSubmodules doLast {
task -> println "Building $task.project.name"
}
2022-04-24 04:31:39 +02:00
buildSubmodules.finalizedBy build
}
tasks.processResources {
def files = ["plugin.yml", "bungee.yml"]
filesMatching(files) {
expand(["pluginVersion": project.version])
}
}
2023-05-14 22:12:18 +02:00
sourceCompatibility = JavaVersion.VERSION_16
targetCompatibility = JavaVersion.VERSION_16
}
apply from: 'env-variables.gradle'
println("Branch ${ext.branch}${ext.shaRef} isRelease: '${ext.isRelease}'")
println("Snapshot Name: ${ext.snapshotName}")
println("Github SHA: ${ext.githubSha}")
println("Sha Ref: ${ext.shaRef}")
archivesBaseName = "Advanced-Portals"
group = 'com.sekwah.advancedportals'
2024-11-18 06:11:27 +01:00
def versionString = (file('./version.txt').text + (isRelease ? "" : "-${snapshotName}${shaRef}")).replaceAll('\n', '').replaceAll('\r', '')
setVersion(versionString)
println "Version: ${getVersion()}"
2018-07-23 02:43:29 +02:00
description = ""
configurations {
// configuration that holds jars to copy into lib
2022-04-24 04:34:45 +02:00
implementation.extendsFrom(includeLibs)
2018-07-23 02:43:29 +02:00
}
repositories {
maven { url "https://repo.maven.apache.org/maven2" }
2018-07-23 02:43:29 +02:00
maven { url "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
2020-12-30 03:49:45 +01:00
maven { url "https://nexus.velocitypowered.com/repository/maven-public/" }
}
2018-07-23 02:43:29 +02:00
// includeLibs just says to include the library in the final jar
dependencies {
2024-11-18 06:11:27 +01:00
includeLibs project(':lang')
includeLibs project(':core')
includeLibs project(':bungee')
includeLibs project(':spigot')
includeLibs project(':velocity')
2018-07-23 02:43:29 +02:00
}
2024-11-18 06:11:27 +01:00
apply from: 'env-variables.gradle'
2024-11-18 06:11:27 +01:00
println "Branch ${ext.branch}${ext.shaRef} isRelease: '${ext.isRelease}'"
tasks.named('jar') {
dependsOn(':core:shadowJar')
}
2024-11-18 06:11:27 +01:00
jar {
// Filters the files out that are in the build folders. Look to see if there is a better way to do this?
from configurations.includeLibs.filter {
it.path.contains("${File.separator}build${File.separator}libs")
} .collect {
println("Will Include: ${it.name}")
it.isDirectory() ? it : zipTree(it)
}
2022-05-04 02:17:54 +02:00
}
2023-12-03 15:19:57 +01:00
// This is used to download my plugin for helping reload the server in tandem with the copyPlugin task
tasks.register('downloadSekCDevToolsPlugin') {
doLast {
// Define the URL and destination path
def url = 'https://github.com/sekwah41/SekCDevToolsPlugin/releases/download/v1.0.0/SekCDevToolsPlugin-1.0-SNAPSHOT.jar'
def destinationDir = new File("$buildDir/MinecraftServer/plugins")
def destinationFile = new File(destinationDir, 'SekCDevToolsPlugin-1.0-SNAPSHOT.jar')
// Create the directory if it doesn't exist
if (!destinationDir.exists()) {
destinationDir.mkdirs()
}
// Download the file if it doesn't exist
if (!destinationFile.exists()) {
println "Downloading SekCDevToolsPlugin..."
new URL(url).withInputStream { i ->
destinationFile.withOutputStream {
it << i
}
}
} else {
println "SekCDevToolsPlugin already downloaded"
}
}
}
tasks.launchMinecraftServer.dependsOn(downloadSekCDevToolsPlugin)
2022-05-04 02:17:54 +02:00
minecraftServerConfig {
jarUrl.set('https://download.getbukkit.org/spigot/spigot-1.20.2.jar')
2022-05-04 02:17:54 +02:00
jvmArgument = ["-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005", "-DIReallyKnowWhatIAmDoingISwear=true"]
}
tasks.withType(Jar).configureEach {
2023-04-06 19:41:18 +02:00
duplicatesStrategy = DuplicatesStrategy.WARN
}
2022-05-04 02:17:54 +02:00
2023-12-03 15:19:57 +01:00
/**
* Will build then copy it to the minecraft server folder for use with the launch task and dev tools plugin
*/
tasks.register('copyPlugin') {
2023-12-03 15:19:57 +01:00
dependsOn(build)
2022-05-04 02:17:54 +02:00
doLast {
copy {
def sourceFilePath = Paths.get("$buildDir/libs/Advanced-Portals-${getVersion()}.jar")
def destinationFilePath = Paths.get("$buildDir/MinecraftServer/plugins/Advanced-Portals.jar")
println "Handling file: $destinationFilePath"
byte[] newContent = Files.readAllBytes(sourceFilePath)
if (Files.exists(destinationFilePath)) {
println "File exists. Overwriting with new binary content."
Files.write(destinationFilePath, newContent, StandardOpenOption.TRUNCATE_EXISTING)
} else {
println "File does not exist. Copying from source."
Files.copy(sourceFilePath, destinationFilePath, StandardCopyOption.REPLACE_EXISTING)
2022-05-04 02:17:54 +02:00
}
}
}
}
2018-07-23 02:43:29 +02:00
// Set SPIGOT_LOC to the location of your server and SPIGOT_JAR as the name of the jar file in the server you want to run
// DIReallyKnowWhatIAmDoingISwear is to remove the stupid pause spigot has at the start
2024-11-18 06:11:27 +01:00
tasks.register('runJar') {
2018-07-23 02:43:29 +02:00
doLast {
javaexec {
main "-jar"
args "${System.env.MC_SERVER_LOC}\\${System.env.MC_SERVER_JAR}.jar"
2018-08-27 22:43:02 +02:00
jvmArgs = ["-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005", "-DIReallyKnowWhatIAmDoingISwear=true"]
2018-07-23 02:43:29 +02:00
workingDir "${System.env.MC_SERVER_LOC}"
}
}
}
2018-06-04 12:54:52 +02:00
2024-11-18 06:11:27 +01:00
idea {
project {
settings {
taskTriggers {
afterSync(project(':core').tasks.named('generateTemplates'))
}
}
2018-06-04 05:47:35 +02:00
}
2018-06-07 00:00:58 +02:00
}
apply from: 'curse.gradle'
apply from: 'discord.gradle'