bukman/build.gradle
Frank van der Heijden 15e3ba306c
Fix the common module being relocated due to adventure
Making a single distributable jar with adventure is fun
2021-10-05 12:46:45 +02:00

129 lines
4.1 KiB
Groovy

plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '6.1.0'
}
group = 'net.frankheijden.serverutils'
String dependencyDir = group + '.dependencies'
version = '3.0.0'
allprojects {
ext {
cloudVersion = '1.6.0-SNAPSHOT'
adventureVersion = '4.8.1'
adventurePlatformVersion = '4.0.0-SNAPSHOT'
adventureMinimessageVersion = '4.1.0-SNAPSHOT'
bstatsVersion = '2.2.1'
}
}
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8
subprojects {
apply plugin: 'java'
apply plugin: 'checkstyle'
apply plugin: 'com.github.johnrengelman.shadow'
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url 'https://repo.incendo.org/content/repositories/snapshots' }
maven { url 'https://papermc.io/repo/repository/maven-public/' }
maven { url 'https://libraries.minecraft.net' }
}
dependencies {
implementation "cloud.commandframework:cloud-core:${rootProject.cloudVersion}"
implementation "cloud.commandframework:cloud-brigadier:${rootProject.cloudVersion}"
implementation 'com.github.FrankHeijden:MinecraftReflection:1.0.0'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'me.lucko:commodore:1.10'
compileOnly 'com.mojang:brigadier:1.0.17'
testCompile 'org.assertj:assertj-core:3.18.1'
testCompile 'org.junit.jupiter:junit-jupiter-api:5.7.0'
testCompile 'org.junit.jupiter:junit-jupiter-params:5.7.0'
testCompile 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
}
compileJava {
options.compilerArgs += ["-parameters"]
options.fork = true
options.forkOptions.executable = 'javac'
}
test {
useJUnitPlatform()
}
checkstyle {
toolVersion "8.38"
configFile = file("${rootDir}/config/checkstyle/checkstyle.xml")
ignoreFailures = false
maxErrors = 0
maxWarnings = 0
}
shadowJar {
exclude 'com/mojang/**'
exclude 'javax/annotation/**'
exclude 'org/checkerframework/**'
relocate 'com.google.gson', dependencyDir + '.gson'
relocate 'dev.frankheijden.minecraftreflection', dependencyDir + '.minecraftreflection'
relocate 'cloud.commandframework', dependencyDir + '.cloud'
relocate 'me.lucko.commodore', dependencyDir + '.commodore'
relocate 'io.leangen.geantyref', dependencyDir + '.typetoken'
relocate 'net.kyori.adventure', dependencyDir + '.adventure'
relocate 'net.kyori.examination', dependencyDir + '.examination'
relocate 'net.kyori.adventure.text.minimessage', dependencyDir + '.adventure.text.minimessage'
relocate 'dev.frankheijden.minecraftreflection', dependencyDir + '.minecraftreflection'
}
shadowJar.dependsOn checkstyleMain, checkstyleTest, test
}
repositories {
mavenCentral()
}
dependencies {
implementation project(path: ':Common', configuration: 'shadow')
implementation project(path: ':Bukkit', configuration: 'shadow')
implementation project(path: ':Bungee', configuration: 'shadow')
implementation project(path: ':Velocity', configuration: 'shadow')
implementation("net.kyori:adventure-text-serializer-gson:${rootProject.adventureVersion}") {
exclude group: 'net.kyori', module: 'adventure-api'
exclude group: 'com.google.code.gson', module: 'gson'
}
}
shadowJar {
relocate 'net.kyori.adventure.text.serializer.gson', dependencyDir + '.impl.adventure.text.serializer.gson'
archiveFileName = "${archiveBaseName.orNull}-${archiveVersion.orNull}.${archiveExtension.orNull}"
}
def outputTasks() {
[
"shadowJar",
":Bukkit:shadowJar",
":Bungee:shadowJar",
":Velocity:shadowJar",
].stream().map({ tasks.findByPath(it) })
}
task copyJars(type: Copy) {
outputTasks().forEach({ from(it) })
rename '(.*)-all.jar', '$1.jar'
into file('jars')
}
task cleanJars() {
delete file('jars')
}
clean.dependsOn cleanJars
build.dependsOn shadowJar
build.dependsOn copyJars