Iris/build.gradle
2021-12-30 20:58:43 -08:00

224 lines
7.7 KiB
Groovy

/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
plugins {
id 'java'
id 'io.freefair.lombok' version '5.2.1'
id "com.github.johnrengelman.shadow" version "7.0.0"
id "de.undercouch.download" version "4.1.2"
}
group 'com.volmit.iris'
version '1.9.7-1.18.X'
def nmsVersion = "1.18.1"
def apiVersion = '1.18'
def name = getRootProject().getName() // Defined in settings.gradle
def main = 'com.volmit.iris.Iris'
// ADD YOURSELF AS A NEW LINE IF YOU WANT YOUR OWN BUILD TASK GENERATED
// ======================== WINDOWS =============================
registerCustomOutputTask('Cyberpwn', 'C://Users/cyberpwn/Documents/development/server/plugins', name)
registerCustomOutputTask('Psycho', 'D://Dan/MinecraftDevelopment/server/plugins', name)
registerCustomOutputTask('ArcaneArts', 'C://Users/arcane/Documents/development/server/plugins', name)
registerCustomOutputTask('Coco', 'C://Users/sjoer/Desktop/MCSM/plugins', name)
registerCustomOutputTask('Strange', 'D://Servers/1.17 Test Server/plugins', name)
// ========================== UNIX ==============================
registerCustomOutputTaskUnix('CyberpwnLT', '/Users/danielmills/Documents/development/server/plugins', name)
registerCustomOutputTaskUnix('PsychoLT', '/Users/brianfopiano/Desktop/REMOTES/RemoteMinecraft/plugins', name)
// ==============================================================
def registerCustomOutputTask(name, path, plugin) {
if (!System.properties['os.name'].toLowerCase().contains('windows'))
{
return;
}
tasks.register('build' + name, Copy) {
group('development')
outputs.upToDateWhen { false }
dependsOn ':shadowJar'
from(file('build/libs/' + plugin + '-' + version + '-all.jar'))
into(file(path))
rename { String fileName ->
fileName.replace(plugin + '-' + version + '-all.jar', plugin + ".jar")
}
}
}
def registerCustomOutputTaskUnix(name, path, plugin) {
if(System.properties['os.name'].toLowerCase().contains('windows'))
{
return;
}
tasks.register('build' + name, Copy) {
group('development')
outputs.upToDateWhen { false }
dependsOn ':shadowJar'
from(file('build/libs/' + plugin + '-' + version + '-all.jar'))
into(file(path))
rename { String fileName ->
fileName.replace(plugin + '-' + version + '-all.jar', plugin + ".jar")
}
}
}
/**
* Gradle is weird sometimes, we need to delete the plugin yml from the build folder to actually filter properly.
*/
file(jar.archiveFile.get().getAsFile().getParentFile().getParentFile().getParentFile().getAbsolutePath() + '/build/resources/main/plugin.yml').delete()
/**
* Expand properties into plugin yml
*/
processResources {
filesMatching('**/plugin.yml') {
expand(
'name': name.toString(),
'version': version.toString(),
'main': main.toString(),
'apiversion': apiVersion.toString()
)
}
}
/**
* Unified repo
*/
repositories {
mavenLocal{
content{
includeGroup("org.bukkit")
includeGroup("org.spigotmc")
}
}
maven { url "https://dl.cloudsmith.io/public/arcane/archive/maven/" }
mavenCentral()
mavenLocal()
}
/**
* We need parameter meta for the decree command system
*/
compileJava {
options.compilerArgs << '-parameters'
}
/**
* Configure Iris for shading
*/
shadowJar {
minimize()
append("plugin.yml")
relocate 'com.dfsek.paralithic', 'com.volmit.iris.util.paralithic'
relocate 'io.papermc.lib', 'com.volmit.iris.util.paper'
relocate 'net.kyori', 'com.volmit.iris.util.kyori'
dependencies {
include(dependency('io.papermc:paperlib'))
include(dependency('com.dfsek:Paralithic'))
include(dependency('net.kyori:'))
}
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor 60, 'minutes'
resolutionStrategy.cacheDynamicVersionsFor 60, 'minutes'
}
/**
* Dependencies.
*
* Provided or classpath dependencies are not shaded and are available on the runtime classpath
*
* Shaded dependencies are not available at runtime, nor are they available on mvn central so they
* need to be shaded into the jar (increasing binary size)
*
* Dynamically loaded dependencies are defined in the plugin.yml (updating these must be updated in the
* plugin.yml also, otherwise they wont be available). These do not increase binary size). Only declare
* these dependencies if they are available on mvn central.
*/
dependencies {
// Provided or Classpath
compileOnly 'org.projectlombok:lombok:1.18.22'
annotationProcessor 'org.projectlombok:lombok:1.18.22'
implementation 'org.spigotmc:spigot-api:1.18.1-R0.1-SNAPSHOT'
implementation 'me.clip:placeholderapi:2.10.10'
implementation 'io.th0rgal:oraxen:1.94.0'
compileOnly 'org.bukkit:craftbukkit:1.18.1-R0.1-SNAPSHOT:remapped-mojang'
compileOnly 'org.spigotmc:spigot:1.18.1-R0.1-SNAPSHOT:remapped-mojang'
// Shaded
implementation 'com.dfsek:Paralithic:0.4.0'
implementation 'io.papermc:paperlib:1.0.5'
implementation "net.kyori:adventure-text-minimessage:4.2.0-SNAPSHOT"
implementation "net.kyori:adventure-platform-bukkit:4.0.0" // Dont upgrade yet
implementation 'net.kyori:adventure-api:4.9.2' // Dont upgrade yet
// Dynamically Loaded
implementation 'io.timeandspace:smoothie-map:2.0.2'
implementation 'it.unimi.dsi:fastutil:8.5.6'
implementation 'com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2'
implementation 'org.zeroturnaround:zt-zip:1.14'
implementation 'com.google.code.gson:gson:2.8.9'
implementation 'org.ow2.asm:asm:9.2'
implementation 'com.google.guava:guava:31.0.1-jre'
implementation 'bsf:bsf:2.4.0'
implementation 'rhino:js:1.7R2'
implementation 'com.github.ben-manes.caffeine:caffeine:3.0.5'
implementation 'org.apache.commons:commons-lang3:3.12.0'
}
System.out.println("Gradle is using Java: " + JavaVersion.current());
def buildToolsJar = new File(buildDir, "buildtools/BuildTools.jar");
def specialSourceJar = new File(buildDir, "specialsource/SpecialSource.jar");
def buildToolsFolder = new File(buildDir, "buildtools");
// ======================== Building Mapped Jars =============================
task downloadBuildtools(type: Download) {
src 'https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar'
dest buildToolsJar
onlyIf{
!buildToolsJar.exists()
}
}
task downloadSpecialSource(type: Download){
src 'https://repo.maven.apache.org/maven2/net/md-5/SpecialSource/1.10.0/SpecialSource-1.10.0-shaded.jar'
dest specialSourceJar
onlyIf{
!specialSourceJar.exists()
}
}
task executeBuildTools(dependsOn: downloadBuildtools, type: JavaExec)
{
classpath = files(buildToolsJar)
workingDir = buildToolsFolder
args = [
"--rev",
nmsVersion,
"--compile",
"craftbukkit",
"--remap"
]
onlyIf{
!buildToolsFolder.exists()
}
}
tasks.compileJava.dependsOn(executeBuildTools)