mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-11-25 12:06:17 +01:00
187 lines
5.7 KiB
Groovy
187 lines
5.7 KiB
Groovy
import java.nio.file.Files
|
|
import java.nio.file.Paths
|
|
import java.nio.file.StandardCopyOption
|
|
import java.nio.file.StandardOpenOption
|
|
|
|
|
|
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'
|
|
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.1.7'
|
|
}
|
|
|
|
allprojects {
|
|
apply plugin: 'java'
|
|
apply plugin: 'idea'
|
|
|
|
tasks.withType(JavaCompile).configureEach {
|
|
options.encoding = 'UTF-8'
|
|
}
|
|
|
|
if (project.name != "Advanced-Portals") {
|
|
task buildSubmodules doLast {
|
|
task -> println "Building $task.project.name"
|
|
}
|
|
buildSubmodules.finalizedBy build
|
|
}
|
|
|
|
tasks.processResources {
|
|
def files = ["plugin.yml", "bungee.yml"]
|
|
filesMatching(files) {
|
|
expand(["pluginVersion": project.version])
|
|
}
|
|
}
|
|
|
|
sourceCompatibility = JavaVersion.VERSION_16
|
|
targetCompatibility = JavaVersion.VERSION_16
|
|
|
|
}
|
|
|
|
apply from: 'env-variables.gradle'
|
|
|
|
archivesBaseName = "Advanced-Portals"
|
|
group = 'com.sekwah.advancedportals'
|
|
def versionString = (file('./version.txt').text + (isRelease ? "" : "-${snapshotName}${shaRef}")).replaceAll('\n', '').replaceAll('\r', '')
|
|
setVersion(versionString)
|
|
println "Version: ${getVersion()}"
|
|
|
|
description = ""
|
|
|
|
configurations {
|
|
// configuration that holds jars to copy into lib
|
|
implementation.extendsFrom(includeLibs)
|
|
}
|
|
|
|
repositories {
|
|
maven { url "https://repo.maven.apache.org/maven2" }
|
|
maven { url "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" }
|
|
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
|
maven { url "https://nexus.velocitypowered.com/repository/maven-public/" }
|
|
}
|
|
|
|
// includeLibs just says to include the library in the final jar
|
|
dependencies {
|
|
includeLibs project(':lang')
|
|
includeLibs project(':core')
|
|
includeLibs project(':bungee')
|
|
includeLibs project(':spigot')
|
|
includeLibs project(':velocity')
|
|
}
|
|
|
|
apply from: 'env-variables.gradle'
|
|
|
|
println "Branch ${ext.branch}${ext.shaRef} isRelease: '${ext.isRelease}'"
|
|
|
|
|
|
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)
|
|
}
|
|
|
|
}
|
|
|
|
// 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)
|
|
|
|
minecraftServerConfig {
|
|
jarUrl.set('https://download.getbukkit.org/spigot/spigot-1.20.2.jar')
|
|
jvmArgument = ["-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005", "-DIReallyKnowWhatIAmDoingISwear=true"]
|
|
}
|
|
|
|
tasks.withType(Jar).configureEach {
|
|
duplicatesStrategy = DuplicatesStrategy.WARN
|
|
}
|
|
|
|
/**
|
|
* Will build then copy it to the minecraft server folder for use with the launch task and dev tools plugin
|
|
*/
|
|
tasks.register('copyPlugin') {
|
|
dependsOn(build)
|
|
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)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 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
|
|
tasks.register('runJar') {
|
|
doLast {
|
|
javaexec {
|
|
main "-jar"
|
|
args "${System.env.MC_SERVER_LOC}\\${System.env.MC_SERVER_JAR}.jar"
|
|
jvmArgs = ["-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005", "-DIReallyKnowWhatIAmDoingISwear=true"]
|
|
workingDir "${System.env.MC_SERVER_LOC}"
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
idea {
|
|
project {
|
|
settings {
|
|
taskTriggers {
|
|
afterSync(project(':core').tasks.named('generateTemplates'))
|
|
}
|
|
}
|
|
}
|
|
}
|