mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-09-27 14:52:59 +02:00
148 lines
4.4 KiB
Groovy
148 lines
4.4 KiB
Groovy
|
|
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'
|
|
}
|
|
|
|
allprojects {
|
|
apply plugin: 'java'
|
|
|
|
tasks.withType(JavaCompile) {
|
|
options.encoding = 'UTF-8'
|
|
}
|
|
|
|
if (project.name != "Advanced-Portals") {
|
|
task buildSubmodules doLast {
|
|
task -> println "Building $task.project.name"
|
|
}
|
|
buildSubmodules.finalizedBy build
|
|
}
|
|
|
|
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 = ""
|
|
|
|
tasks.withType(JavaCompile) {
|
|
options.encoding = 'UTF-8'
|
|
}
|
|
|
|
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) {
|
|
duplicatesStrategy = DuplicatesStrategy.WARN
|
|
}
|
|
|
|
/**
|
|
* Will build then copy it to the minecraft server folder for use with the launch task and dev tools plugin
|
|
*/
|
|
task copyPlugin() {
|
|
dependsOn(build)
|
|
doLast {
|
|
copy {
|
|
println "$buildDir/libs/Advanced-Portals-${getVersion()}.jar"
|
|
println "$buildDir/MinecraftServer/plugins/Advanced-Portals-${getVersion()}.jar"
|
|
try {
|
|
delete fileTree("$buildDir/MinecraftServer/plugins/") {
|
|
include "Advanced-Portals*.jar"
|
|
}
|
|
}
|
|
catch (RuntimeException e) {
|
|
println e.getLocalizedMessage()
|
|
}
|
|
from file("$buildDir/libs/Advanced-Portals-${getVersion()}.jar")
|
|
into file("$buildDir/MinecraftServer/plugins")
|
|
}
|
|
}
|
|
}
|