Switch to indra, attempt to fix shading and universal jar

This commit is contained in:
jmp 2021-02-17 21:32:43 -08:00 committed by KennyTV
parent ef6c347194
commit 024c36c584
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
17 changed files with 226 additions and 245 deletions

View File

@ -1,142 +1,74 @@
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import net.kyori.indra.IndraPlugin
import net.kyori.indra.IndraPublishingPlugin
import net.kyori.indra.sonatypeSnapshots
plugins {
`java-library`
`maven-publish`
id("com.github.johnrengelman.shadow") version ("6.1.0") apply false
id("net.kyori.indra")
}
group = "us.myles"
version = "3.3.0-21w06a"
description = "Allow newer clients to join older server versions."
subprojects {
apply {
plugin<JavaPlugin>()
plugin<JavaLibraryPlugin>()
plugin<MavenPublishPlugin>()
plugin<ShadowPlugin>()
}
group = "us.myles"
version = "3.3.0-21w06a"
description = "Allow newer clients to join older server versions."
java.sourceCompatibility = JavaVersion.VERSION_1_8
apply<JavaLibraryPlugin>()
apply<MavenPublishPlugin>()
apply<IndraPlugin>()
apply<IndraPublishingPlugin>()
tasks {
build {
dependsOn(withType<ShadowJar>())
}
test {
useJUnitPlatform()
}
withType<JavaCompile>() {
options.encoding = "UTF-8"
}
javadoc {
options.encoding = "UTF-8"
}
// Variable replacements
processResources {
filesMatching(listOf("plugin.yml", "mcmod.info", "fabric.mod.json", "bungee.yml")) {
expand("version" to project.version, "description" to project.description)
}
}
}
withType<ShadowJar>() {
archiveFileName.set("ViaVersion-" + project.version + ".jar")
relocate("org.yaml.snakeyaml", "us.myles.viaversion.libs.snakeyaml")
relocate("javassist", "us.myles.viaversion.libs.javassist")
relocate("com.google.gson", "us.myles.viaversion.libs.gson")
relocate("com.github.steveice10.opennbt", "us.myles.viaversion.libs.opennbt")
relocate("net.md_5.bungee", "us.myles.viaversion.libs.bungeecordchat") {
include("net.md_5.bungee.api.chat.*")
include("net.md_5.bungee.api.ChatColor")
include("net.md_5.bungee.api.ChatMessageType")
include("net.md_5.bungee.chat.*")
}
relocate("it.unimi.dsi.fastutil", "us.myles.viaversion.libs.fastutil") {
// We only want int and Object maps
include("it.unimi.dsi.fastutil.ints.*")
include("it.unimi.dsi.fastutil.objects.*")
include("it.unimi.dsi.fastutil.*.class")
// Object types
exclude("it.unimi.dsi.fastutil.*.*Reference*")
exclude("it.unimi.dsi.fastutil.*.*Boolean*")
exclude("it.unimi.dsi.fastutil.*.*Byte*")
exclude("it.unimi.dsi.fastutil.*.*Short*")
exclude("it.unimi.dsi.fastutil.*.*Float*")
exclude("it.unimi.dsi.fastutil.*.*Double*")
exclude("it.unimi.dsi.fastutil.*.*Long*")
exclude("it.unimi.dsi.fastutil.*.*Char*")
// Map types
exclude("it.unimi.dsi.fastutil.*.*Custom*")
exclude("it.unimi.dsi.fastutil.*.*Linked*")
exclude("it.unimi.dsi.fastutil.*.*Sorted*")
exclude("it.unimi.dsi.fastutil.*.*Tree*")
exclude("it.unimi.dsi.fastutil.*.*Heap*")
exclude("it.unimi.dsi.fastutil.*.*Queue*")
// Crossing fingers
exclude("it.unimi.dsi.fastutil.*.*Big*")
exclude("it.unimi.dsi.fastutil.*.*Synchronized*")
exclude("it.unimi.dsi.fastutil.*.*Unmodifiable*")
}
}
val platforms = listOf(
"bukkit",
"bungee",
"fabric",
"sponge",
"velocity"
).map { "viaversion-$it" }
if (platforms.contains(project.name)) {
configureShadowJar()
}
repositories {
maven {
url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots")
}
maven {
url = uri("https://oss.sonatype.org/content/repositories/snapshots")
}
maven {
url = uri("https://nexus.velocitypowered.com/repository/velocity-artifacts-snapshots/")
}
maven {
url = uri("https://repo.spongepowered.org/maven")
}
maven {
url = uri("https://repo.viaversion.com")
}
maven {
url = uri("https://libraries.minecraft.net")
}
maven {
url = uri("https://repo.maven.apache.org/maven2/")
}
sonatypeSnapshots()
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots")
maven("https://nexus.velocitypowered.com/repository/velocity-artifacts-snapshots/")
maven("https://repo.spongepowered.org/maven")
maven("https://repo.viaversion.com")
maven("https://libraries.minecraft.net")
maven("https://repo.maven.apache.org/maven2/")
}
dependencies {
implementation("net.md-5:bungeecord-chat:1.16-R0.5-SNAPSHOT")
implementation("it.unimi.dsi:fastutil:8.3.1")
implementation("com.github.steveice10:opennbt:1.2-SNAPSHOT")
implementation("com.google.code.gson:gson:2.8.6")
implementation("org.javassist:javassist:3.27.0-GA")
implementation("org.yaml:snakeyaml:1.18")
compileOnly("io.netty:netty-all:4.0.20.Final")
compileOnly("com.google.guava:guava:17.0")
compileOnly("org.jetbrains:annotations:19.0.0")
testImplementation("io.netty:netty-all:4.0.20.Final")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.6.3")
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.6.3")
testImplementation("io.netty", "netty-all", Versions.netty)
testImplementation("com.google.guava", "guava", Versions.guava)
testImplementation("org.junit.jupiter", "junit-jupiter-api", Versions.jUnit)
testImplementation("org.junit.jupiter", "junit-jupiter-engine", Versions.jUnit)
}
java {
withSourcesJar()
withJavadocJar()
}
publishing {
publications.create<MavenPublication>("maven") {
from(components["java"])
indra {
javaVersions {
target.set(8)
testWith(8, 11, 15)
}
github("ViaVersion", "ViaVersion") {
issues = true
}
mitLicense()
}
}
}
tasks {
// root project has no useful artifacts
withType<Jar> {
onlyIf { false }
}
}

View File

@ -1,14 +1,13 @@
plugins {
// Support convention plugins written in Kotlin. Convention plugins are build scripts in 'src/main' that automatically become available as plugins in the main build.
`kotlin-dsl`
id("com.github.johnrengelman.shadow") version ("6.1.0") apply false
}
repositories {
// Use the plugin portal to apply community plugins in convention plugins.
gradlePluginPortal()
}
dependencies {
compileOnly("com.github.jengelman.gradle.plugins", "shadow", "6.1.0")
implementation("net.kyori", "indra-common", "1.3.1")
implementation("net.kyori", "indra-publishing-gradle-plugin", "1.3.1")
implementation("com.github.jengelman.gradle.plugins", "shadow", "6.1.0")
}

View File

@ -0,0 +1,31 @@
object Versions {
// common
const val netty = "4.0.20.Final"
const val guava = "17.0"
const val jUnit = "5.6.3"
const val bungeeChat = "1.16-R0.5-SNAPSHOT"
const val fastUtil = "8.3.1"
const val openNBT = "1.2-SNAPSHOT"
const val gson = "2.8.6"
const val javassist = "3.27.0-GA"
const val snakeYaml = "1.18"
const val jetbrainsAnnotations = "19.0.0"
// bukkit
const val spigot = "1.16.5-R0.1-SNAPSHOT"
// bukkit-legacy
const val legacyBukkit = "1.8.8-R0.1-SNAPSHOT"
// bungee
const val bungee = "1.15-SNAPSHOT"
// sponge
const val sponge = "5.0.0-SNAPSHOT"
// sponge-legacy
const val legacySponge = "4.0.0-SNAPSHOT"
// velocity
const val velocityApi = "1.1.0-SNAPSHOT"
}

View File

@ -1,45 +1,81 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.invoke
import org.gradle.kotlin.dsl.withType
import java.io.ByteArrayOutputStream
fun relocate(shadow: ShadowJar) {
shadow.relocate("org.yaml.snakeyaml", "us.myles.viaversion.libs.snakeyaml")
shadow.relocate("javassist", "us.myles.viaversion.libs.javassist")
shadow.relocate("com.google.gson", "us.myles.viaversion.libs.gson")
shadow.relocate("com.github.steveice10.opennbt", "us.myles.viaversion.libs.opennbt")
shadow.relocate("net.md_5.bungee", "us.myles.viaversion.libs.bungeecordchat") {
include("net.md_5.bungee.api.chat.*")
include("net.md_5.bungee.api.ChatColor")
include("net.md_5.bungee.api.ChatMessageType")
include("net.md_5.bungee.chat.*")
fun Project.configureShadowJar() {
apply<ShadowPlugin>()
tasks {
withType<ShadowJar> {
archiveClassifier.set("")
destinationDirectory.set(rootProject.projectDir.resolve("build/libs"))
//minimize() // ?
configureRelocations()
configureExcludes()
}
getByName("build") {
dependsOn(withType<ShadowJar>())
}
}
}
fun relocateAll(shadow: ShadowJar) {
relocate(shadow)
shadow.relocate("it.unimi.dsi.fastutil", "us.myles.viaversion.libs.fastutil") {
// We only want int and Object maps
include("it.unimi.dsi.fastutil.ints.*")
include("it.unimi.dsi.fastutil.objects.*")
include("it.unimi.dsi.fastutil.*.class")
// Object types
exclude("it.unimi.dsi.fastutil.*.*Reference*")
exclude("it.unimi.dsi.fastutil.*.*Boolean*")
exclude("it.unimi.dsi.fastutil.*.*Byte*")
exclude("it.unimi.dsi.fastutil.*.*Short*")
exclude("it.unimi.dsi.fastutil.*.*Float*")
exclude("it.unimi.dsi.fastutil.*.*Double*")
exclude("it.unimi.dsi.fastutil.*.*Long*")
exclude("it.unimi.dsi.fastutil.*.*Char*")
// Map types
exclude("it.unimi.dsi.fastutil.*.*Custom*")
exclude("it.unimi.dsi.fastutil.*.*Linked*")
exclude("it.unimi.dsi.fastutil.*.*Sorted*")
exclude("it.unimi.dsi.fastutil.*.*Tree*")
exclude("it.unimi.dsi.fastutil.*.*Heap*")
exclude("it.unimi.dsi.fastutil.*.*Queue*")
// Crossing fingers
exclude("it.unimi.dsi.fastutil.*.*Big*")
exclude("it.unimi.dsi.fastutil.*.*Synchronized*")
exclude("it.unimi.dsi.fastutil.*.*Unmodifiable*")
}
private fun ShadowJar.configureRelocations() {
relocate("org.yaml.snakeyaml", "us.myles.viaversion.libs.snakeyaml")
relocate("javassist", "us.myles.viaversion.libs.javassist")
relocate("com.google.gson", "us.myles.viaversion.libs.gson")
relocate("com.github.steveice10.opennbt", "us.myles.viaversion.libs.opennbt")
relocate("net.md_5.bungee", "us.myles.viaversion.libs.bungeecordchat")
relocate("it.unimi.dsi.fastutil", "us.myles.viaversion.libs.fastutil")
}
private fun ShadowJar.configureExcludes() {
// bungee api
/*
include("net.md_5.bungee.api.chat.*")
include("net.md_5.bungee.api.ChatColor")
include("net.md_5.bungee.api.ChatMessageType")
include("net.md_5.bungee.chat.*")
*/
// fastutil
// We only want int and Object maps
/*
include("it.unimi.dsi.fastutil.ints.*")
include("it.unimi.dsi.fastutil.objects.*")
include("it.unimi.dsi.fastutil.*.class")
*/
// Object types
exclude("it/unimi/dsi/fastutil/*/*Reference*")
exclude("it/unimi/dsi/fastutil/*/*Boolean*")
exclude("it/unimi/dsi/fastutil/*/*Byte*")
exclude("it/unimi/dsi/fastutil/*/*Short*")
exclude("it/unimi/dsi/fastutil/*/*Float*")
exclude("it/unimi/dsi/fastutil/*/*Double*")
exclude("it/unimi/dsi/fastutil/*/*Long*")
exclude("it/unimi/dsi/fastutil/*/*Char*")
// Map types
exclude("it/unimi/dsi/fastutil/*/*Custom*")
exclude("it/unimi/dsi/fastutil/*/*Linked*")
exclude("it/unimi/dsi/fastutil/*/*Sorted*")
exclude("it/unimi/dsi/fastutil/*/*Tree*")
exclude("it/unimi/dsi/fastutil/*/*Heap*")
exclude("it/unimi/dsi/fastutil/*/*Queue*")
// Crossing fingers
exclude("it/unimi/dsi/fastutil/*/*Big*")
exclude("it/unimi/dsi/fastutil/*/*Synchronized*")
exclude("it/unimi/dsi/fastutil/*/*Unmodifiable*")
}
fun Project.latestCommitHash(): String {
val byteOut = ByteArrayOutputStream()
exec {
commandLine = listOf("git", "rev-parse", "--short", "HEAD")
standardOutput = byteOut
}
return byteOut.toString(Charsets.UTF_8.name()).trim()
}

View File

@ -1,10 +1,8 @@
dependencies {
compileOnly(project(":viaversion-common"))
compileOnly("org.bukkit:bukkit:1.8.8-R0.1-SNAPSHOT") {
implementation(project(":viaversion-common"))
compileOnly("org.bukkit", "bukkit", Versions.legacyBukkit) {
exclude("junit", "junit")
exclude("com.google.code.gson", "gson")
exclude("javax.persistence", "persistence-api")
}
}
description = "viaversion-bukkit-legacy"

View File

@ -1,13 +1,9 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
dependencies {
implementation(project(":viaversion-bukkit-legacy"))
compileOnly(project(":viaversion-common"))
compileOnly("org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT") {
implementation(project(":viaversion-common"))
compileOnly("org.spigotmc", "spigot-api", Versions.spigot) {
exclude("junit", "junit")
exclude("com.google.code.gson", "gson")
exclude("javax.persistence", "persistence-api")
}
}
description = "viaversion-bukkit"

View File

@ -1,6 +1,4 @@
dependencies {
compileOnly(project(":viaversion-common"))
compileOnly("net.md-5:bungeecord-api:1.15-SNAPSHOT")
implementation(project(":viaversion-common"))
compileOnly("net.md-5", "bungeecord-api", Versions.bungee)
}
description = "viaversion-bungee"

View File

@ -1,30 +1,23 @@
plugins {
id("net.kyori.blossom") version "1.1.0"
id("org.ajoberstar.grgit") version "4.1.0"
}
val commitId: String = grgit.head().abbreviatedId
blossom {
replaceToken("\$VERSION", project.version)
replaceToken("\$IMPL_VERSION", "git-ViaVersion-" + project.version + ":" + commitId)
replaceToken("\$IMPL_VERSION", "git-ViaVersion-${project.version}:${rootProject.latestCommitHash()}")
}
dependencies {
implementation("net.md-5:bungeecord-chat:1.16-R0.5-SNAPSHOT")
implementation("it.unimi.dsi:fastutil:8.3.1")
implementation("com.github.steveice10:opennbt:1.2-SNAPSHOT")
implementation("com.google.code.gson:gson:2.8.6")
implementation("org.javassist:javassist:3.27.0-GA")
implementation("org.yaml:snakeyaml:1.18")
api("net.md-5", "bungeecord-chat", Versions.bungeeChat) {
exclude("com.google.guava")
}
api("it.unimi.dsi", "fastutil", Versions.fastUtil)
api("com.github.steveice10", "opennbt", Versions.openNBT)
api("com.google.code.gson", "gson", Versions.gson)
api("org.javassist", "javassist", Versions.javassist)
api("org.yaml", "snakeyaml", Versions.snakeYaml)
compileOnly("io.netty:netty-all:4.0.20.Final")
compileOnly("com.google.guava:guava:17.0")
compileOnly("org.jetbrains:annotations:19.0.0")
testImplementation("io.netty:netty-all:4.0.20.Final")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.6.3")
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.6.3")
compileOnlyApi("io.netty", "netty-all", Versions.netty)
compileOnlyApi("com.google.guava", "guava", Versions.guava)
compileOnlyApi("org.jetbrains", "annotations", Versions.jetbrainsAnnotations)
}
description = "viaversion-common"

View File

@ -1,5 +1,3 @@
dependencies {
compileOnly(project(":viaversion-common"))
implementation(project(":viaversion-common"))
}
description = "viaversion-fabric"

0
gradlew vendored Normal file → Executable file
View File

View File

@ -1,18 +0,0 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
dependencies {
implementation(project(":viaversion-common"))
implementation(project(":viaversion-bukkit"))
implementation(project(":viaversion-bungee"))
implementation(project(":viaversion-fabric"))
implementation(project(":viaversion-sponge"))
implementation(project(":viaversion-velocity"))
}
tasks {
withType<ShadowJar>() {
archiveFileName.set("ViaVersion-" + project.version + ".jar")
}
}
description = "viaversion-jar"

View File

@ -1,21 +1,22 @@
rootProject.name = "viaversion-parent"
include(":viaversion")
include(":viaversion-common")
include(":viaversion-bukkit")
include(":viaversion-bukkit-legacy")
include(":viaversion-bungee")
include(":viaversion-velocity")
include(":viaversion-sponge-legacy")
include(":viaversion-sponge")
include(":viaversion-fabric")
setupViaSubproject("common")
setupViaSubproject("bukkit")
setupViaSubproject("bukkit-legacy")
setupViaSubproject("bungee")
setupViaSubproject("velocity")
setupViaSubproject("sponge")
setupViaSubproject("sponge-legacy")
setupViaSubproject("fabric")
setupViaSubproject("universal")
project(":viaversion-common").projectDir = file("common")
project(":viaversion-bukkit").projectDir = file("bukkit")
project(":viaversion-bukkit-legacy").projectDir = file("bukkit-legacy")
project(":viaversion-bungee").projectDir = file("bungee")
project(":viaversion-velocity").projectDir = file("velocity")
project(":viaversion-sponge").projectDir = file("sponge")
project(":viaversion-sponge-legacy").projectDir = file("sponge-legacy")
project(":viaversion-fabric").projectDir = file("fabric")
project(":viaversion").projectDir = file("jar")
fun setupViaSubproject(name: String) {
setupSubproject("viaversion-$name") {
projectDir = file(name)
}
}
inline fun setupSubproject(name: String, block: ProjectDescriptor.() -> Unit) {
include(name)
project(":$name").apply(block)
}

View File

@ -1,6 +1,4 @@
dependencies {
compileOnly(project(":viaversion-common"))
compileOnly("org.spongepowered:spongeapi:4.0.0-SNAPSHOT")
implementation(project(":viaversion-common"))
compileOnly("org.spongepowered", "spongeapi", Versions.legacySponge)
}
description = "viaversion-sponge-legacy"

View File

@ -1,7 +1,5 @@
dependencies {
implementation(project(":viaversion-sponge-legacy"))
compileOnly(project(":viaversion-common"))
compileOnly("org.spongepowered:spongeapi:5.0.0-SNAPSHOT")
implementation(project(":viaversion-common"))
compileOnly("org.spongepowered","spongeapi", Versions.sponge)
}
description = "viaversion-sponge"

View File

@ -0,0 +1,23 @@
tasks {
val universalJar = register<Jar>("universalJar") {
artifacts.add("archives", this)
archiveClassifier.set("")
destinationDirectory.set(rootProject.projectDir.resolve("build/libs"))
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
arrayOf(
"bukkit",
"bungee",
"fabric",
"sponge",
"velocity"
).forEach {
val subProject = rootProject.project(":viaversion-$it")
val shadowJarTask = subProject.tasks.getByName("shadowJar")
from(zipTree(shadowJarTask.outputs.files.singleFile))
dependsOn(shadowJarTask)
}
}
build {
dependsOn(universalJar)
}
}

View File

@ -1,7 +1,5 @@
dependencies {
compileOnly(project(":viaversion-common"))
compileOnly("com.velocitypowered:velocity-api:1.1.0-SNAPSHOT")
annotationProcessor("com.velocitypowered:velocity-api:1.1.0-SNAPSHOT")
implementation(project(":viaversion-common"))
compileOnly("com.velocitypowered", "velocity-api", Versions.velocityApi)
annotationProcessor("com.velocitypowered", "velocity-api", Versions.velocityApi)
}
description = "viaversion-velocity"